Goal actions
Give a client a goal, such as making an item from the base chests or keeping a crop field harvested, and let it work out the steps.
A goal is a step that plans its own work. Instead of scripting every chest, furnace and crafting click, you say what you want and the client works out the rest from what it holds and what your base holds.
Rules shared by every goal.
- Goals need game version 1.13 or newer. On older servers the step fails at once.
- A goal is an ordinary step: when it cannot finish it fails, so try and the last_action_failed condition see it.
- Your survival triggers come first. When a fight, a flee or a pickup moves the client, the goal waits until nothing else is moving it and carries on where it was. After 20 such interruptions it gives up.
- stop_moving pauses a goal until the next movement or goal step has run. cancel_goal ends it.
- Results land in client variables, the same way set_var
writes them. A list longer than 256 characters is cut with "… and N more", and its full
length is in the matching
_countvariable. Two goals running at the same time overwrite each other's results.
obtain
Makes an item from the inventory and the base chests: it plans the whole recipe chain, fetches the materials, smelts, crafts and, if you ask, stores the result.
| Field | Type | Required | Notes |
|---|---|---|---|
item | string, 1–64 chars | yes | What to end up with. A registry name matches exactly; other text matches the shortest item name containing it. |
count | integer, 1–2304 | no | Default 1. How many in the end: items already held count. |
chests | list of x y z, up to 16 | no | The chests materials may come from. Omitted: every chest, barrel or shulker box within 16 blocks. |
table | x y z | no | The crafting table to use. Omitted: the nearest within 16 blocks, else it makes and places one. |
furnace | x y z | no | The furnace to use. Omitted: the nearest within 16 blocks, else it makes and places one. |
deliver | x y z | no | A chest to store the result in, never a source of materials, both halves of a double chest included. Omitted: the result stays in the inventory. |
timeoutMs | integer, 10000–1800000 | no | Default 600000 (10 minutes). The step fails after this long. |
In the editor, coordinates are typed as x y z, and several chests are separated by ;.
How it works:
- Plan. It reads the recipes from the game data, including every wood type for planks
and sticks, and knows the furnace recipes and fuel values. It counts the inventory first,
then opens the chests one by one until the plan is covered. If anything is still missing it
stops before taking anything and fails with the exact list, for example
missing 3 raw_iron, 2 coal. - Gather. It takes exactly what the plan needs from the chests, nothing more.
- Make. It smelts first, loading only the fuel the smelt needs and waiting for the output, then crafts from the bottom up. Recipes that fit a 2×2 grid are crafted in the inventory. With no table or furnace nearby it crafts one and places it next to itself, inside 16 blocks of where it started, and only when the materials for it are there too.
- Deliver. With
deliverset, it putscountof the item in that chest.
Planks of different woods mix in one recipe, the way they do for a player, so two oak and two spruce planks still make a crafting table.
Results, as client variables:
| Variable | Set to |
|---|---|
{{obtain_done}} | How many it made this time. 0 when it failed. |
{{obtain_missing}} | What was missing, like 3 raw_iron, 2 coal. Empty on success. |
{{obtain_missing_count}} | How many different items were missing. |
{{obtain_reason}} | Why it failed. Empty on success. |
It fails when materials are missing, when it cannot reach a chest, table or furnace, when the server refuses to let it place a table or furnace (a protected area), when the inventory is full, when the timeout runs out, when a furnace stops smelting for 30 seconds (out of fuel), and when a goal is cancelled. If it had already taken materials, the message says what the inventory holds now and what it left in the furnace, so nothing goes missing silently.
farm
Makes one pass over a crop field: harvests the ripe crops, picks up what drops, replants every
empty farmland and, if you like, stores the harvest in a chest. Repeating it is the flow's job:
put it under a timer trigger.
| Field | Type | Required | Notes |
|---|---|---|---|
fromX, fromY, fromZ | integers | yes | One corner of the field. |
toX, toY, toZ | integers | yes | The opposite corner. The field is at most 64×64 blocks and 4 blocks tall. |
crop | wheat | carrots | potatoes | beetroots | no | Only this crop. Leave out for every crop in the field. |
deliverX, deliverY, deliverZ | integers | no | A chest, barrel or shulker box for the harvest. Leave out to keep it in the inventory. |
keepSeeds | integer, 0–256 | no | Default 16. Seeds, carrots and potatoes of each kind kept back for replanting when storing. |
The corners can be the farmland or the crops on it. What it does, row by row:
- Harvest. Breaks only ripe crops: wheat, carrots and potatoes at their last growth stage, beetroots at theirs. Unripe crops are left alone. It digs like a player, only what it can reach and see, and walks closer when needed.
- Pick up. Collects the crop drops on the field and up to 2 blocks around it, following drops that are still bouncing.
- Replant. Plants every empty farmland in the field with the matching seed (
wheat_seeds,carrot,potato,beetroot_seeds) from the inventory. Withoutcrop, a cell gets back what grew there; an empty cell gets the crop the field mostly holds. - Till. When the client carries a hoe, dirt and grass inside the field with air above and water within 4 blocks are tilled and planted too.
- Store. With a chest set, the crop items this pass picked up go in, except
keepSeedsof each seed kind. Food and seeds the client already carried, and other items, stay in the inventory.
While it works the client never drops down a block and never parkours, the moves that trample farmland. Mark a field whose rows it can walk along at one height.
Results land in client variables, like set_var:
| Variable | Holds |
|---|---|
{{farm_harvested}} | Crops harvested in this pass. |
{{farm_replanted}} | Cells planted in this pass. |
{{farm_stored}} | Items put in the chest. |
{{farm_left}} | Crop items still on the ground in and around the field after the pass, such as a drop it could not reach. These do not fail the step. |
{{farm_missing}} | The seeds that ran out, such as 12 wheat_seeds. Empty when nothing was missing. {{farm_missing_count}} counts the kinds. |
The step fails, so try and last_action_failed see it,
when seeds run out ("missing seeds for 12 cells"), when a crop or cell cannot be reached or
seen, when the server refuses a harvest or a planting (a protected area: after 5 refusals in a
row the pass stops), when the chest is missing or full, when the inventory fills up, when the
pass takes longer than 10 minutes, and on a field over the size limits. Everything it could do, it
still does first. Two goals running at once overwrite each other's results.
Other movement comes first. When a survival step such as
flee or a chasing
attack starts, the pass waits until nothing else
moves the client and then carries on where it was; after 20 such interruptions it fails.
stop_moving pauses it until the next movement
or goal step has run, and cancel_goal ends it.
Needs game version 1.13 or newer.