NBT - Modify NBT (Section) — SkBee

Addon: SkBee · Category: Section · Since: 3.11.0

Syntax

modify [custom] nbt of %entity/block/itemstack/itemtype/slot%

Description

Modify NBT of an entity/block(TileEntity)/item. This method is faster than the old NBT expressions, as the changes aren't applied to the object until the section is done. This section creates its own internal event, which means previous event-values will not work. **OPTIONS**: `entity` = Will modify the base nbt of an entity/player. `block` = Will modify the base nbt of a block, must be a tile entity block. `item` = Will modify the base nbt of an item (the components section of an item). `custom` = Will modify the custom nbt of an item (the "minecraft:custom_data" component), entity or block.

Examples

# Item
modify nbt of player's tool:
	set int tag "test" of nbt to 1
# Item - Custom
modify custom nbt of player's tool:
	set double tag "points" of nbt to 10.5

# Entity
modify nbt of player:
	set int tag "SomeRealNbtTag" of nbt to 5
# Entity - Custom
modify custom nbt of player:
	set string tag "blah" of nbt to "ooo a string"

# Block
modify nbt of target block:
	set short tag "cooking_time_spent" of nbt to 25
# Block - Custom
modify custom nbt of target block:
	set string tag "owner" of nbt to {_nameOfPlayer}

View source