Skip to main content
1 of 3
Day Trip
  • 75
  • 1
  • 9

How to interpolate smoothly between two yaw rotations less fast in MCP/Forge?

I am coding a custom client for Minecraft using MCP. (Please no hate, I'm not making a hacked client!) I have two variables currentYaw which is the current yaw rotation of the player, and targetYaw which is the yaw rotation that I want the player to be looking at. I have a function called lerpAngle and here is the code for it:

public static float lerpAngle(float fromRadians, float toRadians, float progress) {
    float delta = ((toRadians - fromRadians + PI2 + PI) % PI2) - PI;
    return (fromRadians + delta * progress + PI2) % PI2;
}

There is a float in minecraft.timer called elapsedPartialTicks. This variable is always between 0 and 1. Now I want to interpolate between currentYaw and targetYaw so that the transition is smooth. I passed in elapsedPartialTicks as progress but the screen moves way too fast. I am running all this code from the tick method.

What can I do to interpolate smoothly between currentYaw and targetYaw, but without the screen moving so fast.

Thank you for all the help!

Please note that I don't need any code, so it doesn't matter if you're answer is based on Forge or MCP. I just need a logic; I can write the code myself.

Again, thank you so much!

Day Trip
  • 75
  • 1
  • 9