Jump to content

Items thrown out of inventory instead of being put into "hand"


WorldsEnder

Recommended Posts

Hey guys. I have a problem which is exactly what the title says. I have made a Container and opening it up works fine. I have not tested putting something in and taking it out again because well I have bind player's Inventory and a custom inventory and try to let items be switched between them. I guess I have to override some method in the Container. Here are my 2 files:

 

MHItemChestContainer:

http://paste.minecraftforge.net/view/1c70ae3b

 

InventoryMHItemChest:

http://paste.minecraftforge.net/view/3d880296

 

If you need anything else, just ask for it :D

Thanks for your time

Link to comment
Share on other sites

Your transferStackInSlot function is returning null. If this is happening on shift-click then you should consider putting some code in there.

 

Mine looks like this.

 

 

 

  /**
     * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that.
     */
    public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
    {
        ItemStack var3 = null;
        Slot var4 = (Slot)this.inventorySlots.get(par2);

        if (var4 != null && var4.getHasStack())
        {
            ItemStack var5 = var4.getStack();
            var3 = var5.copy();

            if (par2 == 2)
            {
                if (!this.mergeItemStack(var5, 3, 39, true))
                {
                    return null;
                }

                var4.onSlotChange(var5, var3);
            }
            else if (par2 != 1 && par2 != 0)
            {
                if (MillRecipes.smelting().getSmeltingResult(var5) != null)
                {
                    if (!this.mergeItemStack(var5, 0, 1, false))
                    {
                        return null;
                    }
                }
                else if (TileEntityMill.isItemFuel(var5))
                {
                    if (!this.mergeItemStack(var5, 1, 2, false))
                    {
                        return null;
                    }
                }
                else if (par2 >= 3 && par2 < 30)
                {
                    if (!this.mergeItemStack(var5, 30, 39, false))
                    {
                        return null;
                    }
                }
                else if (par2 >= 30 && par2 < 39 && !this.mergeItemStack(var5, 3, 30, false))
                {
                    return null;
                }
            }
            else if (!this.mergeItemStack(var5, 3, 39, false))
            {
                return null;
            }

            if (var5.stackSize == 0)
            {
                var4.putStack((ItemStack)null);
            }
            else
            {
                var4.onSlotChanged();
            }

            if (var5.stackSize == var3.stackSize)
            {
                return null;
            }

            var4.onPickupFromSlot(par1EntityPlayer, var5);
        }

        return var3;
    }

 

 

"The Gentle Way... My @$$!"

-average new judo student upon learning the meaning of the word Judo in Japanese

Link to comment
Share on other sites

Not sure if this is helpful or not, but it sounds a lot like the MC bug that can happen in full screen mode. That is usually fixed by going to windowed mode, and/or hitting the ALT key a couple times while in an inventory gui.

 

I'd check that just to be sure you rule out a runtime bug and not the code.

"The Gentle Way... My @$$!"

-average new judo student upon learning the meaning of the word Judo in Japanese

Link to comment
Share on other sites

Actually it was a problem with the GUI. The GUIContainer class features a ySize-variable which defines wheter you have clicked "out of the GUI". If yes then the ItemStack you have in-hand is thrown away. As my GUI was a bit bigger than the default sitze of 176*166 I clicked "out of the Gui" and the items got thrown away. One mystery less in the world ^^

 

Appreciated your help Me

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.



×
×
  • Create New...

Important Information

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