Jump to content

ItemStack's NBTTagCompound not saving


tylermmorton

Recommended Posts

Hi, I'm programming an item that has it's own inventory inside, and I'm using NBT to store the itemstacks of the inventory. The problem is, every time I open the inventory of the item it resets my NBT tags to a new compound. Here is the code.

 

http://pastebin.com/9BjeE9D6 (edit - the param "backpack" is actually "stack" in the code.)

 

Every time I create a new isntance of ItemInventory using the exact same ItemStack, it always ends up not having a tag compound, and ends up generating a new one. (I know this because of the sysouts that get called when I add a test tag)

 

My only guess as to why the NBT data isn't saving is because Java's pass-by-value system, where the ItemStack I'm passing into this constructor never gets changed where it actually resides in memory, and in turn the data is not getting saved.

 

If anyone has an insight on this, that would be awesome :) thanks!

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.