Fixes the mouse delay bug introduced in Minecraft 1.8
Switch branches/tags
Nothing to show
Clone or download
Latest commit 78cac28 Jan 9, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
gradle/wrapper It works Apr 24, 2017
src/main/java/io/prplz/mousedelayfix Update version Jan 9, 2018
.gitignore Only affect EntityPlayerSP (consistent with MC 1.11) May 1, 2017
README.md fixed typo in README file Dec 22, 2017
build.gradle Client side only, fixes #2 Jan 9, 2018
gradle.properties Client side only, fixes #2 Jan 9, 2018
gradlew It works Apr 24, 2017
gradlew.bat It works Apr 24, 2017

README.md

MouseDelayFix

MouseDelayFix is a forge mod for Minecraft 1.8.x, 1.9.x and 1.10.x to fix the mouse delay bug introduced in Minecraft 1.8 (https://bugs.mojang.com/browse/MC-67665).


The bug

// EntityLivingBase
public Vec3 getLook(float partialTicks) {
    if (partialTicks == 1.0F) {
        return this.getVectorForRotation(this.rotationPitch, this.rotationYawHead);
    } else {
        float f = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * partialTicks;
        float f1 = this.prevRotationYawHead + (this.rotationYawHead - this.prevRotationYawHead) * partialTicks;
        return this.getVectorForRotation(f, f1);
    }
}

Since 1.8 entity look direction is being derived from rotationYawHead instead of rotationYaw. This is bad for players because the angle your head faces is not the same as your crosshair location.


Mojang's fix (MC 1.11)

// EntityPlayerSP
public Vec3d getLook(float partialTicks) {
    return this.getVectorForRotation(this.rotationPitch, this.rotationYaw);
}

The fix added in 1.11 is to override getLook in the client player class (EntityPlayerSP) and use rotationYaw.


My fix

 // EntityLivingBase
 public Vec3 getLook(float partialTicks) {
+    if (this instanceof EntityPlayerSP) {
+        return super.getLook(partialTicks);
+    }
     if (partialTicks == 1.0F) {
         return this.getVectorForRotation(this.rotationPitch, this.rotationYawHead);
     } else {
         float f = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * partialTicks;
         float f1 = this.prevRotationYawHead + (this.rotationYawHead - this.prevRotationYawHead) * partialTicks;
         return this.getVectorForRotation(f, f1);
     }
 }

My fix injects the above code into EntityLivingBase.getLook. This works because Entity.getLook uses rotationYaw (non-living entities don't have heads!). This is equivalent to Mojang's 1.11 fix.