> ## Documentation Index
> Fetch the complete documentation index at: https://entities.lodemc.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Triggers

> When an effect line runs: every trigger, what fires it, and who @trigger is.

A trigger decides **when** a line runs. It's the part prefixed with `+`:

```yaml theme={null}
- narrate "Ow!"  +onHurt  @trigger
```

* A line with **no trigger runs when the mob spawns** (`+onSpawn`). MythicMobs' own default is `onCombat`; the [MythicMobs importer](https://entities.lodemc.net/mythicmobs.md) writes `+onCombat` on any imported line that had none, so imported skills behave as they did.
* The `on` is optional: `+hurt` and `+onHurt` are the same trigger.
* MythicMobs' `~onHurt` and the old `#onHurt` both still parse. A file that uses them is rewritten to `+` the next time it loads.

> [!NOTE]
>
> **Why `+`?** `#` is YAML's comment character, so one hand edit that broke the loader's quoting could silently turn a whole line into a comment. `+` means nothing to YAML.

## @trigger and @target

Every trigger records **who caused it**, and `@trigger` targets that entity:

```yaml theme={null}
- damage{amount=2}            +onHurt     @trigger   # thorns: hits whoever hit it
- giveitem{items=diamond 1}   +onDeath    @trigger   # rewards the killer
- message{m=&7Hello!}         +onInteract @trigger   # replies to the clicker
```

`@target` is the mob's **current AI target**, falling back to the trigger entity when it has none. Most of the time those are the same entity; when a mob is chasing one player and gets hit by another, `@trigger` is the one who hit it. See [Targeters](https://entities.lodemc.net/targeters.md).

## Mob triggers

| Trigger | Also | Fires when | `@trigger` is |
| :- | :- | :- | :- |
| `+onSpawn` | `+onFirstSpawn` | the mob is spawned (command, egg, spawner, `summon`, API). The default. | nothing |
| `+onLoad` | | the mob is loaded back in with its chunk | nothing |
| `+onSpawnOrLoad` | | either of the two above | nothing |
| `+onReady` | | one tick after it spawns | nothing |
| `+onDespawn` | `+onDespawned` | it is removed without dying (not counting its chunk unloading) | nothing |
| `+onHurt` | `+onDamaged`, `+onDamage` | it takes damage | the attacker |
| `+onSkillDamage` | `+onSkillHit` | it takes damage from a skill's `damage` | the caster of that skill |
| `+onAttack` | `+onHit` | it damages something in melee | the victim |
| `+onBowHit` | | a projectile it shot hits | the entity hit |
| `+onShoot` | `+onBowShoot` | it shoots a bow or crossbow | its target |
| `+onCombat` | `+onDefault` | it hurts or is hurt by something | the other entity |
| `+onEnterCombat` | | it starts fighting | the opponent |
| `+onDropCombat` | `+onLeaveCombat` | 10 seconds pass with no fighting and no target | nothing |
| `+onTargetChange` | `+onChangeTarget` | it picks a new target | the new target |
| `+onDeath` | `+onDie` | it dies | the killer |
| `+onKill` | | it kills something | the victim |
| `+onPlayerKill` | `+onKillPlayer` | it kills a player | the player |
| `+onInteract` | `+onClick`, `+onRightClick` | a player right-clicks it | the player |
| `+onTimer:N` | | every `N` ticks while it is alive: `+onTimer:40`, `+onTimer:2s` | nothing |
| `+onSignal:NAME` | | the [`signal`](mechanics-flow) mechanic sends it that signal; `+onSignal` alone catches any | the sender |
| `+onExplode` | | it explodes | nothing |
| `+onPrime` | | a creeper starts its fuse | nothing |
| `+onCreeperCharge` | `+onCharged` | a creeper is charged by lightning | the lightning |
| `+onTeleport` | | it teleports | nothing |
| `+onChangeWorld` | `+onWorldChange` | it moves to another world | nothing |
| `+onJump` | | it jumps | nothing |
| `+onTame` | | it is tamed (vanilla taming, or a [pet](https://entities.lodemc.net/pets.md) taming) | the new owner |
| `+onTameFail` | | a [pet](https://entities.lodemc.net/pets.md) taming attempt fails | the player |
| `+onPetSummon` | `+onSummoned` | a [pet](https://entities.lodemc.net/pets.md) is summoned | the owner |
| `+onPetDismiss` | `+onDismissed` | a pet is put away | the owner |
| `+onPetFeed` | `+onFed` | its owner feeds it | the owner |
| `+onPetLevelUp` | `+onLevelUp` | it gains a level; `<skill.var.level>` is the new one | the owner |
| `+onPetEvolve` | `+onEvolve` | it evolves | the owner |
| `+onBreed` | | it breeds | the other parent, or the player who fed them |
| `+onTrade` | | a player trades with it | the player |
| `+onHear` | `+onVibration` | a warden-style vibration reaches it; `<skill.var.sound>` holds the sound | the source |
| `+onSplashPotion` | `+onPotionSplash` | a splash potion hits it | the thrower |
| `+onMount` | | something mounts it | the rider |
| `+onUnmount` | | something gets off it | the rider |
| `+onItemPickup` | `+onPickupItem` | it picks up an item | the item |
| `+onItemDrop` | `+onDropItem` | it drops an item | the item |
| `+onMilk` | `+onMilked` | a player milks it | the player |
| `+onBucket` | `+onUseBucket` | a player catches it in a bucket | the player |
| `+onFishGrab` | `+onFishingGrab` | a fishing rod hooks it | the player |

## Player and item triggers

MythicMobs' player and item triggers load without errors, so a line using one never fails to parse: `+onUse`, `+onSwing`, `+onCrouch`, `+onUncrouch`, `+onConsume`, `+onBlockPlace`, `+onBlockBreak`, `+onFish`, `+onFishBite`, `+onFishCatch`, `+onFishGround`, `+onFishReel`, `+onFishFail`, `+onTridentThrow`, `+onTridentHit`, `+onEquip`, `+onUnequip`, `+onPressQ`, `+onPressCtrlQ`, `+onPressF`, `+onPress`, `+onRelease`, `+onJoin`, `+onRespawn`, `+onCast`, `+onCustom`, `+onBlock`, `+onPlayerDeath`.

Mobs never fire them on their own. An addon fires them through the API; see [Extending the Effect Language](https://entities.lodemc.net/extending-effects.md#custom-triggers).

## Several lines, one trigger

Lines that share a trigger run top to bottom:

```yaml theme={null}
boss:
  base: zombie
  effects:
  - sound{s=entity.wither.spawn;volume=2} +onSpawn @playersInRadius{r=30}
  - narrate "&4The boss has awakened."    +onSpawn @playersInWorld
  - lightning                             +onDeath @self
  - narrate "&aThe boss has fallen!"      +onDeath @playersInWorld
```

## Triggers live on the calling line

Only a mob's own `effects:` lines carry triggers. Lines inside a [skill](https://entities.lodemc.net/named-effects.md) inherit the moment they were called from: the `skill` line has the trigger, the skill just runs.

```yaml theme={null}
  effects:
  - skill{s=smash} +onHurt @trigger   # the trigger lives here
  smash:
  - lunge{velocity=1.6}               # no triggers in here
  - delay 0.5s
  - damage{amount=10} @playersRadius[4]
```

To gate a line on what fired it, use a trigger condition: `?~isPlayer` runs the line only when the trigger entity is a player. See [Line Options](https://entities.lodemc.net/line-options.md#inline-conditions).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.