1

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.

2

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.

  • What's the difference between air and #air? I don't get what is "cave air" nor "void air", how are they different from a normal air block? – Bruno Rodrigues Nov 21 at 17:14
  • 1
    "#air" is a block tag that includes all air variants, just like "#logs" is a block tag that includes oak_log, spruce_log, dark_oak_log, acacia_log, jungle_log and birch_log, so that you don't have to write the same command three or six times with each of those blocks. "cave air" gets generated instead of normal air in caves, otherwise it is identical. But if you for example replace all regular air with something, that would not work inside caves. "void air" is internally used by the game for something, but doesn't normally occur anywhere.If you set it manually, #air matches it. – Fabian Röling Nov 21 at 19:08
  • Hey Fabian but one of the reasons why I posted these examples to this question is because I can't find the tag for air variants #air. Is this newly added tag in a snapshot? – Joe Nov 27 at 12:25
  • That's weird, the wiki also doesn't list it. I thought I had seen it before. I'll ask around a bit. – Fabian Röling Nov 27 at 13:48
  • Apparently it does not exist, that is weird. I updated my answer accordingly. – Fabian Röling Nov 27 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.