Files
OpenOnyx/src/openonyx/events/MovementRotation.java
T

86 lines
2.2 KiB
Java

package openonyx.events;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;
import openonyx.core.MinecraftAccess;
public class MovementRotation implements MinecraftAccess {
private static boolean L = false;
private static EntityPlayerSP entityPlayerSP = null;
private static float m = 0.0F;
private static final float h = 50.0F;
private static float l = 0.0F;
private static float I = 0.0F;
private static float d = 0.0F;
private static float i = 0.0F;
private static float f = 0.0F;
private static float H = 0.0F;
private static float e = 0.0F;
private static float L() {
double dx = mc.thePlayer.posX - mc.thePlayer.prevPosX;
double ex = mc.thePlayer.posZ - mc.thePlayer.prevPosZ;
float fx = m;
if ((float)(dx * dx + ex * ex) > 0.0025000002F) {
float g = (float)(MathHelper.atan2(ex, dx) * 180.0 / Math.PI) - 90.0F;
float hx = Math.abs(MathHelper.wrapAngleTo180_float(I) - g);
fx = 95.0F <= hx && hx < 265.0F ? g - 180.0F : g;
}
if (mc.thePlayer.swingProgress > 0.0F) {
fx = I;
}
float ix = m + MathHelper.wrapAngleTo180_float(fx - m) * 0.3F;
float j;
if (Math.abs(j = MathHelper.wrapAngleTo180_float(I - ix)) > 50.0F) {
ix += j - Math.signum(j) * 50.0F;
}
return ix;
}
public static void L() {
if (mc.thePlayer != null) {
i = I;
l = e;
d = m;
I = H;
e = f;
m = L();
}
}
public static boolean L(Entity entity) {
return L && entity == mc.thePlayer;
}
public static float D(float f) {
return RotationMath.L(d, m, fx);
}
public static float d(float f) {
return RotationMath.L(i, I, fx);
}
public static float L(float f) {
return l + (e - l) * fx;
}
public static void L(float f, float g) {
H = fx;
f = g;
L = RotationManager.D();
if (entityPlayerSP != mc.thePlayer) {
entityPlayerSP = mc.thePlayer;
i = fx;
I = fx;
l = g;
e = g;
d = fx;
m = fx;
}
}
}