Commands/data

From Minecraft Wiki
Jump to: navigation, search
Java Edition.png
data
Restrictions

Operator

First introduced

1.13 (17w45a)

Allows the player to get, merge, and remove block entity and entity NBT data.

Syntax
data get block <pos> [<path>] [<scale>]
data get entity <target> [<path>] [<scale>]
data merge block <pos> <nbt>
data merge entity <target> <nbt>
data remove block <pos> <path>
data remove entity <target> <path>
Arguments
pos
Specifies the position of the block.
target
Specifies the target entity.
path (Optional)
Specifies the path to the targeted NBT.
Data paths look like this: foo.bar[0]."A [crazy name]".baz.
  • foo.bar means foo's child called bar.
  • foo[0] means element 0 of foo.
  • "quoted strings" may be used if a name of a key needs to be escaped.
scale (Optional)
Scales the number retrieved from get.
nbt
Specifies the NBT tag to be merged/removed.
Result
Fails if the arguments are not specified correctly.
On success:
  • get — Return value depends on what arguments are specified.
No additional arguments
Sends the entire NBT data from the block at pos or one target entity to the executor with syntax highlighting, and returns 1.
Only path
Sends the subsection of the NBT data from the block at pos or one target entity to the executor without syntax highlighting. Return value depends on the type of the NBT element:
  • Retrieving a number will return that number.
  • Retrieving a string will return the length of the string.
  • Retrieving a list will return the number of elements in that list.
  • Retrieving a compound will return the number of tags that are direct children of that compound.
Both path and scale
Requires a numeric value to be at the end of the path. Returns that numeric value scaled by scale.
  • merge — Merges the block NBT data at pos or from the target entity with the specified nbt data. Returns 1 on success.
  • remove — Will remove NBT data at path from the block at pos or from one target entity. Removing player NBT data is not allowed. Returns 1 on success.



Promotional Content