Using the command: execute if entity @p[x=21 ,y=56 ,z=-132 ,distance=..4.5] works but won't work if I use relative coordinates. e.g. command:execute if entity @p[x=~ ,y=~ ,z=~ ,distance=..4.5] I need a way to detect the player with relative coordinates from the block executing the command. I tried using dx=/dy=/dz=it does seem to work partially but I can't figure out the right parameters to use in @p[ ] please help.

1 Answer 1


You almost had it, /execute is the solution, but with positioned:

/execute positioned ~1 ~2 ~3 if entity @p[distance=..4.5] run …

You must log in to answer this question.

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