Reaction binding format
A reaction binding is a JSON object that tells a mob group what to do when something happens to one of its members, such as fleeing when a member is hurt. A mod built on Stope decides where its bindings live (its own data files or config folder); this page lists what every binding can contain, for authors of those files.
Example
Section titled “Example”{ "on": "member_hurt", "do": "flee", "who": "adults", "radius": 12, "when": { "herd_size_at_least": 3, "source_type": ["minecraft:player", "#minecraft:raiders"], "chance": 0.5 }, "cooldown_ticks": 40, "duration_ticks": 80, "then": { "do": "follow_leader" }}Binding keys
Section titled “Binding keys”Any key not in this table, the trigger’s parameters, or the reaction’s parameters makes the
binding fail with a message naming the key. So do unknown trigger and reaction IDs, values of
the wrong type or out of range, and an empty list in source_type or threat. Entity type IDs
and tags in source_type and threat are not checked: one that no installed mod adds never
matches, and the binding still loads.
| Key | Value | What it does |
|---|---|---|
on |
Trigger ID (default none: a standing behavior) | The trigger that starts the binding. An ID without a namespace means Stope’s trigger of that name if there is one, else the namespace of the mod that reads the file. |
do |
Reaction ID, required | The reaction the members run. Namespaces resolve as for on. |
who |
A who value (default all) |
Which members react. |
count |
Whole number (default 1, range 1 to 1024) | How many members react with "who": "nearest". Any other who with count fails. |
radius |
Number (default: the whole group, range 0.5 to 256) | Only members within this many blocks of the member the trigger fired for react. Standing behaviors ignore it. |
when |
Object | Conditions that must all hold for the binding to start; the next four rows are its keys. |
herd_size_at_least (in when) |
Whole number (range 1 to 1024) | The group has at least this many members. |
herd_size_at_most (in when) |
Whole number (range 1 to 1024) | The group has at most this many members. Smaller than herd_size_at_least fails. |
source_type (in when) |
Entity type ID, # entity type tag, or a list of them |
The trigger’s source matches. A trigger with no source never matches. |
chance (in when) |
Number (default 1, range 0 to 1) | The chance the binding starts each time it could. |
cooldown_ticks |
Whole number (default 0, range 0 to 72000 (3,600 seconds)) | The group ignores this binding for that long after it starts. |
then |
Object | The next step, started with the same members when this step ends. It holds do, that reaction’s parameters, and its own then, and no other key. |
Who values
Section titled “Who values”who |
Which members react |
|---|---|
all |
Every member. |
adults |
Every member that is not a baby. |
babies |
Every member that is a baby. |
leader |
The group’s leader; nobody in a group without a leader. |
followers |
Every member but the leader. |
nearest |
The count members nearest the member the trigger fired for, or nearest the group’s center for a standing behavior. |
A who that selects no member, such as leader in a group without a leader, does not start
the binding and does not use up its cooldown.
Triggers
Section titled “Triggers”Every trigger fires only for the group of the member it happened to. Hits and kills by a mob that holds an attack order from a reaction or a mod, and target changes those orders make, fire no trigger, so one group’s reaction never sets off another group’s.
A binding without on is a standing behavior: the group runs it on its regular schedule while
no triggered binding is running. A triggered binding that starts stops the group’s standing
behaviors, and they start again on a later schedule.
| Trigger | Fires when | Source | Parameters |
|---|---|---|---|
member_hurt |
A hit lands on a member. | The attacker, or none (falling, drowning). | None. |
member_killed |
A member dies. | The killer, or none. | None. |
target_acquired |
A member picks a new attack target. Never fires for brain mobs that keep their target only in memory (piglins, hoglins, goats). | The new target. | None. |
threat_seen |
On the group schedule, one member in turn looks for a matching entity it can see within range. Creative and spectator players are ignored. |
The nearest such entity. | threat: entity type ID, # tag, or list, required. range (default 16, range 1 to 64). |
losses |
A member dies, and the group’s deaths within window_ticks reach fraction of its members (counting the dead). |
The group’s last killer. | fraction (default 0.5, range 0.01 to 1). window_ticks (default 200 (10 seconds), range 1 to 72000 (3,600 seconds)). |
Triggers that other mods add take no parameters.
Primitive reactions
Section titled “Primitive reactions”Durations are in game ticks; 20 ticks is 1 second.
| Reaction | Parameters | What members do |
|---|---|---|
flee |
duration_ticks (default 100 (5 seconds), range 1 to 1200 (60 seconds)). speed (default the species’ panic speed or 1.25, range 0.1 to 4). direction: away or random (default away). |
Each member runs on its own, away from the source. With random, or when the trigger has no source, members make short runs every which way. |
avoid |
duration_ticks (default 100 (5 seconds), range 1 to 1200 (60 seconds)). distance (default 8, range 1 to 32). speed (default 1.2, range 0.1 to 3). |
Members keep distance blocks from the source until the time runs out or the source dies. Nothing without a source. |
defend |
duration_ticks (default 200 (10 seconds), range 1 to 2400 (120 seconds)). release (default false). |
Adult members attack the source. Nothing without a living source, or when the source is in the same group. When the run ends the target stays for vanilla AI; with release the defenders drop the target and their anger. Use release for mobs whose own AI never drops a target, such as llamas. |
join_attack |
duration_ticks (default 200 (10 seconds), range 1 to 2400 (120 seconds)). release (default false). |
As defend, for every chosen member, babies included. |
follow_leader |
distance (default 6, range 2 to 32). speed (default 1, range 0.3 to 2). |
Followers farther than distance blocks from the leader, and not already under a movement order, walk back to it. Nothing in a group without a leader. Usually a standing behavior. |
See also
Section titled “See also”- Reactions (Java): how a mod parses bindings, attaches them to groups, and adds reactions of its own.
- Mob groups: what makes a group, its leader, and its schedule.
- Herd animals that flee from players: a guide that builds a fleeing herd step by step.