Skip to content

Triggers ​

The triggers action of a rule runs server commands when a death matches. Use it for a consolation item, an announcement, a scoreboard counter or a script hook.

json
{
  "rules": [
    { "match": "minecraft:lava", "then": { "triggers": {
        "commands": ["say {player} fell into lava at {x} {y} {z}"], "cooldownSeconds": 60 } } },
    { "match": "mob:minecraft:creeper", "then": { "triggers": {
        "commands": ["give {player} minecraft:bread 4"], "oncePerPlayer": true } } }
  ]
}

Fields ​

FieldDefaultMeaning
commandsList of server commands. A leading / is optional.
oncePerPlayerfalseRun only for the first matching death of each player (remembered in .cache/stats_<uuid>.json)
cooldownSeconds0Minimum time between two runs for the same player

The rule's match and conditions (with the dead player's progress) decide when it runs; with conditions, then and else can have different triggers.

Placeholders ​

PlaceholderValue
{player}Name of the player who died
{x} {y} {z}Block position of the death (rounded down)
{damage}Health points of the killing blow, one decimal
any template variableFor example {attacker_name}, {damage_id}, {dimension}, {weapon}. Filled in English, whatever the display switches say. Unknown braces stay as they are.

{damage} in commands

In commands {damage} is in health points. The template variable {damage} in templates is in hearts.

How they run ​

  • Server only (also the integrated server in single player), with console permission.
  • Only one set of triggers runs per death: the first rule from the top whose active branch has triggers (priority). Put several commands into one rule, or make the special rule come first.
  • oncePerPlayer and the cooldown are counted per rule and branch.

Test without dying ​

/whm test minecraft:lava

shows the triggers that would run, with placeholders filled in and the rule they come from, but does not run them. The pack editor's preview shows the same.

Examples ​

Count lava deaths in a scoreboard:

json
{ "match": "minecraft:lava", "then": { "triggers": { "commands": ["scoreboard players add {player} lava_deaths 1"] } } }

Tell new players about a guide book once, but not veterans:

json
{ "match": "*", "unless": ["tag:veteran"],
  "then": { "triggers": { "commands": ["tellraw {player} {\"text\":\"Check the quest book for survival tips!\"}"], "oncePerPlayer": true } } }

Announce boss deaths with the attacker's name:

json
{ "match": "@twilightforest:*", "then": { "triggers": { "commands": ["say {player} was defeated by {attacker_name} in {dimension}"], "cooldownSeconds": 30 } } }

Made by junjun1z. The mods are MIT licensed.