Test if entity is above a certain block independent from height, relative execution

I'm trying to make armor stands run a command if they detect that no snow is anywhere below them. The armor stands are high up in the air with NoGravity.

I tried the execute if blocks; but that seems to not work for 1*y*1 ?

execute at @e[type=Armorstand] if blocks ~ ~-100 ~ ~ ~ ~ 40 50 40 masked run say found_snow

40/50/40 is supposed to be the reference block (snow)


What you tried compares the 1×101×1 area that you entered with the 1×101×1 are starting at the last set of coordinates.
Armorstand is also not the correct ID, it's armor_stand.


Probably the only way to do what you want, except for checking every block separately, e.g. in a loop, is to first clone it somewhere else (I'll choose 0 0 0 as an example here):

/execute at @e[type=armor_stand] run clone ~ 0 ~ ~ ~ ~ 0 0 0

… and then fill all snow blocks in there with something else, storing the return value (which will be the number of filled blocks) in a scoreboard:

/execute as @e[type=armor_stand] at @s store result score @s scoreboard_name run fill 0 0 0 0 ~ 0 air replace snow_block

Now you have the number of snow blocks in that column in the scoreboard "scoreboard_name" for the armour stand. You can use the value, for example with /execute if score <selector> <score> matches 0 run <command>.

You can of course also delete the area again or just let it be overwritten the next time.


If the reference block can be variable, you need to actually check each block one by one. I recommend starting at y=0 and going upwards with a recursive function until you arrive at the armour stand, that way you don't need yet another dummy armour stand and you can still do it for as many armour stands at once as you want. In this case you would actually use /execute if blocks, but you would compare a 1×1×1 area with a 1×1×1 area every time.