2

I want to use the below command:

/execute if entity @p[x=-1856.5,y=122.0,z=-133.5,distance=..3.5] run tp @p ~-4 ~1 ~

but using relative coordinates to the command block instead of these specific ones.
Is that possible?

Edit: Also, could I compress various relative coordinates into one single command block?
What I mean is, for example (I'm not sure if the syntax is correct):

/execute if entity @p[x=~1,y=~1,z=~1] and [x=~2,y=~2,z=~2] run tp @p ~-4 ~1 ~

1
  • What should your "and" do? Commented Jul 26, 2019 at 9:09

1 Answer 1

2

What you want is /execute positioned:

/execute positioned ~ ~ ~10 if entity @e[distance=..3] run <command>

This runs the command if there's an entity within a 3 block radius circle around a position 10 blocks into positive Z direction from you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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