What am I doing wrong: /execute if entity @p positioned 0 20 0 run say Minecraft
Solution 1:
What's the error?
You thought the command would say, "If there is a player positioned at 0 20 0, say Minecraft."
However, it actually says, "Locate the nearest player; if one is found, make the command execute positioned at 0 20 0: say Minecraft"
How to fix it?
/execute positioned 0 20 0 if entity @p[distance=..1] run say Minecraft
This command says "Execute this command positioned at 0 20 0: locate the nearest player within 1 block radius of the command's execution position; if one is found, say Minecraft".
Solution 2:
There is an easier way to do this using selectors:
/execute as @p[x=0.5,y=20.5,z=0.5,distance=..1] run say Minecraft
(The x=
, y=
, and z=
aren't strictly necessary.)
Conversely, you could also specify the volume of the search space like so:
/execute as @p[x=0,y=20,z=0,dx=1,dy=1,dz=1] run say Minecraft