I’m looking for a way to execute a command if an entity is within a certain area of another one. More specifically, I want to know when a player is anywhere along an armour stands y axis to create a command run barrier around a watery area, I can’t use barrier blocks because it takes longer, and creates an annoying air pocket where there shouldn’t be one.
One way I found to do this was
/execute positioned ~ ~20 ~ run execute if entity @e[distance=..1]
But this would create a 1x1x1 sphere you need to be in to make the condition true, and I want it to be a 1x256x1 sphere.
So once more, I am asking is there a way to have an execute if entity command along one coordinate, in my case the Y coordinate?
Here is a command that would work for what I need, the problem is that I would have to run a separate command for every 2 blocks.
/execute if entity @e[x=20, z=30, distance=..2] run say You’re on my y axis!