Jump to content

[1.7.10] Adding Player Inventory slots to GUI screens


timoteo2000

Recommended Posts

Hey guys! I was recently working with a block in my mod that opens a GUI when rightclicked. I successfully added 1 slot in the upper part of the GUI (the part that would be special to the block.) After that, I snooped in the enchantment table GUI code and added all the inventory slots. I've encountered 2 problems though:

  • The slots do not display the real inventory items, but it seems I can pick up items and place them back down in a glitchy manner.
  • The slots are offset by 1 row down, causing the hotbar items to be inaccessible and a blank row to exist.

 

I've already looked through the Gits of a few other mods with containers to see if they have anything different than I do in any relevant classes, but to no avail.

 

Here are some links to gits for my mod:

BlockEnhancementTable

ContainerEnhancementTable

GuiHandler

GuiEnhancementTable

TileEntityEnhancementTable (Currently empty, and it doesn't implement IInventory because this table acts like a crafting bench, dropping items when closed)

 

I know that the place all the inventory slots are added in is the 2 for loops in ContainerEnhancementTable's constructor (the first is for the inventory, the second the hotbar) but this is exactly how it was done in the Enchanting Table's Container class. I also see no other methods in the Enchanting Table's container class that make the items appear.

 

Thanks in advance for the help, and if you need to look at any other classes in the project, everything is available in this repo.

EntityHerobrine.setDead();

 

Pwned.

Link to comment
Share on other sites

Link to comment
Share on other sites

I found this tutorial really helpful for setting up your container and the transfer stack code

http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571390-1-6-2-advanced-minecraft-forge-modding-tutorial-2

 

As I said before, I'm not saving any data to the block, it is not an inventory. I already have all the transfer stuff setup for shift clicking and the for loops I had were exactly the same. I am still running into both of my problems.

 

Thank you though, I may need these later.

EntityHerobrine.setDead();

 

Pwned.

Link to comment
Share on other sites

You must return a container in getServerGuiElement. Also, remove if(world.isRemote) in onBlockActivated.

Thank you so much! Another thing I had to do was have EntityPlayer.inventory rather than InventoryPlayer when I called Container and GuiEnhancementTable. Also, I have no clue why I was making sure the world was remote, but before removing that I couldn't remove the items so yeah.

 

Thanks again :3

EntityHerobrine.setDead();

 

Pwned.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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