HyperScript
Docs

← All of the Docs Items

NBT and data on things

expressionnbt <key> of tool of <who>since 1.7.42

What is kept under that key on the item in their hand; unset if there is nothing. It can be set and deleted: set nbt "kills" of tool of player to 5, delete nbt "kills" of tool of player

send "&7%nbt of tool of player%"
Try it
expressionnbt <key> of block at <location>since 1.7.42

The same on a block that can keep data: a chest, a barrel, a sign, a furnace and the like. A plain block such as stone cannot

set nbt "locked" of block at {_chest} to true
Try it
expressionnbt <key> of <who>since 1.7.42

The same on a player or a creature

delete nbt "tutorial" of player
Try it
expression<item> with nbt <key> <value>since 1.7.43

An item that carries that data from the start: give player diamond sword with nbt "owner" player.name. It may be said several times, and goes with named, with lore and the rest

set {_trophy} to gold ingot named "&6Trophy" with nbt "winner" player.name with nbt "year" 2026
Try it
expressionnbt <key> of <item>since 1.7.43

The same read from an item in a variable: nbt "owner" of {_item}

delete nbt "tutorial" of player
Try it
expressionnbt of tool of <who>since 1.7.42

The whole NBT of the item as one text, to look at; nbt of <who> likewise for a creature. Only where the server can say it; elsewhere it is unset

send "&7%nbt of tool of player%"
Try it
effectset nbt of tool of <who> to <text>since 1.7.43

Lays the game's own tags over what the item has, written as the game writes them: "{Unbreakable:1b}". On Minecraft 1.20.5 and newer an item's tags are written in square brackets, as /give takes them

set nbt of tool of player to "{Unbreakable:1b}"
Try it
effectset nbt of <creature> to <text>since 1.7.43

The same for a creature: set nbt of {_mob} to "{NoAI:1b,Silent:1b}". The game does not let a player's own NBT be changed

set nbt of event entity to "{Silent:1b}"
Try it
effectset nbt of block at <location> to <text>since 1.7.43

The same for a block that has NBT, such as a chest or a spawner

set nbt of block at target block of player to "{Lock:\"secret\"}"
Try it
Guide and examples

Data can be kept on a thing itself: on the item in somebody's hand, on a creature or a player, or on a block that holds something (a chest, a sign, a furnace). The server saves it in the thing's NBT, so it travels with the item from player to player and is still there after a restart.

command /soulbind:
    trigger:
        set nbt "owner" of tool of player to player.name
        set nbt "kills" of tool of player to 0
        send "&dThis item is yours now."

on entity death:
    if killer is set:
        if nbt "owner" of tool of player is player.name:
            set {_kills} to nbt "kills" of tool of player + 1
            set nbt "kills" of tool of player to {_kills}
            send action bar "&7Kills with this item: &f%{_kills}%" to player

on right click:
    if nbt "locked" of block at event's location is true:
        if nbt "owner" of block at event's location is not player.name:
            cancel event
            send "&cThis is not yours."

command /lock:
    trigger:
        set {_chest} to target block of player
        set nbt "locked" of block at {_chest} to true
        set nbt "owner" of block at {_chest} to player.name
        set nbt "visits" of player to nbt "visits" of player + 1
        delete nbt "tutorial" of player
        send "&7%nbt of tool of player%"

command /trophy:
    permission: "trophy.give"
    trigger:
        set {_trophy} to gold ingot named "&6Trophy" with nbt "winner" player.name with nbt "year" 2026
        give player {_trophy}
        set {_winner} to nbt "winner" of {_trophy}
        send "&7It says: %{_winner}%"
        set nbt of tool of player to "{Unbreakable:1b}"

on mob spawn:
    if event.entity is "zombie":
        set nbt of event entity to "{Silent:1b}"

command /fillchest:
    permission: "fill.use"
    trigger:
        set nbt of block at target block of player to "{Lock:\"secret\"}"
SyntaxWhat it does
nbt <key> of tool of <who>What is kept under that key on the item in their hand; unset if there is nothing. It can be set and deleted: set nbt "kills" of tool of player to 5, delete nbt "kills" of tool of player
nbt <key> of block at <location>The same on a block that can keep data: a chest, a barrel, a sign, a furnace and the like. A plain block such as stone cannot
nbt <key> of <who>The same on a player or a creature
<item> with nbt <key> <value>An item that carries that data from the start: give player diamond sword with nbt "owner" player.name. It may be said several times, and goes with named, with lore and the rest
nbt <key> of <item>The same read from an item in a variable: nbt "owner" of {_item}
nbt of tool of <who>The whole NBT of the item as one text, to look at; nbt of <who> likewise for a creature. Only where the server can say it; elsewhere it is unset
set nbt of tool of <who> to <text>Lays the game's own tags over what the item has, written as the game writes them: "{Unbreakable:1b}". On Minecraft 1.20.5 and newer an item's tags are written in square brackets, as /give takes them
set nbt of <creature> to <text>The same for a creature: set nbt of {_mob} to "{NoAI:1b,Silent:1b}". The game does not let a player's own NBT be changed
set nbt of block at <location> to <text>The same for a block that has NBT, such as a chest or a spawner
  • A value is a text, a number, or true / false.
  • Whether something is there is asked with is set: if nbt "owner" of tool of player is not set:.
  • A key written plainly, such as "kills", is HyperScript's own and no other plugin touches it. A key written with a colon, such as "otherplugin:level", is what another plugin keeps under that name, and can be read and changed the same way.
  • Keys and whole NBT are two things. A key (nbt "kills" of ...) is data of your own, kept apart from the game's, and it is what a script should use for its own bookkeeping. The whole NBT (set nbt of ... to "{...}") is the game's own tags, for what has no statement of its own. What is written there is handed to the game as it is, so a tag the game does not know is refused by the game, and the console says so.
  • For what there is a statement for, use the statement: set health of, enchanting an item, unbreakable. They work the same on every version; the names of the game's tags do not.
  • Data on an item belongs to that one item. tagged and with model are still the simple way to mark an item a script hands out; see Players.