Posted September 25, 20159 yr So I currently have a backpack working thing is, I want every new backpack to have its own inventory. How would I go about doing this?
September 25, 20159 yr 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.
September 25, 20159 yr Author I have the backpack inventory i just want it to be unique for each new player gets new backpack, the new backpack is a different inventory to the last one.
September 25, 20159 yr What did I just write? ( ͠° ͟ʖ ͡°) 1.7.10 is no longer supported by forge, you are on your own.
September 25, 20159 yr http://www.apostropheabuse.com/ 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.
September 26, 20159 yr 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. http://i.imgur.com/NdrFdld.png[/img]
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.