Jump to content

Inventory's


NathanLeadill

Recommended Posts

Create Item, implement IInventory. Customize your implementation. Since Item is only "description" of what you are holding - it cannot hold data itself (singleton).

 

What holds data  is ItemStack. You can assign NBT with any kind of data to any ItemStack. Save your equipment per-itemStack inside its NBT. For examples (and util methods) lookup vanilla's code (player's inventory for one).

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

You can NOT implement IInventory in an Item class - Items in Minecraft are singletons, so there is only ever one instance of each item, but for an Inventory to work you need the Inventory itself to be a unique instance, otherwise it will be all sorts of messed up.

 

If you want each player to have a unique backpack instance, like a portable Ender Chest, you need to store the inventory in IExtendedEntityProperties and only access the inventory GUI via your item - the item itself will have nothing else to do with the inventory.

 

If you want players to be able to carry as many backpacks as they want, each backpack having storing an independent inventory, you must store the Inventory inside the ItemStack's NBT and basically recreate the inventory from that tag each time you want to interact with it.

 

I have a tutorial that covers both cases.

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.