Will this command block always teleport the correct player(s)?
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
Solution 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
Solution 2:
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.