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.

2 Answers 2


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


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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .