Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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..

 

PackItem
GuiHandler

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! :P

Any help is appreciated!

 

Edited by shauncjones

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/

  • 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.

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?

  • 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

  • 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... :(

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.

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.