2323import com .llamalad7 .mixinextras .injector .wrapoperation .WrapOperation ;
2424import net .minecraft .client .render .entity .LivingEntityRenderer ;
2525import net .minecraft .entity .LivingEntity ;
26+ import org .jetbrains .annotations .Nullable ;
2627import org .spongepowered .asm .mixin .Mixin ;
2728import org .spongepowered .asm .mixin .injection .At ;
2829
29- import java . util .Objects ;
30+ import static com . lambda . util .math . LinearKt . lerp ;
3031
3132// This mixin's purpose is to set the player's pitch the current render pitch to correctly show the rotation
3233// regardless of the camera position
@@ -49,8 +50,11 @@ public class LivingEntityRendererMixin {
4950 */
5051 @ WrapOperation (method = "updateRenderState(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/client/render/entity/state/LivingEntityRenderState;F)V" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/entity/LivingEntity;getLerpedPitch(F)F" ))
5152 private float wrapGetLerpedPitch (LivingEntity instance , float v , Operation <Float > original ) {
52- return (instance == Lambda .getMc ().player )
53- ? Objects .requireNonNullElse (RotationManager .getHeadPitch (), original .call (instance , v ))
54- : original .call (instance , v );
53+ @ Nullable
54+ Float headPitch = RotationManager .getHeadPitch ();
55+ if (instance != Lambda .getMc ().player || headPitch == null )
56+ return original .call (instance , v );
57+
58+ return lerp (v , RotationManager .INSTANCE .getPrevServerRotation ().getPitchF (), headPitch );
5559 }
5660}
0 commit comments