0

I'm creating an RPG map and I need a command block to detect if a player is near specific coordinates, but I cannot work with specific numbers, I need it to be relative to the command block position. For example, in this command that does not work:

/execute at block ~3 ~2 ~-1 run execute if entity @p[team=Player01,distance=..5]

The current command I'm using is this one:

/execute if entity @a[team=Player01,distance=..5]

I've already searched about execute relative to command block but it´s the opposite scenario. I need the detection to be relative to the command block.

  • What is your actual problem? If you can detect players being nearby, you can also do anything to players nearby. What does not work about your first command? And what do you actually want to do? The two commands you listed don't perform any action. – Fabian Röling Oct 30 '19 at 0:13
  • the problem is that with sphere radius the corners don´t detect the player and i do not know how to use square radius – D3T0NA Oct 30 '19 at 0:33
  • i need the detection área to be a cube – D3T0NA Oct 30 '19 at 0:34
  • So it's the exact same thing as your other question? – Fabian Röling Oct 30 '19 at 12:16
  • The only way yo make it a cube is using one command block for each block and instead of using comparators, you should learn a little bit more about /tag and @e[tag="name"] selector. – Bruno Rodrigues Oct 30 '19 at 14:52
2

The only thing you are missing is the positioned part. It will work from a certain position and it can be an entity, coordinate or relative coordinate.

Thus, it will look like this:

/execute positioned ~ ~ ~ run execute as @a[team=Player01,distance=..1] run [Rest of the command here]

Simply change "~ ~ ~" to your desired relative coordinates.

Altough, it will work in a radius of 1 since using 0 here will anulate the effect (or make it waaaay specific becoming useless), for some reason.

| improve this answer | |
  • it´s not working i don´t know why – D3T0NA Oct 29 '19 at 22:20
  • Are you sure that the command is a repeater and set to always active? – Bruno Rodrigues Oct 29 '19 at 22:21
  • /execute positioned ~-1 ~2 ~1 run execute as @a[team=Player01,distance=..5] run is what im using in this specific command – D3T0NA Oct 29 '19 at 22:21
  • yes i´m sure it´s on repeat and Always active – D3T0NA Oct 29 '19 at 22:22
  • 1
    Change it to /execute positioned ~-1 ~2 ~1 run execute if entity @a[team=Player01,distance=..5] – Bruno Rodrigues Oct 29 '19 at 22:29

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.