Skip to content

Skill Triggers ​

Every trigger a mob definition's actions section can bind, plus the context variables each action line receives, is listed below. The actions section in a mob definition binds lifecycle trigger events to CoreLib action pipelines. Action lines are executed by the EmakiCoreLib action pipeline (a hard dependency), so installing EmakiSkills is not required. The legacy skills key remains as a compatibility fallback and logs a WARN when read; migrating is recommended

Trigger list ​

TriggerWhen it firesContext objects
on_spawnMob spawned (inside MobFactory, right after the boss bar and model attach)—
on_deathMob dieskiller (only when a living killer exists)
on_targetMob acquires a new targettarget (only when the target is non-null)
on_damage_giveThis mob deals damage as the attackertarget (only when the victim is a living entity)
on_damage_takeThis mob takes damageattacker (only when the damager is a living entity)
on_killMob kills an entityvictim (the killed entity)
on_shootMob fires a projectile—
on_explodeMob explodes (e.g. Creeper)—
on_teleportMob teleports—
on_transformMob transforms (e.g. zombie → drowned)—
on_health_threshold_<percent>Mob health first drops to or below that percentage—

The objects listed under "Context objects" are supplied by EmakiMobs through CoreLib action context keys. When one is absent, the matching source (such as killer) resolves to nothing and that action line is not executed. There is no damage-amount object — neither on_damage_give nor on_damage_take provides damage; use another CoreLib mechanism when you need the amount

Health threshold triggers ​

on_health_threshold_<percent> uses a fixed set of five tiers; only these five key names fire:

on_health_threshold_90
on_health_threshold_75
on_health_threshold_50
on_health_threshold_25
on_health_threshold_10

Other numbers (such as on_health_threshold_80) raise no error but never fire

Each tier fires only once per mob. When a mob takes damage, the tiers are checked from 90 down to 10; if a single hit crosses several tiers, each crossed tier fires in sequence during that same hit. The percentage is computed as current health / max-health attribute value, and no threshold check runs when that attribute is missing or non-positive

NOTE

Health thresholds are checked together with the damage event, so on_damage_take and any crossed threshold trigger run at the same time

Action string format ​

Each trigger maps to a list of CoreLib action pipeline strings:

[selector |] action_name [key=value ...]

Common selectors ​

SelectorProvided byDescription
selfCoreLibThe mob that fired the event (the pipeline caster)
targetEmakiMobsThe current event's target entity (on_target, on_damage_give)
killerEmakiMobsThe entity that killed the mob (on_death)
victimEmakiMobsThe entity killed by the mob (on_kill)
attackerEmakiMobsThe entity that damaged the mob (on_damage_take)
nearby radius=<n> include_players=trueCoreLibEntities within the radius. Players are excluded by default: include_players defaults to false, so writing only type=player selects nobody — add include_players=true explicitly

The four EmakiMobs-provided selectors (target / killer / victim / attacker) depend on the context objects listed above and can only resolve a target when that object exists in the trigger's event

Action examples ​

yaml
actions:
  on_spawn:
    # Send a message to all players within 20 blocks
    - "nearby radius=20 include_players=true | send_message text='<red>Elite Zombie has arrived!'"
    # Spawn particles at the mob's location
    - "self | spawn_particle particle=FLAME count=30 offset_x=0 offset_y=1 offset_z=0"

  on_death:
    # Give experience to the killer
    - "killer | give_exp amount=80"
    # Broadcast defeat message to nearby players
    - "nearby radius=50 include_players=true | send_message text='<green>Elite Zombie defeated!'"

  on_damage_give:
    # Apply slowness to the target
    - "target | give_potion_effect type=SLOWNESS level=1 duration=3s"

  on_damage_take:
    # Spawn flame particles when hurt
    - "self | spawn_particle particle=FLAME count=10 offset_x=0 offset_y=1 offset_z=0"

  on_target:
    # Play a sound when acquiring a target
    - "self | play_sound sound=minecraft:entity.skeleton.ambient volume=1.0 pitch=0.7"

Sources and stages registered by EmakiMobs ​

Besides CoreLib's built-in content, EmakiMobs registers 8 segments with the action system (the startup log prints the registered count against an expected 8): four sources attacker / killer / victim / target, and four stages summon_mob / mob_play_animation / mob_stop_animation / mob_set_model. When an action line fails to compile, the console prints 技能编译错误: mob=<id> trigger=<trigger> line=<line> reason=<reason>; that line is skipped and the other lines of the same trigger still run

summon_mob — summon a mob definition ​

Summons an EmakiMobs mob definition at the target's location

ParameterTypeRequiredDefaultAccepted valuesDescription
mob_idstringYesnonea loaded mob definition id (case-sensitive)Definition to summon; a missing or blank value returns a configuration error (INVALID_CONFIG), and an unregistered id returns the same
countintNo1≥ 1 (below 1 is treated as 1)Number to summon; spawned one by one at the target location
yaml
actions:
  on_damage_take:
    # Summon two fire guardians at the mob's own location
    - "self | summon_mob mob_id=fire_guardian count=2"

  on_health_threshold_50:
    # At half health, summon one minion at the killer's location
    - "killer | summon_mob mob_id=boss_minion"

The action needs a resolvable location from the target (its execution domain is the location region). With no location it returns skipped; when every summon fails it returns INTERNAL_ERROR

Model stages ​

The parameters and behaviour of mob_play_animation, mob_stop_animation, and mob_set_model are documented in the "Action stages" section of Entity Models & Animations

NOTE

The full list of available actions and their parameter syntax is provided by EmakiCoreLib. Refer to the CoreLib documentation for all supported actions