mojira.dev
MC-90097

Client yaw rotation does not adhere angle limitations

This was tested with a recompiled version of Minecraft 1.8 using MCP. However I cannot test it that easily in newer versions.

The bug

The client does not set the yaw rotation to the valid -180 to 180 angle when the player continues to rotate.

Normally you would not notice that because the debug screen disguises it by doing this. However when you remove this part of the code you will see that the yaw increases to infinity when you rotate. This could in theory cause problems as with high numbers Minecraft has strange movement and rendering bugs.

The reason

The reason for this is that in the public void setAngles(float yaw, float pitch) method of the net.minecraft.entity.Entity class (MCP 1.8 names) just sets the rotation values without testing if they are between -180 and 180.

/**
 * Adds 15% to the entity's yaw and subtracts 15% from the pitch. Clamps pitch from -90 to 90. Both arguments in
 * degrees.
 */
public void setAngles(float yaw, float pitch)
{
	float var3 = this.rotationPitch;
	float var4 = this.rotationYaw;
	// Replaced this
	// this.rotationYaw = (float)((double)this.rotationYaw + (double)yaw * 0.15D);
	// this.rotationPitch = (float)((double)this.rotationPitch - (double)pitch * 0.15D);
	this.rotationYaw = MathHelper.wrapAngleTo180_float((float)((double)this.rotationYaw + (double)yaw * 0.15D));
	this.rotationPitch = MathHelper.wrapAngleTo180_float((float)((double)this.rotationPitch - (double)pitch * 0.15D));
	
	
	this.rotationPitch = MathHelper.clamp_float(this.rotationPitch, -90.0F, 90.0F);
	this.prevRotationPitch += this.rotationPitch - var3;
	this.prevRotationYaw += this.rotationYaw - var4;
}

This fix has however problems when rotating from -180 to 180 it looks like it jumps for two pixels and the player arm is rotating 360°.

Attachments

Comments 4

Is this still an issue in the most recent versions (currently that is 1.10.2, or 16w43a) of Minecraft? If so, please update the affected versions and help us keeping this ticket updated from time to time. If you are the owner/reporter of this ticket, you can modify the affected version(s) yourself.

Just discovered this on 1.20.4 while testing a custom server and looking at the angles sent by the client; definitely still unresolved.

After setting mouse sensitivity to HYPERSPEED!!! and disabling raw input (with mouse acceleration enabled system-wide), I was able to reach a yaw value below -2²² (~-4 million) in a reasonable amount of time, for some definition of reasonable. As shown in the attached video, this number is large enough to show visible quantization in the debug screen yaw display. It also causes a very noticeable "screen edge" effect blocking horizontal mouse movement when the motion delta since last frame is less than 0.5 degrees, also shown in the video.

[media]

As an aside, weird how a report for 1.19-pre3 can be marked as a duplicate without causing this to be reopened...

still in 1.21.1 and 24w33a.

marcono1234

(Unassigned)

Community Consensus

(Unassigned)

client, limit, limitation, rotation

Minecraft 1.8.8, 1.20.4

Retrieved