- Статус
- Оффлайн
- Регистрация
- 24 Ноя 2024
- Сообщения
- 671
- Реакции
- 11
Ротация:
Коррекция через жопу от чата гпт:
Java:
private void applyFuntimeRotation() {
float rotSpeed = rotationSpeed.getValue();
if (adaptiveSpeed.isEnabled()) {
double distanceFactorBase = Math.min(1.0, lastTargetDistance / range.getValue());
double distanceFactor = 1.0 - (distanceFactorBase * 0.3);
float yawDiff = Math.abs(MathHelper.wrapDegrees(targetRotation[0] - currentRotation[0]));
float pitchDiff = Math.abs(targetRotation[1] - currentRotation[1]);
double angleFactor = Math.min(1.5, (yawDiff + pitchDiff) / 45.0);
rotSpeed *= Math.min(2.0, Math.max(0.8, distanceFactor * angleFactor));
}
rotSpeed *= 0.95f + random.nextFloat() * 0.1f;
float yawDifference = MathHelper.wrapDegrees(targetRotation[0] - currentRotation[0]);
float pitchDifference = targetRotation[1] - currentRotation[1];
float smoothingStrength = smoothFactor.getValue();
System.arraycopy(rotationSmoothingCache, 2, rotationSmoothingCache, 0, 6);
rotationSmoothingCache[6] = yawDifference;
rotationSmoothingCache[7] = pitchDifference;
double smoothedYawDiff = 0;
double smoothedPitchDiff = 0;
double totalWeight = 0;
for (int i = 0; i < 4; i++) {
double weight = Math.pow(smoothingStrength, i);
smoothedYawDiff += rotationSmoothingCache[6-i*2] * weight;
smoothedPitchDiff += rotationSmoothingCache[7-i*2] * weight;
totalWeight += weight;
}
smoothedYawDiff /= totalWeight;
smoothedPitchDiff /= totalWeight;
double progressFactor;
if (Math.abs(yawDifference) < 3.0 && Math.abs(pitchDifference) < 3.0) {
progressFactor = 1.0;
} else {
double completion = 1.0 - (Math.abs(smoothedYawDiff) / Math.max(1.0, Math.abs(yawDifference) + Math.abs(smoothedPitchDiff) / Math.max(1.0, Math.abs(pitchDifference))));
progressFactor = 0.5 + Math.sin(Math.PI * (completion - 0.5)) * 0.5;
progressFactor = Math.max(0.5, Math.min(1.5, progressFactor));
}
float yawStep = (float) (Math.min(Math.abs(smoothedYawDiff), rotSpeed) * Math.signum(smoothedYawDiff) * progressFactor);
float pitchStep = (float) (Math.min(Math.abs(smoothedPitchDiff), rotSpeed) * Math.signum(smoothedPitchDiff) * progressFactor);
float inertiaFactor = 0.35f;
yawStep = yawStep * (1 - inertiaFactor) + lastRotationStep[0] * inertiaFactor;
pitchStep = pitchStep * (1 - inertiaFactor) + lastRotationStep[1] * inertiaFactor;
lastRotationStep[0] = yawStep;
lastRotationStep[1] = pitchStep;
float yawRandomFactor = 1.0f + (random.nextFloat() - 0.5f) * 0.03f;
float pitchRandomFactor = 1.0f + (random.nextFloat() - 0.5f) * 0.02f;
currentRotation[0] += yawStep * yawRandomFactor;
currentRotation[1] += pitchStep * pitchRandomFactor;
if (Math.abs(yawDifference) < 1.0 && Math.abs(pitchDifference) < 1.0 && random.nextFloat() < 0.4) {
double microAmount = random.nextGaussian() * 0.02 * randomization.getValue();
currentRotation[random.nextBoolean() ? 0 : 1] += microAmount;
}
currentRotation[1] = MathHelper.clamp(currentRotation[1], -90.0f, 90.0f);
}
Коррекция через жопу от чата гпт:
Java:
private void correctMovement() {
if (mc.player.movementInput.moveForward == 0 && mc.player.movementInput.moveStrafe == 0) {
return;
}
float yaw = currentRotation[0];
float forward = mc.player.movementInput.moveForward;
float strafe = mc.player.movementInput.moveStrafe;
float oldForward = forward;
float oldStrafe = strafe;
float adjustedYaw = yaw;
if (forward != 0.0f && strafe != 0.0f) {
adjustedYaw += (forward > 0.0f) ? -45.0f : 135.0f;
if (strafe > 0.0f) {
adjustedYaw -= 90.0f;
}
forward = 0.0f;
} else if (forward != 0.0f) {
adjustedYaw += (forward > 0.0f) ? 0.0f : 180.0f;
} else if (strafe != 0.0f) {
adjustedYaw += (strafe > 0.0f) ? -90.0f : 90.0f;
}
float clientYaw = mc.player.rotationYaw;
float deltaYaw = adjustedYaw - clientYaw;
mc.player.movementInput.moveForward = oldForward * (float)Math.cos(Math.toRadians(deltaYaw)) +
oldStrafe * (float)Math.sin(Math.toRadians(deltaYaw));
mc.player.movementInput.moveStrafe = oldStrafe * (float)Math.cos(Math.toRadians(deltaYaw)) -
oldForward * (float)Math.sin(Math.toRadians(deltaYaw));
}