In Minecraft Java Edition 1.12 and under, the only way to run a command on a condition is to use /testfor
, /testforblock
, or /testforblocks
to test, and include a conditional chain command block which only executes if the test passes.
When creating a multi-command chain starting with any of the aforementioned commands, all the rest of the command blocks have to be conditional for them only to be executed when the /testfor
succeeds. If any of them are not conditional, they will execute even if the /testfor
fails.
The problem is, when a command block is conditional, all command blocks before that have had to execute their command and return a non-zero value. This not only includes the original /testfor
, but also every other step in the chain.
For example, let's say I have the following commands in order in a repeating command chain:
REPEATING, NONCONDITIONAL: /testfor @a[x=0, y=1, z=0, r=0.4]
CHAIN, CONDITIONAL: /setblock 0 0 0 air
CHAIN, CONDITIONAL: /say False Floor Trap!! LOL
This means that the message on screen will only be displayed if the testfor succeeds. All is well, until we add the fact that if the /testfor
succeeds but the /setblock
fails, the /say
still won't run.
But if we make it nonconditional, it will always run, even if the /testfor
fails.
What is the best way to make a conditional chain command block run if the /testfor
passes, but still run if a step in between fails?