How stable is itemstack NBT data?

Started by Stitch147 on

Topic category: Help with modding (Java Edition)

Last seen on 05:10, 3. Dec 2023
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How stable is itemstack NBT data?
Fri, 08/25/2023 - 23:02 (edited)

As the title says, how stable is itemstack NBT? Specifically this would be a number variable.

 

I have a currency that is currently stored on a player global variable, but I want to change it over to an item NBT variable, so that the item itself holds the currency. I know that entity NBT can be a little unstable, so I was wondering how stable item NBT is - will it hold the data over time from logging in and out, will it work on multiplayer, will it hold data when dropped, or when put into an item frame?

 

Also, is there a maximum number of NBT's I can add to the item?

 

Thank you :)

Edited by Stitch147 on Fri, 08/25/2023 - 23:02
Last seen on 15:05, 6. Oct 2023
Joined Jan 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Item NBTs should be the most…
Fri, 08/25/2023 - 23:05

Item NBTs should be the most stable NBT holder, I've tried blockstate nbt (and it didn't even save somewhy), entity I didn't try yet but Item works for me (tested up to 8 tags), keeps the data whatever you do with it (next to deleting/crafting/smelting or anything)

Last seen on 05:10, 3. Dec 2023
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Cool! Thank you so much! I…
Sat, 08/26/2023 - 00:17

Cool! Thank you so much! I've had similar experiences with blockstate not saving as well.

Last seen on 21:37, 17. Feb 2024
Joined Dec 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@ModProgrammMiked Block data…
Sat, 08/26/2023 - 11:31

@ModProgrammMiked Block data will not work if block entity is selected, all NBT will Always should be infinite.

Last seen on 15:05, 6. Oct 2023
Joined Jan 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@presidentuni how do i…
Sat, 08/26/2023 - 11:34

@presidentuni how do i unselect it then?

Last seen on 05:10, 3. Dec 2023
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You can unselect it under…
Sat, 08/26/2023 - 14:24

You can unselect it under the "Block Entity" tab in the block's element. 

 

I'm confused though, the description says block entity needs to be on in order to store NBT data.

Last seen on 15:05, 6. Oct 2023
Joined Jan 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@Stitch147 yea ik thats why…
Sat, 08/26/2023 - 15:21

@Stitch147 yea ik thats why i asked

maybe he meant deselecting something different idk

Last seen on 05:10, 3. Dec 2023
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
After some time playing…
Sun, 09/10/2023 - 20:08

After some time playing around with it, it seems you do need it to be a Block Entity to save the data. All my block NBT data so far has been saving properly, and stays when I log out of the world or completely restart the game. I haven't had any issues with data being lost over time either.

Last seen on 20:43, 20. Aug 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
In my experience, item and…
Mon, 10/02/2023 - 21:58

In my experience, item and entity NBT are pretty solid, I've been able to use entity NBTs for pathfinding and timers in some (very specific) use cases. Haven't tried block NBT tags, modifying and assigning vanilla ones works fine, but custom ones seem a bit iffier.

Last seen on 20:21, 9. May 2024
Joined Jan 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
is it however possible to…
Fri, 01/12/2024 - 20:11

is it however possible to change NBT values of an item which is not in anyone's inventory, but floating in the air?

Last seen on 20:43, 20. Aug 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You would need to make a…
Fri, 01/12/2024 - 21:13

You would need to make a procedure with a local itemstack variable, set the itemstack variable to the itemstack entity, converted into an itemstack. (There should be a conversion function that, when provided with an item entity, converts it to an itemstack.) Then apply the NBT changes to the local itemstack variable, despawn the original item entity, and spawn in a new item with the changes applied.