Posted April 28, 201312 yr Hello, all. I've been trying to code an unenchantment table, but I'm having some problems actually getting the inventory changes to "stick", so to speak. Here is the code for my gui's button action: protected void actionPerformed(GuiButton guibutton) { //id is the id you give your button if (this.inventorySlots.getSlot(0).getHasStack()) { ItemStack stackInSlot = this.inventorySlots.getSlot(0).getStack(); EntityPlayer player = this.mc.thePlayer; if (stackInSlot.isItemEnchanted()) { ItemStack tempItemStack = new ItemStack(stackInSlot.getItem()); tempItemStack.setItemDamage(stackInSlot.getItemDamage()); System.out.println(((ItemStack) this.inventorySlots.getInventory().get(0)).getDisplayName()); this.inventorySlots.getSlot(0).putStack(tempItemStack); this.inventorySlots.detectAndSendChanges(); player.inventoryContainer.detectAndSendChanges(); } this.inventorySlots.detectAndSendChanges(); player.inventoryContainer.detectAndSendChanges(); } } The item simply reverts to it's previous state after it I click on it. Any ideas? Thanks!
April 28, 201312 yr Author So, how exactly would I go about implementing this packethandler/packet system? Can you supply some example code, or perhaps link me to a tutorial? I've looked at the one of the Forge wiki, but I'm still confused. Thanks!
April 28, 201312 yr Author I've overridden the method, but it isn't being called when the button is pressed.
April 28, 201312 yr Author protected void actionPerformed(GuiButton guibutton) { // if (this.inventorySlots.getSlot(0).getHasStack()) { Packet108EnchantItem packet = new Packet108EnchantItem(0, 1); PacketDispatcher.sendPacketToServer(packet); // } }
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.