Movement actions
Walk, pathfind, look, follow, ride, fight, run away and pick things up.
Sixteen actions that move the client or change what it is doing with its body.
Two of them pathfind, goto and
goto_block. Reaching the destination fires
goal_reached, and a path that cannot
be found fires goto_failed. That is how
you write "walk there, then act". The step itself also fails when the client does not
arrive, so try and
last_action_failed see it.
Every action that walks (goto, goto_block, follow, attack with chase, flee,
collect_items and sleep) walks like a careful player. It never breaks a block, never
places one to climb or bridge, and drops at most 3 blocks. Doors, trapdoors and fence gates
count as walls: the client walks round them, and if one is the only way through, the path
fails. Open it first with use_block.
move
Holds a direction for a fixed time. Dumb movement: no pathfinding, no obstacle avoidance.
| Field | Type | Required | Notes |
|---|---|---|---|
direction | forward | back | left | right | yes | Relative to where the client faces. |
ms | integer, 1–60000 | yes | How long to hold it. |
For getting somewhere specific use goto; this is for short nudges.
jump
Jumps once.
No fields.
look
Points the client in an absolute direction.
The editor's palette no longer offers this block: flows that already use it keep working, and look at covers the same need with coordinates.
| Field | Type | Required | Notes |
|---|---|---|---|
yaw | number, −360…360 | yes | Horizontal angle in degrees, as the F3 screen shows it: 0 faces south, 90 west, 180 north, −90 east. |
pitch | number, −90…90 | yes | Vertical angle in degrees, as F3 shows it: −90 is straight up, 0 level, 90 straight down. |
That faces north, looking level. Stand where you want the client to look, press F3 and copy the two numbers after "Facing"; the client turns the same way.
look_at
Turns to face a world coordinate. Easier than working out angles yourself.
| Field | Type | Required | Notes |
|---|---|---|---|
x | integer | yes | World X. |
y | integer, −2048…2048 | yes | World Y. |
z | integer | yes | World Z. |
goto
Pathfinds to a position or to a player, then stops.
| Field | Type | Required | Notes |
|---|---|---|---|
mode | coords | player | no | Default coords. |
x, y, z | integers | for coords | The destination. |
rel | boolean | no | Read x/y/z as an offset from the client instead of world coordinates. |
player | player name | for player | Walks to where that player currently stands. |
timeoutMs | integer, 1000–600000 | no | Default 60000. Fail the step if the client has not arrived after this long. The editor takes a number plus a unit. |
mode: player walks once to where they stood. To keep up as they move, use
follow.
The step fails, and the console says why, when:
- there is no path to the destination,
- the client is stuck: 5 seconds without moving at all, or 30 seconds without getting half a block closer,
timeoutMsruns out first,- something else stops it on the way, such as
stop_moving.
goto_block
Pathfinds to the nearest block of a given kind and stops next to it. goto needs
coordinates; a farm loop rarely knows them.
| Field | Type | Required | Notes |
|---|---|---|---|
block | string, 1–64 chars | yes | Registry name, e.g. chest. |
radius | integer, 1–64 | no | Default 16. How far to search. |
Fails when there is no such block within radius, and in the same cases as goto, with a
limit of 60 seconds.
follow
Keeps walking to a player, re-pathing as they move.
| Field | Type | Required | Notes |
|---|---|---|---|
on | boolean | no | Default true. false drops the follow goal. |
player | player name | to start | Who to follow. |
distance | integer, 1–16 | no | Default 3. How close to stay. |
Following continues in the background after the block finishes. To stop it, use another follow block with its first field set to off:
or stop moving, which also clears everything else.
stop_moving
Cancels any path in flight and releases every control state.
No fields.
The only way to interrupt a running goto or follow, or to clear a sneak or sprint
that got stuck on.
A running goal is paused, not ended: it resumes after the next movement or goal step. To
end it, use cancel_goal.
mount
Rides a vehicle: boat, minecart, horse, strider.
| Field | Type | Required | Notes |
|---|---|---|---|
mode | nearest | named | no | Default nearest. |
target | entity name | for named | The entity's name. |
radius | integer, 1–32 | no | Default 8. Search radius for nearest. |
Fails when there is nothing to ride within radius, or when the server has not seated the
client a second later. A pig or a horse needs a saddle, and a horse has to be tamed.
dismount
Leaves the current vehicle by sneaking, like a player does.
No fields.
Fails when the client is still riding a second later. With nothing to ride it does nothing.
attack
Hits something. One swing by default, or walks to the target and fights until it is dead.
| Field | Type | Required | Notes |
|---|---|---|---|
mode | nearest | named | hostile | attacker | mob | no | Default nearest. hostile is the nearest hostile mob; neutral mobs such as endermen, piglins and zombified piglins are left alone. attacker is whatever hit the client in the last 10 seconds, mob or player, if it is within radius. mob is the nearest living mob of any kind, hostile, neutral or passive. |
target | entity name | for named | A player or mob name. |
exclude | array of entity names, max 16 | no | Never target these, for example villager and iron_golem. |
chase | boolean | no | Default off. Walk to the target and keep fighting it until it is dead or gone. |
radius | integer, 1–32 | no | Default 16. Only pick a target this close. With chase, give up when it gets further than 1.5 times this, or when the client is more than 32 blocks from where the chase started. |
timeoutMs | integer, 1000–120000 | no | Default 30000. chase only: fail the step if the client has not landed a hit for this long. Every hit starts the count again, so a long fight that keeps landing hits goes on. The editor takes a number plus a unit. |
spread | boolean | no | Default off. chase only: share the targets out across the group instead of all going for the nearest one. |
Every swing, with or without chase, is one a player could land. Only living things are
ever targeted, never a dropped item, an arrow or an armour stand. The client turns its head at
a human pace and swings only when it faces the target (within 15 degrees), the target is
within 3 blocks and nothing solid is between its eyes and the target. Swings follow the pace
of the weapon in its hand, a little under a second for an axe and about two thirds of a second
for a sword or an empty hand, with a small random wobble so ten clients do not swing in step.
A plain attack asked for before the weapon is ready waits for it, up to a second, instead of
swinging early. Out of reach or out of sight it does nothing for that swing. That is not a
failure, so a plain attack aimed at something too far away is quietly skipped. Plain
attack is one swing per action; for sustained combat without chase, put it in a
repeat or a
while.
With chase the client picks one target when the step starts and fights it like a player:
- It walks after the target (sprinting when it can) until it is within swing reach, then stands and fights.
- When something else hits it, or a hostile mob gets within 2.5 blocks, while the target is
out of reach, it turns and fights that mob first. Once that mob is more than 6 blocks away,
it goes back to the target. When it kills that mob and the mob fits the chase (any hostile
mob for
hostile), the chase ends there as a kill, so every kill is counted once. - With two or more hostile mobs within 3 blocks, it steps 2 blocks away from them after each hit, so the knockback keeps them off, then goes back in.
- Against heavy mobs that shrug off knockback (ravager, warden, iron golem, hoglin, zoglin, piglin brute, elder guardian) it hits and runs: it goes in only when its weapon is ready, swings once and sprints back to 8 blocks, going in again once the weapon is ready and the mob is 8 blocks off, within reach, or 2.5 seconds have passed. Below half health it stops fighting a heavy mob and backs away until it is 12 blocks clear; the step then fails with "backed away from ravager with health below half". Players are never fought this way.
- It backs off from a creeper whose fuse is lit and goes back in once the fuse is out.
- It stays within 32 blocks of where the chase started. A mob that hits and runs cannot drag the client, or a whole group, across the map: past 32 blocks the chase gives up as lost.
A chase only picks living things, and mob also skips tamed animals and anything with a
custom name, because that is someone's pet.
With spread, each client picks the nearest target that is not already covered. A mob with
up to 20 health needs one fighter, and every further 20 health asks for one more, up to four:
an iron golem gets four clients, a zombie gets one. Clients that CubeMind runs side by side
share a list of who is chasing what, so they never pick the same zombie, even when they start
from the same spot. Any other player, which can include one of your clients that CubeMind runs
elsewhere, covers a target when it is closer to it than this client is. If every
target is covered, the client goes for the nearest one anyway. A stranger standing next to a
zombie makes your clients leave it to them.
Fighting in a group, list your other clients in exclude. A sword's sweep can hit a client
standing next to the target, and with attacker the client that was hit would otherwise turn
on the one that hit it.
A chase succeeds only on a kill. When several of your clients that CubeMind runs side by
side fight one mob, the kill goes to the client that landed the last hit before it died, and
to no other. Otherwise the kill counts when this client hit the target in the last 5 seconds
before it died. When someone else lands the killing blow, or the sun or lava finishes it, the
step fails quietly, without a warning in the console. The target despawning, getting too far
away, the client getting more than 32 blocks from where it started or timeoutMs passing
without a hit also fail the step, and so does
having no target at all when it starts. That makes a kill counter a two-block job: right after the chase, check
last_action_failed and add
inc_var only when it is not set. Inside a
try a failed chase also stops the body, so a step
after it in the body runs only after a kill.
A chase is a mover: only one of attack with chase, flee, collect_items and sleep
(while it walks to the bed) runs per client at a time. Starting one ends the older one,
which finishes as done, not failed, and the newest wins. A second chase on the target the
client is already chasing does not restart anything; it waits for the running chase and
reports the same result. stop_moving also
ends a running mover, and fails a running chase, since it did not kill.
Known limits:
- Before game version 1.20 the server does not say who hurt the client.
attackerfalls back to the nearest mob or player within 5 blocks at that moment, and arrows from a skeleton stay unknown on those versions, soattackerfinds nothing for them. - This is melee only. No bows, shield blocking, critical-hit jumps or strafing.
flee
Runs away from danger until it is far enough.
| Field | Type | Required | Notes |
|---|---|---|---|
mode | hostile | attacker | no | Default hostile: the nearest hostile mob. attacker runs from whatever hit the client last. |
distance | integer, 4–32 | no | Default 12. Done once the threat is at least this far away. |
timeoutMs | integer, 1000–60000 | no | Default 15000. Fail the step if the client is still not clear after this long. |
strikeBack | boolean | no | Default on. While running, swing at a hostile mob within reach whenever the weapon is ready, then keep running. Turn it off for a pure retreat. |
The client pathfinds away, sprinting when it can (the game stops sprinting at 6 food or
less, so it just runs slower then), and checks again for the nearest threat as it goes, so
a second mob in the way is accounted for. With strikeBack on, a hostile mob that is already
within reach and in front, or any hostile mob within 2.5 blocks even behind the client, gets a
swing first: the client stops for at most half a second to turn and hit it, with the same
face, reach and sight rules as attack, then runs on. A swing that does not land waits 2
seconds before the next try. That way it does not
turn its back on a mob as fast as it is. With nothing to run from, the step is done at once
and counts as a success.
flee is a mover; see attack for the one-mover
rule. If a trigger can start both a flee and a chase, set a variable first and check it in
the fight loop, then call
stop_moving. The fight loop reference flow
below does exactly that, and the order matters.
collect_items
Walks over dropped items to pick them up.
| Field | Type | Required | Notes |
|---|---|---|---|
radius | integer, 1–16 | no | Default 8. Pick up dropped items this close. |
item | string, 1–64 chars | no | Only this item. Leave out for anything. |
matchBy | name | display_name | lore | no | Default name. |
timeoutMs | integer, 1000–60000 | no | Default 15000. Stop after this long. |
Goes to the nearest item first, then the next, until none are left or the time is up. Both
count as success. It fails when the inventory is full while items are still lying there, when
an item it walked onto was never picked up three times in a row, which usually means it cannot
be reached, or when the client gets stuck on the way, as in
goto. It is a mover.
sneak
Holds or releases sneak.
| Field | Type | Required | Notes |
|---|---|---|---|
on | boolean | yes | true holds it down, false releases. |
It stays held until something turns it off: this action with on: false, or
stop_moving.
sprint
Holds or releases sprint.
| Field | Type | Required | Notes |
|---|---|---|---|
on | boolean | yes | true holds it down, false releases. |
activate_item
Uses the held item (right-click, in effect). Eating, drinking, throwing, activating.
No fields.
Example: a fight loop
A client that fights mobs like a player: hits back at whatever hit it first, otherwise takes the nearest mob, counts kills, picks up drops and wears better gear, and runs away to heal when its health gets low, eating back up so it heals. It is built from the blocks above, not one built-in fight block.
Five things make it work.
set statecomes beforestop_moving. The fight loop checksstateat the top of each pass. Stop first and it can start a new chase in the gap before the flag changes.- Every step after the first chase checks
stateagain.stop_movingends the chase as a failure, so the loop lands inelse on failurewhile the client is already running away. An unchecked fallback chase or pick-up would start a new move and cancel the run away, since the newest move wins. Checked, the pass ends quietly and the loop waits untilstateisfightagain. - Count only after a clean chase. A chase only succeeds on a kill. When the fallback
chase fails too, the inner
tryfails, which stops the outer body before the count and the pick-up, and the outertrywaits and picks the next target. Thenot last action failedtest keeps the count honest if you take the innertryout. - Heal by eating, and keep the potion for real danger. Health only comes back by itself
while food is 18 or more, so after running away the client eats until
food above 17and then waits for its health. The healing potion is drunk only below half health (10); above that, food is enough. Without food the loop stops at the first failedeatinstead of trying ten times. - The damage trigger hits back when no mob is around, which is how a player attacker gets answered. Mobs are handled by the fight loop.