Jump to content

Inventory Change Not "Sticking"


SirJshreder

Recommended Posts

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!

Link to comment
Share on other sites

protected void actionPerformed(GuiButton guibutton) {
//        if (this.inventorySlots.getSlot(0).getHasStack()) {
            Packet108EnchantItem packet = new Packet108EnchantItem(0, 1);
            PacketDispatcher.sendPacketToServer(packet);
//        }
    }

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.