mojira.dev
MC-141744

Entities rotating their heads while idle is client side only

The bug

When an entity randomly rotates, while standing on the same position, the server does not update the entity's rotation, causing the Rotation NBT and local coordinates to be inaccurate to what players see.

How to reproduce

  1. Summon a zombie

  2. Run this command in a repeating command block:

    /execute at @e[type=zombie] anchored eyes run particle flame ^ ^ ^4 0 0 0 0 1

    → ❌ When the zombie randomly looks around without moving, the particle will stay in the same place, rather than move with the zombie's looking direction

Code analysis

Potential code analysis by @unknown can be found in this comment.

Linked issues

Attachments

Comments 9

Can confirm in 20w51a.

Can confirm in 21w05b.

Can confirm in 21w06a.

Can confirm in 1.16.5 and 21w10a. Video attached.

The cause of this issue is likely located in the BodyRotationControl class. The yRot field is not updated when the mob is not moving. Here's an example of a fix in the method BodyRotationControl::clientTick. The only change is the addition of the last line.

if (this.isMoving()) {
         this.mob.yBodyRot = this.mob.getYRot(); // Take the logic from here
         this.rotateHeadIfNecessary();
         this.lastStableYHeadRot = this.mob.yHeadRot;
         this.headStableTime = 0;
      } else {
         if (this.notCarryingMobPassengers()) {
            if (Math.abs(this.mob.yHeadRot - this.lastStableYHeadRot) > 15.0F) {
               this.headStableTime = 0;
               this.lastStableYHeadRot = this.mob.yHeadRot;
               this.rotateBodyIfNecessary();
            } else {
               ++this.headStableTime;
               if (this.headStableTime > 10) {
                  this.rotateHeadTowardsFront();
               }
            }
            this.mob.setYRot(this.mob.yBodyRot). //And apply the opposite here
         }
      }

Ok, turns out this is actually a duplicate of MC-135178.
Moderator that resolves this, please ensure all the info in this report is moved over to that one. (Or resolve that one in favor of this one.)

Can confirm in 1.17.1

Can confirm in 21w44a

Can confirm in 1.18.2 and 22w18a.

user-f2760

(Unassigned)

Confirmed

Gameplay

Normal

Commands, Entities

Minecraft 1.13-pre7, Minecraft 1.13, Minecraft 18w30b, Minecraft 1.13.1, Minecraft 1.13.2, ..., 1.20.1, 1.20.2, 23w43b, 1.20.4, 1.21.4

Retrieved