Minecraft – What am I doing wrong: /execute if entity @p positioned 0 20 0 run say Minecraft

minecraft-java-edition

So, the command block should say 'Minecraft' only if a player stands at 'xyz: 0 20 0'. But it does so no matter where I stand. Could somebody tell me what I did wrong and fix this command please?

/execute if entity @p positioned 0 20 0 run say Minecraft

I'm playing on a single player creative world on Minecraft Java Edition 1.16.3.

Best Answer

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".