When teleporting an entity with /tp
with relative coordinates, the accuracy of the destination seems to vary depending on the entity's previous coordinates. Sometimes it is slightly negative, sometimes it is slightly positive.
This may seem like a well-known floating point error, but it differs in that the coordinates of the destination are always the same double/float
value. i.e. Running two commands with exactly the same destination position coordinates(double
) teleports to different position coordinates(double
).
This only occurs in relative and local coordinates. Absolute coordinates seem safe.
/forceload add 0 0
/summon marker 0.0 0.0 0.0 {UUID:[I;0,0,0,0]}
Case 1 : teleport from 4.0 to 1.1 → 1.1 ✔ Expected
/tp 0-0-0-0-0 4.0 0.0 0.0
/execute positioned 1.1 0.0 0.0 run tp 0-0-0-0-0 ~ 0.0 0.0
/data get entity 0-0-0-0-0 Pos
Case 2 : teleport from 16.0 to 1.1 → 1.0999999999999996 ❌ Wrong position
/tp 0-0-0-0-0 16.0 0.0 0.0
/execute positioned 1.1 0.0 0.0 run tp 0-0-0-0-0 ~ 0.0 0.0
/data get entity 0-0-0-0-0 Pos
Case 3 : teleport from 32.0 to 1.1 → 1.1000000000000014 ❌ Wrong position
/tp 0-0-0-0-0 32.0 0.0 0.0
/execute positioned 1.1 0.0 0.0 run tp 0-0-0-0-0 ~ 0.0 0.0
/data get entity 0-0-0-0-0 Pos
The same problem occurs with the rotation argument of /tp
. (Not in /rotate
.)
Case 4 : rotate from 2.0 to 1.1 → 1.1 ✔ Expected
/tp 0-0-0-0-0 0.0 0.0 0.0 2.0 0.0
/execute rotated 1.1 0.0 run tp 0-0-0-0-0 0.0 0.0 0.0 ~ 0.0
/data get entity 0-0-0-0-0 Rotation
Case 5 : rotate from 8.0 to 1.1 → 1.0999999 ❌ Wrong rotation
/tp 0-0-0-0-0 0.0 0.0 0.0 8.0 0.0
/execute rotated 1.1 0.0 run tp 0-0-0-0-0 0.0 0.0 0.0 ~ 0.0
/data get entity 0-0-0-0-0 Rotation
Case 6 : rotate from 16.0 to 1.1 → 1.1000004 ❌ Wrong rotation
/tp 0-0-0-0-0 0.0 0.0 0.0 16.0 0.0
/execute rotated 1.1 0.0 run tp 0-0-0-0-0 0.0 0.0 0.0 ~ 0.0
/data get entity 0-0-0-0-0 Rotation
Comments 0
No comments.