-
Bug
-
Resolution: Unresolved
-
None
-
Minecraft 1.12.2, Minecraft 18w02a, Minecraft 1.13.1, Minecraft 18w50a, Minecraft 1.14.3, 1.14.4, 19w41a, 1.15 Pre-Release 2, 1.15 Pre-release 4, 1.15.1 Pre-release 1, 1.15.2, 1.16 Pre-release 2, 1.16 Pre-release 3, 1.16 Pre-release 6, 1.16.1, 20w28a, 20w29a, 20w30a, 1.16.2 Pre-release 1, 1.16.2 Pre-release 2, 1.16.2 Pre-release 3, 1.16.2 Release Candidate 1, 1.16.2 Release Candidate 2, 1.16.2, 1.16.3, 21w03a, 21w05b, 1.17.1, 1.18.1, 22w06a, 1.19 Pre-release 1, 1.19, 1.19.2, 1.19.3, 1.19.4, 1.20.1, 1.20.4
-
Confirmed
-
Mob behaviour, Player
-
Low
-
Gameplay
The bug
When swinging with your left hand, the animation is not perfectly mirrored to swinging with your right hand. There is a very slight mismatch.
How to reproduce
- /tp @s ~ ~ ~ 0 0
- /effect give @p mining_fatigue 10000 15 true (to slow down the swinging animation)
- Go in third person to look at yourself from the front
- Hit with your right hand, notice that the corner of your hand goes past the center of your body
→ Also notice that your left hand will shake a little - Hit with your left hand by switching your main hand, notice that the corner of your hand does not go past the center of your body
→ Also notice that your right hand does NOT shake at allTo reproduce
- Summon an enderman
/summon minecraft:enderman ~ ~ ~ {Attributes:[{Base:-10.0d,Name:"generic.movement_speed"},{Base:0.0d,Name:"generic.attack_damage"}],LeftHanded:1b}
- Either attack it or look at it in the eyes
→ It's swings it's left arm in a weird way
also happens with piglin
Code analysis
The following is based on a decompiled version of Minecraft 1.12 using MCP 9.40
The reason is likely due to an oversight in net.minecraft.client.model.ModelBiped.setRotationAngles(). In the section calculating animations based off swingProgress, the line:
this.bipedLeftArm.rotateAngleX += this.bipedBody.rotateAngleY;
appears to add an offset to the left arm when the right arm is swinging. This line should instead subtract the value from the X angle and switch to modifying the right hand when the main hand is the left hand.
Additionally, in the same section, the line:
modelrenderer.rotateAngleZ += MathHelper.sin(this.swingProgress * (float)Math.PI) * -0.4F;
does not apply the angle correctly when on the left hand as the Z angle should be mirrored. Instead it should subtract the value from the Z angle.
Potential fix
if (this.swingProgress > 0.0F) { EnumHandSide enumhandside = this.getMainHand(entityIn); ModelRenderer modelrenderer = this.getArmForSide(enumhandside); float f1 = this.swingProgress; this.bipedBody.rotateAngleY = MathHelper.sin(MathHelper.sqrt(f1) * ((float)Math.PI * 2F)) * 0.2F; if (enumhandside == EnumHandSide.LEFT) { this.bipedBody.rotateAngleY *= -1.0F; } this.bipedRightArm.rotationPointZ = MathHelper.sin(this.bipedBody.rotateAngleY) * 5.0F; this.bipedRightArm.rotationPointX = -MathHelper.cos(this.bipedBody.rotateAngleY) * 5.0F; this.bipedLeftArm.rotationPointZ = -MathHelper.sin(this.bipedBody.rotateAngleY) * 5.0F; this.bipedLeftArm.rotationPointX = MathHelper.cos(this.bipedBody.rotateAngleY) * 5.0F; this.bipedRightArm.rotateAngleY += this.bipedBody.rotateAngleY; this.bipedLeftArm.rotateAngleY += this.bipedBody.rotateAngleY; /** * this.bipedBody.rotateAngleY is negated when hand side is left * thus it must be subtracted from this.bipedRightArm.rotateAngleX * to make it positive again as X angles aren't affected by mirroring */ if (enumhandside == EnumHandSide.LEFT) { this.bipedRightArm.rotateAngleX -= this.bipedBody.rotateAngleY; } else { this.bipedLeftArm.rotateAngleX += this.bipedBody.rotateAngleY; } f1 = 1.0F - this.swingProgress; f1 = f1 * f1; f1 = f1 * f1; f1 = 1.0F - f1; float f2 = MathHelper.sin(f1 * (float)Math.PI); float f3 = MathHelper.sin(this.swingProgress * (float)Math.PI) * -(this.bipedHead.rotateAngleX - 0.7F) * 0.75F; modelrenderer.rotateAngleX = (float)((double)modelrenderer.rotateAngleX - ((double)f2 * 1.2D + (double)f3)); modelrenderer.rotateAngleY += this.bipedBody.rotateAngleY * 2.0F; /** * Used 0.4F instead of -0.4F here. Right hand subtracts and left hand adds * since Z angles must apply opposite on left versus right hand to correctly mirror */ if (enumhandside == EnumHandSide.LEFT) { modelrenderer.rotateAngleZ += MathHelper.sin(this.swingProgress * (float)Math.PI) * 0.4F; } else { modelrenderer.rotateAngleZ -= MathHelper.sin(this.swingProgress * (float)Math.PI) * 0.4F; } }
- is duplicated by
-
MC-156118 The left-hand animation is different from the right-hand animation.
- Resolved
-
MC-163406 Left hand movement is much more exaggerated than the right hand.
- Resolved
-
MC-194588 Attacking animation is not mirrored for left handed endermen
- Resolved
-
MC-235586 Animation When hitting With Left Main Hand Is Incorrect
- Resolved
-
MC-254234 left hand doesn't swing in the correct direction in 3rd person when selected as main hand
- Resolved