1

Does that teleport the player closest to the command block or the player closet to the coordinates in the execute portion?

May goal is to teleport anyone that steps in a specific block, but I want to make sure I'm doing it right

/execute @a[x=112,y=34,z=14,r=1] ~ ~ ~ tp @p 90 29 8
3
  • 2
    Err, try running it?
    – ave
    Commented Aug 14, 2017 at 1:51
  • Works great when I run it, but I'm the only player....so I'm always the closest player to both blocks, so running it doesn't really help me here :\
    – Trel
    Commented Aug 14, 2017 at 2:10
  • Try running it in mltiplayer. Make sure there is another player there.
    – user194390
    Commented Aug 14, 2017 at 3:33

2 Answers 2

1

You should skip the execute command and use the target selector with arguments in the tp command:

/tp @a[x=112,y=34,z=14,r=1] 90 29 8

If you want to use the execute command for some reason, use the @s target selector in the tp portion of the command. This selects the entity which executed the command. This would be the same entity the execute command targeted within the coordinates:

/execute @a[x=112,y=34,z=14,r=1] ~ ~ ~ tp @s 90 29 8
4
  • Thanks. I think I'll switch mine over to this, since it guarantees it affects the right people unambiguously.
    – Trel
    Commented Aug 14, 2017 at 3:57
  • Question for you, you mention 2 command blocks. What is the 2nd for? Is that 2 per teleport station for a testfor block as the first?
    – IronAnvil
    Commented Aug 14, 2017 at 4:08
  • Sorry, I think I was probably ambiguous. There's one command block. The two blocks are the command block and the block they step into to be teleported. I was asking when using the /tp @p method, if the proximity was in proximity to the block used in the execute portion, or to the command block itself. Once you pointed out to just use @a again, that part of my question became irrelevant.
    – Trel
    Commented Aug 14, 2017 at 16:12
  • Because your adding the selectors to the /tp the /execute part is unnecessary, also if I remember correctly r=1 will have a 3x3 around the center as such r=0 would be more accurate, if the coordinates is the location the player will stand, not the block they will stand on
    – Venya
    Commented Aug 14, 2017 at 22:01
1

Yes, it does target the player standing on the block.

However, in the extremely unlikely case that two players stand on exactly the same coordinates, it could have issues where one player targets the other player and therefore he himself is not teleported. If you don't turn off the command block the next tick or do something else that prevents it, that's not a big issue, he would just be teleported the next tick, because then he's the only player left there.

But if you want to be completely sure that you always target everyone instantly, you can replace the @p in your command with @s, which always targets the command executor.

Or in your specific case, you could also just replace the whole command with

/tp @a[x=112,y=34,z=14,r=1] 90 29 8

That has the exact same effect.

And if you want to test something with @p in the future, you can just use @e[c=1], this does the same as @p, but with all entities. Then you can just put a bunch of sheep everywhere to test. You could also use items, but sheep are cuter.

4
  • Also: In 1.13 you will be able to use @a[x=112,y=34,z=14,dx=1,dy=1,dz=1] to target exactly everyone on that block, because there will be no more centering on the block. You could then even use dy=0.1 for players on the ground, because it will allow non-integers. Currently it doesn't. Commented Aug 14, 2017 at 6:17
  • that sounds useful, is the dx, dy, dz, part documented o the wiki? I'm guessing from context, that it's either an offset "distance" or shape, "diameter" but I'm not certain just by reading it.
    – Trel
    Commented Aug 14, 2017 at 16:14
  • Yes, it's in the wiki: minecraft.gamepedia.com/Commands#Target_selectors It's the size of a selection box. Commented Aug 14, 2017 at 17:19
  • Archive: minecraft.gamepedia.com/… Commented Apr 30, 2018 at 12:38

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.