long currentTime = System.currentTimeMillis();
if (spookyTimeLastChange == 0) spookyTimeLastChange = currentTime;
float smoothMultiPitchY = lerp(spookyTimeStart, spookyTimeTarget,
Math.min(1.0f, (currentTime - spookyTimeLastChange) / 500.0f));
if (currentTime - spookyTimeLastChange > 500) {
spookyTimeLastChange = currentTime;
spookyTimeTarget = MathSystem.random(-1.0f, 1f);
spookyTimeStart = smoothMultiPitchY;
}
pitchToTargetValue = (float) (-Math.toDegrees(Math.atan2(vec.y + smoothMultiPitchY, hypot(vec.x, vec.z))));
pitchDelta = wrapDegrees(pitchToTargetValue - this.rotateVector.y);
float yaw = Math.min(Math.max(Math.abs(yawDelta), 0), MathSystem.random(40, 70));
float pitch = Math.min(Math.max(Math.abs(pitchDelta), 0), MathSystem.random(5, 20));
float yaw33 = this.rotateVector.x + (yawDelta > 0.0f ? yaw : -yaw);
float gcd = this.rotateVector.x + (yawDelta > 0.0f ? yaw : -yaw);
float finalPitch = 0;
double xzDistance = Math.hypot(this.getTarget().getPosX() - mc.player.getPosX(), this.getTarget().getPosZ() - mc.player.getPosZ());
finalPitch = clamp(this.rotateVector.y + (pitchDelta > 0.0f ? pitch : -pitch), xzDistance < 1.7f ? -90 : -90, 90);
gcd -= (yaw33 - this.rotateVector.x) % GCDSensSystem.getGCDValue();
this.rotateVector = new Vector2f(gcd, finalPitch);
this.lastYaw = yaw33;
this.lastPitch = pitch;
break;
}