Minecraft – Put an execute command inside another execute command

minecraft-commandsminecraft-java-edition

Is it possible to put a "double conditional" in a command block (two execute commands in the same command), like so:

/execute foo run execute bar run command

Is this possible?

Best Answer

Yes, it is possible. In fact, a /execute command with multiple parameters remains functionally the same if you add the words run execute in between each parameter.

For example, these two are equivalent:

/execute as @p at @s if entity @p[distance=..10] run say Hi!
/execute as @p run execute at @s run execute if entity @p[distance=..10] run say Hi!

Therefore, there is no need to place multiple /execute commands within each other. It remains the same putting all the parameters in one command.

For your double conditional, all you need to do is include multiple if/unless parameters:

/execute if entity @p[tag=tagA] if entity @p[tag=tagB] run say hello worl