I am trying to figure out how to seamlessly teleport the player while also rotating them, the problem is when just doing

execute as @a[x=-153,y=29,dy=2,z=-84] at @s rotated as @s run tp @s ~-37 ~10 ~1 ~180 ~

the x position won't be correct because it isn't being mirrored. The problem is that I don't know how to do that. I think it would be using score operations, but then I don't know the maths for it.

Consider the picture below:
If the player is up against the blue stained glass (the starting position) they are at x -151.3, and if they are up against the lime stained glass (the destination), x is -190.7.
I would need to reflect over the red stained glass (the center line) to make teleporting the player 180° with relative coordinates seamless. How would I go about doing that? (If I get what I need for the x axis, I should be able to apply it to the z axis myself).

Antichamber Many Paths To Nowhere Stairs in Minecraft from above with stained glass markers

  • 3
    "the x position isn't being mirrored", what? What do you actually want to achieve, what's the project you're working on, and why do you need to do Math(s) with positions? Commented Aug 18, 2019 at 14:05
  • Ok, so if you are against the right wall facing south the decimal number is .7, I want to rotate the player 180 and move them somewhere else using relative teleportation but that would keep the .7 however the decimal against the right wall when facing north is .3 so the teleport is not seamless Commented Aug 18, 2019 at 22:06
  • You should have the same problem with z, not just x.
    – user232393
    Commented Aug 18, 2019 at 22:56
  • I think the OP wants to let the player face in the opposite direction after teleportation, so he/she is once again oriented in the exact same way in this mirrored structure, making it a seamless experience. @badhaloninja, could you also provide a top view of the structures? It seem the structure with the lime colored glass is further away in this picture, making it necessary to also change the y-position after teleportation. (It seems there are three exactly similar buildings connected by colored hallways, is that the right interpretation?)
    – Joachim
    Commented Aug 24, 2019 at 8:33
  • The image is top view? But the y-pos is indeed different. Also yes, that is the correct interpretation. Commented Aug 25, 2019 at 19:41

1 Answer 1


You can't really do scoreboard things with the coordinates of a /tp command. What you can do is setting the Pos tag of a dummy entity and then teleporting the player to it. So you can for example summon an armour stand at the player's position:

/execute at @p run summon armor_stand

…and then get its position into a scoreboard:

/execute store result score @p x run data get entity @e[type=armor_stand,limit=1] Pos[0]

(after preparing the scoreboard of course, the same for Y and Z).
Then you can assign the sum of the starting X coordinate and the target X coordinate to some dummy entity or fake player or whatever and use /scoreboard players operation to subtract the starting coordinates from it. The same for Z of course.
Finally, you set the coordinates of the armour stand to the target coordinates:

/execute store entity @e[type=armor_stand,limit=1] Pos[0] run scoreboard players get @p x

And then you simply teleport the player to the armour stand. If the target coordinates are far away, you have to do it in the same tick, because the chunk will unload again otherwise.
And of course you'll likely want to restrict these target selectors @p and @e[type=armor_stand] somewhat, depending on the rest of your setup.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .