Skip to content

Triggers

A pheno:trigger gene runs its action when an event happens to the bearer. For the gene fields, see Gene Nodes.

TriggerFires WhenCounterpart (other)
when_hurtThe bearer takes damage.The attacker.
when_attackThe bearer damages something.The victim.
when_killThe bearer kills something.The victim.
when_deathThe bearer dies.The killer.
when_death_preventedA pheno:prevent death gene saves the bearer.The killer.
when_landThe bearer lands after a fall.none
when_jumpThe bearer jumps.none
when_sleepThe bearer starts to sleep, in a bed or another rest spot.none
when_wake_upThe bearer wakes up. when_wake is the same trigger.none
when_restedThe bearer is fully rested while it sleeps. For a player, this is when the player can skip the night. For a villager, this is when its fatigue is gone.none
when_struck_by_lightningLightning strikes the bearer.none
when_equipThe bearer’s equipment changes.none
when_item_useThe bearer finishes using an item. item_condition tests it.none
when_craftThe bearer takes a crafted item. item_condition tests it and item_action changes it before it reaches the inventory; action is optional.none
when_enter_dimensionThe bearer arrives in another dimension.none
when_workThe bearer completes Career work.none
pressThe bearer presses key (default jump).none
aiA villager’s ability AI decides to, by its ai_trigger: when_flying, when_threatened, when_hurt, when_hurt_nearby or always. Players never fire it.none

target: "other" runs the action on the counterpart instead of the bearer. bientity_condition tests (bearer, counterpart) and fails when there is no counterpart, so a lifesteal can skip foes that do not bleed. Damage triggers expose their damage to pheno:event_damage.

A crafting proc that sometimes adds Unbreaking:

{
"type": "pheno:trigger",
"trigger": "when_craft",
"item_action": {
"type": "pheno:chance",
"chance": 0.25,
"action": { "type": "pheno:enchant", "enchantment": "minecraft:unbreaking", "level": 1 }
}
}

Use an ai trigger so that villagers can use a power that players start with a key. Pair it with pheno:keypress. Then the key’s own press trigger runs the power for players and villagers. In this example, a glider flaps its wings on the jump key, and villagers flap too:

{ "type": "pheno:trigger", "trigger": "ai", "ai_trigger": "when_flying",
"action": { "type": "pheno:keypress", "key": "jump" } }

Townstead’s flight AI counts a when_flying ai trigger as a way to gain lift. Winged villagers with one take powered flights, not only glides down.