Minecraft – How to detect any block around an entity using the /execute command in Minecraft

minecraft-commandsminecraft-java-edition

I'm trying to create an RPG launcher kind of device to make a tutorial on for my YouTube channel. I am using crossbows and firework rockets and so far I have succeeded in having the firework rocket explode when flying above grass blocks. Is there any way to detect when the rocket flies into any block, rather than a particular block / category?

Best Answer

Try the following:

/execute unless block X Y Z minecraft:air run SOMETHING...

Theoretically this should work, as minecraft:air is a block type, and should be detectable using the /execute command.