3059673 Posted February 8, 2014 Posted February 8, 2014 My custom container slots are overlaying player's invetory slots (not visually). When i click on slots in my container, it somehow clicks on the respective slot in player's inventory and swaps/puts/takes items from it . How do i manage that ? In my container constructor i didn't add any player's inventory slots, i don't need them. Quote
3059673 Posted February 8, 2014 Author Posted February 8, 2014 TickHandler - Server - player //ThaumicWheelProject if(utils.isKeyPressed("V",player.username) && player.getCurrentEquippedItem()!= null && player.getCurrentEquippedItem().getItem() instanceof ItemWandCasting && (!player.getEntityData().hasKey(ThaumicWheelUtils.isOpenedForNBT) || !player.getEntityData().getBoolean(ThaumicWheelUtils.isOpenedForNBT))){ player.getEntityData().setBoolean(ThaumicWheelUtils.isOpenedForNBT, true); new SimplePacket().openNewThaumicWheelGUI(player); } else if(!utils.isKeyPressed("V",player.username) && (player.getEntityData().hasKey(ThaumicWheelUtils.isOpenedForNBT) || player.getEntityData().getBoolean(ThaumicWheelUtils.isOpenedForNBT))){ player.getEntityData().setBoolean(ThaumicWheelUtils.isOpenedForNBT, false); if(ThaumicWheelUtils.GUIs.containsKey(player)) player.closeScreen(); ThaumicWheelUtils.GUIs.remove(player); } //................ In packethandler FMLNetworkHandler.openGui is used. Container public class ThaumicWheelContainer extends Container{ public World world; public EntityPlayer player; public int posX,posY,posZ; public ItemStack pouch; public int pouchSlot = -1; public IInventory inv = new FocusPouchINV(); public ThaumicWheelContainer(EntityPlayer player,World par2World, int par3, int par4, int par5) { this.world = par2World; this.posX = par3; this.posY = par4; this.posZ = par5; this.player = player; this.pouch = ThaumicWheelUtils.playerGetPouch(player); this.pouchSlot = ThaumicWheelUtils.playerGetPouchSlot(player); ThaumicWheelUtils.GUIs.put(player, this); for (int a = 0; a < 18; a++) { this.addSlotToContainer(new RestrictedSlot(inv, a, 37 + a % 6 * 18, 60 + a / 6 * 18,IWandFocus.class)); } ItemFocusPouch p = (ItemFocusPouch) ConfigItems.itemFocusPouch; if(pouch != null && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemWandCasting){ ItemStack[] fs = p.getInventory(pouch); for(int i = 0;i<fs.length;i++){ inv.setInventorySlotContents(i, fs[i]); } }else{ player.closeScreen(); player.getEntityData().setBoolean(ThaumicWheelUtils.isOpenedForNBT, false); if(ThaumicWheelUtils.GUIs.containsKey(player)) player.closeScreen(); ThaumicWheelUtils.GUIs.remove(player); } } @Override public boolean canInteractWith(EntityPlayer entityplayer) { return true; } public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer par4EntityPlayer){ new SimplePacket().changeWandFoci(par4EntityPlayer,par1); return (((Slot)this.inventorySlots.get(par1)) != null) ? ((Slot)this.inventorySlots.get(par1)).getStack() : null; } } GuiContainer public class ThaumicWheelGUI extends GuiContainer{ public EntityPlayer player; public ItemStack wand; public ThaumicWheelGUI(EntityPlayer player,World world,int x, int y,int z){ super(new ThaumicWheelContainer(player,world,x,y,z)); this.player = player; this.wand = player.getCurrentEquippedItem(); } public boolean doesGuiPauseGame() { return false; } public void drawScreen(int par1, int par2, float par3) { super.drawScreen(par1, par2, par3); } @Override protected void drawGuiContainerBackgroundLayer(float f, int i, int j) { UtilsFX.drawTag(50, 50, Aspect.AIR); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("thaumcraft","textures/gui/gui_focuspouch.png")); int x = (this.width-175)/2; int y = (this.height-142)/2; GL11.glEnable(3042); this.drawTexturedModalRect(x, y, 0, 0, 175, 142); GL11.glDisable(3042); } } Quote
3059673 Posted February 8, 2014 Author Posted February 8, 2014 Where should i call FMLNetworkHandler.openGui/EntityPlayer.openGui on SERVER or on CLIENT ? Quote
larsgerrits Posted February 8, 2014 Posted February 8, 2014 On the server side. Quote Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.