Conditional command – What is it ?

09/09/2021 | 1min

Conditional commands evaluate the test as passed or failed. They are mostly used to determine flow through if/unless/while loops.


/execute if <conditions> run <command if succes>
/execute unless <conditions> run <command if succes>

/execute executes another command but allows changing the executor, changing the position and angle it is executed at, adding preconditions, and storing its result. wiki

blueprint wireless step 1

With command block, the success test is stored in the command block(nbt tag), check a command block for success or read with a redstone comparator.

If condition is success, the lamp is activated.

blueprint chain command block condition

Or create a chain command block and set it to "conditional" (3) so that it only executes if the previous command block executed.

Check if a cow.

/execute if entity @e[type=cow,distance=..5] run say success

Check if the block is a dirt. Run command if success.

/execute if block ~ ~1 ~ minecraft:dirt run say success test

Check if the block contains a opened book on page 1.

/execute if block ~ ~1 ~ minecraft:lectern[has_book=true]{Page:1} run say Page 1

blueprint chain command block condition