Skip to content

Scripts

LlaGuiTo edited this page Sep 30, 2026 · 1 revision

Scripts

Applies to all versions.

Scripts are JSON files in a datapack that run commands when a specific block or entity is picked up, while it is carried and when it is put down. They are loaded from data/<namespace>/scripts/*.json and are only used when useScripts = true (default).

Format

{
  "priority": 0,
  "object": {
    "name": "spawner_warning",
    "type": "block",
    "match": "minecraft:spawner"
  },
  "effects": {
    "commandInit": "tellraw @p {\"text\":\"Careful, it's heavy!\"}",
    "commandLoop": "",
    "commandPlace": "playsound minecraft:block.anvil.land block @p"
  }
}
Field Required Description
priority No (0) When several scripts match, the highest priority wins.
object.name Yes A name for the script (shown by /carrymechanics debug).
object.type Yes block or entity.
object.match Yes The block or entity id, for example minecraft:chest. * matches every block (or entity). With a [, only the part before it is compared as a prefix.
effects.commandInit No Runs once when the object is picked up.
effects.commandLoop No Runs every server tick while it is carried.
effects.commandPlace No Runs when it is placed or stacked.

Commands run from the server at the player's position, as the player; @p is replaced by the player's name.

Reserved sections

The format also accepts a conditions object (gamestage, advancement, xpLevel, gamemode, scoreboard, nbt) and a render object (nameOverride, type, renderLeftArm, renderRightArm, renderScale…). They are parsed but not applied in the current versions: conditions are always considered met and the render settings are ignored.

Clone this wiki locally