mojira.dev
MC-311855

Entity rotation is not clamped properly

Expected behaviour

Entity rotation should always be in the range of [-180,180] and [-90,90].

Observed behaviour

  • After rotating excessively, player rotation loses floating point precision despite being clamped correctly in “/data get entity @s Rotation”

  • Teleporting an entity to the player reveals that its Rotation is not clamped at all (i.e., Rotation:[430.52295f, 9.058539f])

How to reproduce
Issue 1: Player rotation losing precision (Cannot be reproduced with /tp, needs /rotate)

  1. Repeating command block:

    /execute as @p at @s run rotate @s ~360000 ~
  2. Wait a few seconds and notice how rotation becomes more and more jittery, even after disabling the command block

Issue 2: Entity rotation not being clamped in NBT

  1. Place an armor stand

  2. Repeating command block:

    /execute at @p as @e[type=armor_stand] run tp @s ~ ~ ~ ~ ~
  3. Spin in a circle a few times

  4. data get entity @n[type=armor_stand] Rotation

  5. Notice how the rotation went beyond the intended boundaries.

Notes

  • It is to be noted that teleporting the armor stand to “~ ~ ~ ~ ~” calculates the rotation difference between the player’s clamped rotation and the armor stand’s clamped rotation, then adds the difference to the armor stand’s rotation without clamping it again. So rotating by 360 degrees at once does nothing. Therefore, the issue becomes larger the more often the teleportation is performed.

  • /rotate, on the other hand, directly adds the rotation, so rotating by 360 degrees does change the value.

  • The clamping can be critical if you want to use the entity rotation in a datapack or calculations. Large values tend to overflow (i.e., integer calculations involving the rotation), requiring the player to manually reset rotation every tick and before every teleportation.

Linked issues

Comments 1

Thank you for your report!
We're tracking this issue in MC-296670 and MC-304121, so this ticket is being resolved and linked as a Duplicate.

If you would like to add a vote and any extra information to the main tickets, it would be appreciated.

If you haven't already, please make use of the search feature to see if an issue you are about to report has already been reported.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki

SilicatYT

(Unassigned)

Unconfirmed

26.3 Release Candidate 2

Retrieved