Skip to main content

Store Data (Block Action Type)

Writes the block's ID, full state string, position and block entity NBT into a command storage, so a later command can place it back, copy it or hand it to a function macro.

Type ID: apoli:store_data

Fields

FieldTypeDefaultDescription
storageIdentifierrequiredThe command storage to write into, such as example:scratch.
pathString""A key path inside that storage, separated by dots. Empty writes at the root.
nbtBooleantrueWhether to include the block entity's NBT under nbt, when the block has one.
mergeBooleanfalseMerges into whatever is already at path instead of replacing it.

What gets written

KeyTypeValue
idStringThe block ID, such as minecraft:oak_log.
stateStringThe block ID with its properties, such as minecraft:oak_log[axis=y], which is exactly what /setblock wants.
propertiesCompoundEach block state property as a string, such as {axis: "y"}.
x, y, zIntThe block position.
posString"x y z", ready to paste into a command.
dimensionStringThe dimension the block is in.
nbtCompoundThe block entity's NBT, when there is one and nbt is true.

Examples

Store the block a power just interacted with, then place a copy of it in front of the player:

"block_action": {
  "type": "apoli:store_data",
  "storage": "example:scratch",
  "path": "block"
}
"entity_action": {
  "type": "apoli:execute_command",
  "command": "setblock ^ ^ ^2 $(state)",
  "arguments": {
    "storage": "example:scratch",
    "path": "block"
  }
}

$(state) carries the block's properties with it, so a log placed this way keeps its axis. arguments is the macro substitution of apoli:execute_command itself, so this works on every version without function macros. If you would rather use a real function macro, the same storage can be read with /function example:place with storage example:scratch block.