private void applyFunTimeSnap(Rotation targetAngle) {
if (!this.funtimeSnap.isSelected()) {
return;
}
float deltaYaw = MathHelper.wrapDegrees(targetAngle.getYaw() - this.lastYaw);
float deltaPitch = targetAngle.getPitch() - this.lastPitch;
float targetYaw = this.lastYaw + deltaYaw;
float targetPitch = this.lastPitch + deltaPitch;
float gcd = Rotation.gcd();
targetYaw -= (targetYaw - this.lastYaw) % gcd;
targetPitch -= (targetPitch - this.lastPitch) % gcd;
this.shakeTime += this.shakeSpeed.getCurrent() * 0.05F;
float intensity = this.shakeIntensity.getCurrent();
float yawOffset = (float) (Math.sin(this.shakeTime * 1.7F) * intensity * 0.5F);
float pitchOffset = (float) (Math.sin(this.shakeTime * 2.3F + 1.0F) * intensity * 0.25F);
Rotation finalRotation = new Rotation(
targetYaw + yawOffset,
targetPitch + pitchOffset
);
RotationComponent.update(
finalRotation,
360.0F,
360.0F,
360.0F,
360.0F,
0,
1,
false
);
this.lastYaw = targetYaw;
this.lastPitch = targetPitch;
}
private void applyLonyJir(Rotation targetAngle) {
if (!this.lonyJir.isSelected()) {
return;
}
updateAcceleration();
float deltaYaw = MathHelper.wrapDegrees(targetAngle.getYaw() - this.lastYaw);
float deltaPitch = targetAngle.getPitch() - this.lastPitch;
float factor = MathHelper.clamp(this.acceleration, 0.0F, 1.0F);
float yawFactor = factor;
float pitchFactor = factor / 2.0F;
float newYaw = this.lastYaw + deltaYaw * yawFactor;
float newPitch = this.lastPitch + deltaPitch * pitchFactor;
float gcd = Rotation.gcd();
newYaw -= (newYaw - this.lastYaw) % gcd;
newPitch -= (newPitch - this.lastPitch) % gcd;
Rotation smoothRotation = new Rotation(newYaw, newPitch);
float cameraDeltaYaw = MathHelper.wrapDegrees(mc.gameRenderer.getCamera().getYaw() - this.lastYaw);
float cameraDeltaPitch = mc.gameRenderer.getCamera().getPitch() - this.lastPitch;
if (mc.options.getPerspective() == Perspective.THIRD_PERSON_FRONT) {
cameraDeltaYaw = MathHelper.wrapDegrees(mc.gameRenderer.getCamera().getYaw() - 180.0F - this.lastYaw);
cameraDeltaPitch = -mc.gameRenderer.getCamera().getPitch() - this.lastPitch;
}
boolean cameraAligned =
Math.abs(cameraDeltaYaw) <= 3.0F &&
Math.abs(cameraDeltaPitch) <= 3.0F;
float yawSpeed = 360.0F;
float pitchSpeed = 360.0F;
float bodyYawSpeed = cameraAligned ? 360.0F : 0.0F;
float bodyPitchSpeed = cameraAligned ? 360.0F : 0.0F;
RotationComponent.update(
smoothRotation,
yawSpeed,
pitchSpeed,
bodyYawSpeed,
bodyPitchSpeed,
0,
1,
false
);
this.lastYaw = smoothRotation.getYaw();
this.lastPitch = smoothRotation.getPitch();
}
private void updateAcceleration() {
if (mc.player.isGliding()) {
if (!this.isBack) {
this.acceleration += 0.005F;
if (this.acceleration >= 0.13F) {
this.isBack = true;
}
} else {
if (this.acceleration >= -0.02F) {
this.acceleration -= 0.005F;
}
if (this.acceleration <= -0.02F) {
this.isBack = false;
}
}
return;
}
boolean lookingAtTarget = RaytracingUtil.rayTrace(
mc.player.getRotationVector(),
1488.0D,
this.target.getBoundingBox()
);
if (!lookingAtTarget) {
this.acceleration += 0.0015F;
} else if (this.acceleration > 0.0F) {
this.acceleration -= 0.01F;
}
}