How to group air void air and cave air

execute unless air ~ ~ ~ doesn't work when you're in the void or in a cave.

Is there something like #air that joins all air blocks together, like #wool?


Unfortunately, there doesn't seem to an #air tag available in vanilla Minecraft.

One possible workaround is to simply duplicate the condition:

execute unless block ~ ~ ~ minecraft:air unless block ~ ~ ~ minecraft:cave_air run <...>

Note that you do not need to explicitly test for void_air as of Minecraft 1.16, as execute unless block will always fail in the void.

In theory, it should also be possible to create a predicate in a datapack that tests for the relevant criteria.


You can add your own tags to blocks. If you know datapacks you can add your own tag in .minecraft/saves/(worldname)/datapacks/(datapackname)/data/(datapacksubname)/tags/blocks (stuff between brackets isn't specific text). You have to create a .json file named whatever you want the name of the tag to be. In the file you write the following:

{
 "values":[
  "air",
  "cave_air",
  "void_air"
 ]
}

That should do it, then you can use #(tagname) in game.

Even if you don't know datapacks, you can just follow the file order I gave you, for example: .minecraft/saves/(worldname)/datapacks/airgrouping/data/airgrouping/tags/blocks/air.json