Minecraft – OR operator in executing commands? (Java 1.14)

minecraft-commandsminecraft-java-edition

I have been running into roadblocks at the moment with the use of executing if and unless statements, not only that but also in using tags.

for example here I have a command block running through a few tags and I need it to cover 2 tags "crafting_block2" and "crafting_block1"
except it treats it more like a & operator if I use it like below.

/execute as @e[type=minecraft:armor_stand,tag=crafting_block] align xyz positioned ~0.5 ~0 ~0.5 unless entity @e[type=minecraft:villager,tag=crafting_block2,tag=crafting_block1] at @s run kill @s

So it would only execute if the armor stand has both of the tags, but I want it to execute when it has either of the tags.

I know I could apply another tag from the start to cover it all but is there a way to do this without the additional tag (and without the use of scoreboards). if there is a OR operator or something like that, that would be nice.

As well on top of that, I also want to know about a similar thing

execute as @e[type=minecraft:armor_stand,tag=Landmine] at @s align xyz positioned ~0.5 ~ ~0.5 if block ~ ~ ~ air run tp @s ~ ~-1 ~

for example here, I couldn't quite get it to work on both cave air and normal air. Like as I said above if I tried to put another if statement in it treats it as if there if an AND operator and would only work if both are true (which is impossible in this case). In the end, I had to duplicate the entire command to compensate for this which is ridiculous.

Best Answer

Duplicating commands is a common thing, because there is no "OR" in commands.

In your first case you might be able to do something like "as @e[type=villager] unless entity @s[tag=block1] unless entity @s[tag=block2]" or other fancy tricks, but if that doesn't work in your case, then yes, you might need to use another tag. You can also do very fancy things, like custom predicates (in 1.15), but that's not worth it for such a small example.

Another thing that is also called "tag" (not to be confused with NBT tags, the tags that were formerly a part of the scoreboard command, name tags, the "tag" NBT tag of items or the German word for "day") can help for your second case. If you create a block tag (archive) with the name air and then check for "#air" instead of "air", you can match all blocks in that tag at once. Don't forget the namespace if your datapacks uses a different one than minecraft.