Guide menu ▾

Macros

If / Else: condition blocks

Build If / Else (condition) blocks in a macro: condition types, nested conditions, adding steps to branches and dragging steps around.

Last updated: November 26, 2026

The Condition step adds "if this, do that, otherwise do something else" logic to a macro. Under a Condition step there are two blocks: ✓ If the condition holds and ✗ Else. If the condition holds, the steps in the first block run; otherwise the steps in the Else block run. Whichever runs, the macro then carries on with the steps below the condition. If one block is empty, the macro simply continues in that case.

  1. 1Add a Condition step with + Add step and pick what to check in the Check this list (e.g. Health, Less than, 10).
  2. 2Use + Add step (if it holds) to add what happens when the condition holds (e.g. Hold item: golden_apple, Right click: use item).
  3. 3Use + Add step (else) to add what happens when it does not hold, or leave it empty.
  4. 4If you like, add another condition inside the blocks to nest checks.
The Condition step in the macro editor: the Condition met and Otherwise blocks, with the Check, State and Value fields
The Condition step in the macro editor: the Condition met and Otherwise blocks, with the Check, State and Value fields

Condition types

The Check this list has nine condition types. For numbers the Status is Less than, Greater than or Equals; for text it is Contains or Equals.

CheckWhat it looks atValue
MessageThe chat message that triggered the macroText
Player nameThe player that triggered the macroText
DimensionThe dimension the bot is inoverworld, the_nether, the_end
Health, HungerThe bot's health or hungerNumber
Chance (%)Random; holds with the given percentage0-100
CounterThe counter named in Counter nameNumber
Is a block nearby? (3.5 only)A block within the radiusBlock name
Villager trade result (3.5 only)How the last trade step endedTrade status

The "Is a block nearby?" condition

This condition checks whether a block is around the bot. Enter a block name or wildcard (e.g. spawner, *_ore) in Block name and a number from 1 to 8 in Radius (blocks). The condition holds when the block is within the radius. It only works on the 3.5 bot engine.

The "Villager trade result" condition

This condition looks at why the last Villager trade step with the same variable ended: Trade done, Trade menu closed, Trade not found, Trade locked, Missing materials, Inventory full or The server gave no trade. Details: Craft and villager trading.

Nested conditions and the end of a branch

You can put another condition inside a condition block; the inner condition gets its own ✓ If the condition holds and ✗ Else blocks. The Loop back, Turn off bot and Leave the game (without rejoining) steps end the flow, so they can only be the last step of a block or of the flow. If that block runs, the macro loops back, shuts down or leaves; if the other block runs, the macro goes on.

Example: eat a golden apple when health is low

OrderStepSetting
1TriggerWhen damaged
2ConditionHealth, Less than, 10
2.1✓ If the condition holds: Hold itemgolden_apple; If no item: Skip and continue
2.2✓ If the condition holds: Right click: use itemHold time 1700 ms

Moving steps by dragging

Hold the ⋮⋮ (Drag to move) handle on the left of a step and drag it; drop it when the line between steps lights up. You can move steps into or out of condition blocks, and a condition takes its steps with it. The trigger always stays at the top. The ↑ and ↓ buttons of the selected step move it one place; ⧉ (Duplicate step) copies it and Delete removes it.

Frequently asked questions

How do I add an If / Else block?

In the **Add step** window pick **Condition** from the **Flow** group. The added condition shows **✓ If the condition holds** and **✗ Else** blocks under it; you add steps to each one separately.

Does the macro stop when the condition does not hold?

No. The steps in the Else block run, and if the block is empty the macro continues with the steps below. To stop the macro, put an ending step such as Turn off bot into the Else block.

Can I nest conditions?

Yes. Add a new Condition inside a block with **+ Add step**. All steps still count towards the single macro limit.

How do I move a step into another block?

Drag the step by its **⋮⋮** handle and drop it on the line inside the target block. If you move a condition its steps come along.

If / Else: condition blocks — AFKBot