Docs menu

Survival and reflexes

Staying alive is handled by reflexes: small pieces of code that watch for one danger each and take over the bot's body the moment it shows up. The AI model plays no part in them.

Reflexes don't cancel the job

A reflex takes the legs and the hands. The job the bot was doing isn't thrown away: it waits at its next move and carries on when the reflex lets go. A walk that was cut off is walked again.

So a zombie in the tunnel costs a few seconds, not the mining trip. status shows the job as paused while a reflex has the body.

Saying stop also ends a fight and keeps the fighting reflexes quiet for a minute. Air, lava and being buried are never switched off.

The reflexes

DangerWhen it startsWhat the bot does
CreeperOne in sight within 9 blocks by day, 16 at night.With a sword or an axe it walks up, hits and steps back after each hit. It runs instead when it has no weapon, when its health is under half, or when the creeper is hissing right beside it.
No airUnder water with about 9 seconds of air left.Finds a way to the surface and swims up, or sideways from under a ceiling. With no way out it digs through the block overhead. After coming up twice in a short time it swims for dry land.
LavaThe moment it touches lava.Heads for the nearest ground with no lava beside it. Still burning, it goes to water, or pours its own water bucket at its feet.
BuriedIts head is inside gravel, sand, dirt or stone.Digs the block out at once.
AttackedA hostile mob within 3.5 blocks by day or 8 at night, anything close after it was hurt, or an archer in sight.Fights back with its best sword or axe.

Fighting

  • It fights the game's hostile mobs, hand to hand. It has no bow.
  • It leaves neutral mobs alone unless they hurt it: endermen, piglins, zombified piglins, wolves, bees, iron golems and the like. Spiders in daylight are left alone too.
  • It only goes for mobs that can reach it. Shut in its shelter, it ignores what's outside.
  • It doesn't chase flying mobs. One that comes within reach gets a swing.
  • A fight ends when the mob is dead, has run 14 blocks off or is out of sight. A mob it can't get to in 30 seconds is left alone for a minute.
  • Losing, it backs off. At 4 hearts or less it runs 16 blocks from the mobs and tells you so. It comes back to fight at 7 hearts, or when it's cornered.

Food

It eats when its hunger bar is at 14 of 20 or lower, or when its health is at half or lower. It picks the most filling food it carries.

  • It eats between two moves of its job. Starving or badly hurt, it stops and eats at once.
  • Rotten flesh is eaten only with nothing better on it. Poisonous food only when it's starving.
  • Raw meat doesn't count as food. It cooks it first: on a campfire, in a smoker or in a furnace.

When its food runs low it restocks by day. Where it looks, in order:

  1. Furnaces it left cooking, and its chests.
  2. Raw meat it carries, cooked.
  3. Its fields: ripe crops, and bread from the wheat.
  4. Berries, melons and mushrooms nearby.
  5. Hunting: cows, pigs, sheep, chickens and rabbits. Never babies or named animals.
  6. Fishing from a shore, once it has a rod or string for one.

Starving comes before everything but the reflexes, your orders included. It tells you it's getting food first.

It won't go down its mine with too little food on it.

Armor and tools

  • Every few seconds it puts on any armor it carries that's better than what it wears.
  • It makes leather armor for empty slots from the leather its hunts bring in.
  • After its first iron pickaxe it makes an iron sword, a shield, a water bucket and iron armor, piece by piece. Diamond gear comes later.
  • It keeps spare pickaxes for a mine trip and replaces a broken pickaxe or sword at home.
  • Standing idle, it holds its best weapon.

Health

Eating is the only way it heals. Low health holds it back:

  • Under 6 hearts it won't go down the mine. Under 5 hearts down there, it climbs out and tells you.
  • At 4 hearts or less it backs off from a fight. Under 5 it runs from creepers instead of hitting them.

Waiting to heal or to eat is written in its diary as a wait, never as a failure. See The day planner.

The night

The bot works on after sunset. The night routine starts when a mob hurts it after dark.

  1. It mends its shelter, or digs one if it has none, and runs home.
  2. It shuts itself in.
  3. Inside it puts things away, cooks, smelts iron and makes armor.
  4. Work in the mine goes on: the way down is inside the shelter. With nothing to do there, it sleeps in its bed.

This is part of its own life, so it doesn't happen while its own life is off. See Home and buildings for the shelter itself.

After a death

It remembers where it died and how much it was carrying, even across a restart. When it comes back to life it goes for its things without being asked:

  1. It takes a sword, a pickaxe, a shield and food from its chests, or makes the tools it's missing.
  2. It walks back to the place. If it died in its mine it goes down through the mine; if it has to, it digs down.
  3. It picks up what's lying there and tells you what it got back.

It tries a few times. If it can't reach the place it says so and keeps the place in mind for later. If nothing is left, it tells you the things may have burned or despawned.

Getting unstuck

A job that makes no progress is noticed. Progress means the bot moved or its bag changed.

  • After 45 seconds it jumps and sidesteps.
  • After 45 more it looks for another route.
  • After 45 more it gives the job up, tells you, and keeps away from that spot for 10 minutes.

Waits it means to make, like standing at a furnace, don't count.

What it tells you

Most reflexes say nothing: a creeper dealt with isn't news. It speaks up when it backs off badly hurt, when it's starving, when it leaves the mine hurt, when it gives up a job as stuck, and all the way through getting its things back after a death.

The numbers on this page are the ones in the bot's code, in src/actions. Health is counted in hearts here: a heart is 2 points of the game's 20.