NBT Component Changes - ShaneBeee/SkBee GitHub Wiki

[!NOTE] This wiki is specifically for Minecraft 1.20.5+

Minecraft 1.20.5 changed the structure of NBT for items, they introduced a component system which refactored the layout of where items store different datas.
You can read more about the Data Component Format on McWiki

NBT Compound Changes:

Due to the changes in with how Minecraft deals with NBT, the expression for getting an NBT compound has slightly changed.

NBT of Item:

Pattern: nbt of %item%

  • This will return the "components" tag of an item's full NBT.
  • This is where all Minecraft vanilla data is stored (ex: enchantments, attribute modifiers, damage, custom model data, etc).
  • You cannot create custom components here, all custom data will need to be stored within the "minecraft:custom_data" component.
  • Editing this NBT will directly update the item itself.

Custom NBT of Item:

Pattern: custom nbt of %item%

  • This syntax will now return everything in the Item's "minecraft:custom_data" component (see McWiki for more details).
  • This is where you will store all your custom data in an item.
  • This will not include any Minecraft specific data (ex: enchantments, attribute modifiers, damage, custom model data, etc).
  • Editing this NBT will directly update the item itself.

Full NBT of Item:

Pattern: full nbt of %item%

  • This has no change from previous behaviour.
  • This will return the full NBT of an item, generally used for serialization.
  • Will include the following tags "id", "count", "components", "Slot" (only on items within an inventory).
  • Editing this NBT will have no effect on the original item itself.

Item with NBT:

Due to changes in how components are done now, when using the %item% with %nbt% expression, a few other changes need to be made.
Custom Data will need to be put in the "minecraft:custom_data" component.

Previous behaviour:

Previously, any custom data could be put anywhere in the NBT of an item.

give player diamond sword with nbt from "{points:10}"

New Behaviour:

Minecraft now uses a component system, and all custom data must go into the "minecraft:custom_data" component.

give player diamond sword with nbt from "{""minecraft:custom_data"":{points:10}}"

Secondary Option:

Using the custom part of the item with [custom] %nbt% expression, data will be put into the "minecraft:custom_data" component.

give player diamond sword with custom nbt from "{points:10}"

Serialization Information:

We got lucky here. NBT-API (the api behind SkBee's NBT system) luckily has made use of Minecraft's DataFixerUpper (their system for updating things during MC updates).
What this means for you is, any items previously serialized via full nbt of %item% will now be properly updated when using the nbt item from %nbt% expression.
You can also use this as a cheat to convert old NBT to new NBT.
This can be handy if you find old NBT strings from websites.

Custom Data Changes:

Previously all custom data on an item could be stored in the "tag" portion of an item's NBT.
Minecraft has changed this behaviour with their new component system.
The "tag" tag no longer exists. It has now be renamed "components".
Within that tag, all custom data must now be stored in the "minecraft:custom_data" component.
Any items that were saved prior to the 1.20.5 update, will automatically be updated.
This means any data you previously had in the "tag" compound, will be automatically moved to the new "minecraft:custom_data" compound within the "components" compound.