Posted January 14, 20187 yr Hey guys, I am trying to make a backpack type item. I have managed to get the item to open a gui but when I put items into the item and close it the items disappear. Can anyone tell me what I'm doing wrong? My code is below.. PackItemGuiHandler PackContainer I also have a small problem with the GUI slots being about one pixel too far to the left so if you spot the fix for that, then i'll be just as happy! Any help is appreciated! Edited January 15, 20187 yr by shauncjones
January 14, 20187 yr Don't implement ICapabilityProvider in your Item class. You need to override Item#initCapabilities to return an instance of an ICapabilityProvider. Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support. 1.12 -> 1.13 primer by williewillus. 1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support. http://www.howoldisminecraft1710.today/
January 14, 20187 yr Author 10 minutes ago, larsgerrits said: Don't implement ICapabilityProvider in your Item class. You need to override Item#initCapabilities to return an instance of an ICapabilityProvider. Yeah, I was playing around I changed it back after I posted this but it still doesn't save items.
January 14, 20187 yr I believe you need a class that implements ICapabilitySerializable for your capability.
January 14, 20187 yr Looks like everytime something changes on the slots of your backpack you not saving those changes on the NBT (I may be wrong but check if that is happening) Also, not sure how you populate the slots, are those been fill with the contents you get from the NBT?
January 14, 20187 yr Author 24 minutes ago, American2050 said: Looks like everytime something changes on the slots of your backpack you not saving those changes on the NBT (I may be wrong but check if that is happening) Also, not sure how you populate the slots, are those been fill with the contents you get from the NBT? I managed to get the Items to be persistent with these changes. But when I save and reload the world they are empty again. PackItem GuiHandler PackContainer PackCompatibilityProvider
January 14, 20187 yr You have no code in your serializeNBT and deserializeNBT methods. That's where you write/read the stuff you wamt to save.
January 14, 20187 yr Author 12 minutes ago, Ugdhar said: You have no code in your serializeNBT and deserializeNBT methods. That's where you write/read the stuff you wamt to save. Well it saves the items till I close the world. But I have no clue where to even start writing stuff in there...
January 14, 20187 yr 7 minutes ago, shauncjones said: Well it saves the items till I close the world. But I have no clue where to even start writing stuff in there... It's not saving anything. The items are just in there, if they had saved it'd work when you log in again. The class net.minecraft.item.ItemStack has methods for saving NBT data containing items and whatnot. I'd take a gander over there for saving NBT data.
January 14, 20187 yr 38 minutes ago, shauncjones said: Well it saves the items till I close the world. But I have no clue where to even start writing stuff in there... I ran into this issue, it was primarily the fact that I didn't have the correct sides or checked the world.isRemote correctly.
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.