Jump to content

[HELP] Custom slot in inventory


Recommended Posts

Hi All! I made my slot for ContainerPlayer.java, but when I put back an item that item appears in the slot for a helmet.







package net.minecraft.inventory;

import mods.AdventureCraft.src.BackpackItem;

import net.minecraft.item.ItemStack;

class SlotBackpack extends Slot


final ContainerPlayer inventory;

SlotBackpack(ContainerPlayer containerplayer, IInventory iinventory, int i, int j, int k, int l)


                super(iinventory, i, j, k);

                inventory = containerplayer;


public int getSlotStackLimit()


                return 1;


public boolean isItemValid(ItemStack itemstack)


                return itemstack.getItem() instanceof BackpackItem;






Add my slot in ContainerPlayer.java



for (i = 0; i < 1; ++i)


this.addSlotToContainer(new SlotBackpack(this, par1InventoryPlayer, par1InventoryPlayer.getSizeInventory() - 1, 60, 8 + 2 * 18, 100));





Please, help me. And sorry for my bad English :)

Link to comment
Share on other sites

  • 3 weeks later...

Might I suggest opening a custom Gui with your Item Backpack rather than editing the base inventory gui? For an example of this, check out my tutorial on creating an Item that stores an Inventory: http://www.minecraftforum.net/topic/1949352-creating-an-item-that-stores-an-inventory/


If you want an extra inventory slot to store the item, like I see you are doing, you could store it in IExtendedEntityProperties and assign a special key to open your custom player inventory to allow access to your custom slot. If you need help with IExtendedEntityProperties, I also have a tutorial on that:



I've done this exact thing helping out some guys making a Naruto mod - they needed custom inventory slots for Sharingan Eyes, and I did it like I outlined above.

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.

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.