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
Summon a zombie
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
is duplicated by 5
Attachments
Comments 9
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 20w51a.