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.


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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.