NBT - Compound of Object (Expression) — SkBee

Addon: SkBee · Category: Expression · Since: 1.6.0

Syntax

[full] [vanilla] [custom] nbt [compound] [copy] (of|from) %objects%

Description

Get the NBT compound of a block/entity/item/file/chunk.

**SPECIAL CASES**: - `full nbt of %item%` = Returns a copy of the FULL NBT of an item (this includes id, count and 'components' compound). Modifying this will have no effect on the original item. This is useful for serializing items. - `nbt of %item%` = Returns the original. Modifying this will modify the original item. \- This will return the 'components' portion of an item's full NBT. - `custom nbt of %item%` = Returns the 'minecraft:custom_data' component of an item's NBT. Modifying this will modify the original item. Please see [**Data Component Format**](https://minecraft.wiki/w/Data_component_format) on McWiki for more information on item NBT components. - `[full] vanilla nbt of %item%` = Will return the same as above except it will include vanilla components which don't normally show in NBT. - `nbt copy of %objects%` = Returns a copy of the original NBT compound. This way you can modify it without actually modifying the original NBT compound, for example when grabbing the compound from an entity, modifying it and applying to other entities. - `custom nbt of %object%` = Returns the custom portion of the NBT of the object. For many objects Minecraft does not allow for custom NBT, so they're stored in various spots: - Entity: Stored in the entity's PersistentDataContainer. - Item: Stored in the item's `minecraft:custom_data` component. - Block (TileEntity - such as furnace, chest): Stored in the block's PersistentDataContainer. - Block (non TileEntity): Stored in the PersistentDataContainer of the chunk the block is in.

NBT from a file will need to be saved manually using the 'NBT - Save File' effect. If the file does not yet exist, a new file will be created.

CHANGERS: - `add` = Adding a compound to another compound will merge them (This is controlled by Minecraft, results may vary). - `delete` = Will delete NBT files, or clear the NBT compound (This can break entities/players, be careful!). - `reset` = Will clear the NBT compound (This can break entities/players, be careful!)

Examples

set {_n} to nbt of player's tool
set {_n} to full nbt of player's tool
set {_nbt} to nbt of target entity
set {_n} to nbt of chunk at player
set {_n} to nbt copy of player
set {_n} to nbt from "{components:{""minecraft:enchantments"":{levels:{""minecraft:sharpness"":3}}},count:1,id:""minecraft:diamond_sword""}"
set {_nbt} to nbt of file "world/playerdata/some-uuid.dat"

add nbt from "{NoAI:1}" to nbt of last spawned entity
add nbt from "{NoGravity:1}" to nbt of {_entity}
add nbt from "{custom:{points:1}}" to nbt of player
add nbt from "{""minecraft:enchantments"":{levels:{""minecraft:sharpness"":10}}}" to component nbt of player's tool

delete nbt from file "plugins/some/file.nbt"
reset {_n}
reset nbt of player's tool

View source