Подведи собственные итоги года совместно с YOUGAME и забери ценные призы! Перейти

RotationUtils / 3.1

  • Автор темы Автор темы zeonex_
  • Дата начала Дата начала
Начинающий
Начинающий
Статус
Оффлайн
Регистрация
9 Окт 2024
Сообщения
41
Реакции
0
package onex.main.utils.rotation;

import onex.main.OnexMain;
import onex.main.utils.client.IMinecraft;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector2f;

import static java.lang.Math.PI;


public class RotationUtils implements IMinecraft {
// 08.27.2024

private static final float MAX_SPEED_YAW = 2.6f;
private static final float MAX_SPEED_PITCH = 1.7f;
private static final float RANDOM_FACTOR = 0.52f;
private static final float MAX_YAW_DELTA = 50f;
private static final float MAX_PITCH_DELTA = 50f;
private static final float MIN_YAW_SPEED = 0.1f;
private static final float MIN_PITCH_SPEED = 0.1f;
private static final float SMOOTHING_FACTOR = 0.5f;
private static final float MAX_YAW_ACCELERATION = 0.5f;
private static final float MAX_PITCH_ACCELERATION = 0.5f;
private static final float MIN_YAW_ACCELERATION = 0.1f;
private static final float MIN_PITCH_ACCELERATION = 0.1f;

private float lastYaw;
private float lastPitch;
private float lastYawSpeed;
private float lastPitchSpeed;

public RotationUtils() {
OnexMain.getInstance().getEventBus().register(this);
}

public static Vector2f calculate(final double x, final double y, final double z) {
net.minecraft.util.math.vector.Vector3d pos = mc.player.getPositionVec().add(0, mc.player.getEyeHeight(), 0);
return calculate(new org.joml.Vector3d(pos.x, pos.y, pos.z), new org.joml.Vector3d(x, y, z));
}

public static Vector2f calculate(final org.joml.Vector3d to) {
net.minecraft.util.math.vector.Vector3d pos = mc.player.getPositionVec().add(0, mc.player.getEyeHeight(), 0);
org.joml.Vector3d from = new org.joml.Vector3d(pos.x, pos.y, pos.z);
return calculate(from, to);
}

public static Vector2f calculate(final org.joml.Vector3d from, final org.joml.Vector3d to) {
org.joml.Vector3d diff = to.sub(from);
double distance = java.lang.Math.hypot(diff.x(), diff.z());
float yaw = (float) (MathHelper.atan2(diff.z(), diff.x()) * 180F / PI) - 90F;
float pitch = (float) (-(MathHelper.atan2(diff.y(), distance) * 180F / PI));
yaw = normalize(yaw);
pitch = (float) MathHelper.clamp(-90, 90, pitch);
return new Vector2f(yaw, pitch);
}

public static float normalize(float value) {
value = value % 360.0f;
if (value > 180.0f) {
value -= 360.0f;
} else if (value < -180.0f) {
value += 360.0f;
}
return value;
}

public Vector2f getSmoothRotation(float currentYaw, float currentPitch, float newYaw, float newPitch, boolean isAiming) {
if (isAiming) {
lastYaw = currentYaw;
lastPitch = currentPitch;
}

float deltaYaw = MathHelper.wrapDegrees(newYaw - lastYaw);
float deltaPitch = newPitch - lastPitch;

float limitedYawSpeed = MathHelper.clamp(deltaYaw, -MAX_SPEED_YAW, MAX_SPEED_YAW);
float limitedPitchSpeed = MathHelper.clamp(deltaPitch, -MAX_SPEED_PITCH, MAX_SPEED_PITCH);

limitedYawSpeed = MathHelper.clamp(limitedYawSpeed, MIN_YAW_SPEED, MAX_YAW_DELTA);
limitedPitchSpeed = MathHelper.clamp(limitedPitchSpeed, MIN_PITCH_SPEED, MAX_PITCH_DELTA);

float yawAcceleration = MathHelper.clamp(limitedYawSpeed - lastYawSpeed, MIN_YAW_ACCELERATION, MAX_YAW_ACCELERATION);
float pitchAcceleration = MathHelper.clamp(limitedPitchSpeed - lastPitchSpeed, MIN_PITCH_ACCELERATION, MAX_PITCH_ACCELERATION);

lastYawSpeed += yawAcceleration;
lastPitchSpeed += pitchAcceleration;

float randomYaw = (float) (Math.random() * 2 - 1) * RANDOM_FACTOR * MAX_SPEED_YAW;
float randomPitch = (float) (Math.random() * 2 - 1) * RANDOM_FACTOR * MAX_SPEED_PITCH;

float smoothedYaw = lastYaw + lastYawSpeed + randomYaw;
float smoothedPitch = lastPitch + lastPitchSpeed + randomPitch;

smoothedYaw = lastYaw * (1 - SMOOTHING_FACTOR) + smoothedYaw * SMOOTHING_FACTOR;
smoothedPitch = lastPitch * (1 - SMOOTHING_FACTOR) + smoothedPitch * SMOOTHING_FACTOR;

return new Vector2f(smoothedYaw, smoothedPitch);
}
}
 
норм код:
Expand Collapse Copy
package onex.main.utils.rotation;

import onex.main.OnexMain;
import onex.main.utils.client.IMinecraft;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector2f;

import static java.lang.Math.PI;


public class RotationUtils implements IMinecraft {
// 08.27.2024

private static final float MAX_SPEED_YAW = 2.6f;
private static final float MAX_SPEED_PITCH = 1.7f;
private static final float RANDOM_FACTOR = 0.52f;
private static final float MAX_YAW_DELTA = 50f;
private static final float MAX_PITCH_DELTA = 50f;
private static final float MIN_YAW_SPEED = 0.1f;
private static final float MIN_PITCH_SPEED = 0.1f;
private static final float SMOOTHING_FACTOR = 0.5f;
private static final float MAX_YAW_ACCELERATION = 0.5f;
private static final float MAX_PITCH_ACCELERATION = 0.5f;
private static final float MIN_YAW_ACCELERATION = 0.1f;
private static final float MIN_PITCH_ACCELERATION = 0.1f;

private float lastYaw;
private float lastPitch;
private float lastYawSpeed;
private float lastPitchSpeed;

public RotationUtils() {
OnexMain.getInstance().getEventBus().register(this);
}

public static Vector2f calculate(final double x, final double y, final double z) {
net.minecraft.util.math.vector.Vector3d pos = mc.player.getPositionVec().add(0, mc.player.getEyeHeight(), 0);
return calculate(new org.joml.Vector3d(pos.x, pos.y, pos.z), new org.joml.Vector3d(x, y, z));
}

public static Vector2f calculate(final org.joml.Vector3d to) {
net.minecraft.util.math.vector.Vector3d pos = mc.player.getPositionVec().add(0, mc.player.getEyeHeight(), 0);
org.joml.Vector3d from = new org.joml.Vector3d(pos.x, pos.y, pos.z);
return calculate(from, to);
}

public static Vector2f calculate(final org.joml.Vector3d from, final org.joml.Vector3d to) {
org.joml.Vector3d diff = to.sub(from);
double distance = java.lang.Math.hypot(diff.x(), diff.z());
float yaw = (float) (MathHelper.atan2(diff.z(), diff.x()) * 180F / PI) - 90F;
float pitch = (float) (-(MathHelper.atan2(diff.y(), distance) * 180F / PI));
yaw = normalize(yaw);
pitch = (float) MathHelper.clamp(-90, 90, pitch);
return new Vector2f(yaw, pitch);
}

public static float normalize(float value) {
value = value % 360.0f;
if (value > 180.0f) {
value -= 360.0f;
} else if (value < -180.0f) {
value += 360.0f;
}
return value;
}

public Vector2f getSmoothRotation(float currentYaw, float currentPitch, float newYaw, float newPitch, boolean isAiming) {
if (isAiming) {
lastYaw = currentYaw;
lastPitch = currentPitch;
}

float deltaYaw = MathHelper.wrapDegrees(newYaw - lastYaw);
float deltaPitch = newPitch - lastPitch;

float limitedYawSpeed = MathHelper.clamp(deltaYaw, -MAX_SPEED_YAW, MAX_SPEED_YAW);
float limitedPitchSpeed = MathHelper.clamp(deltaPitch, -MAX_SPEED_PITCH, MAX_SPEED_PITCH);

limitedYawSpeed = MathHelper.clamp(limitedYawSpeed, MIN_YAW_SPEED, MAX_YAW_DELTA);
limitedPitchSpeed = MathHelper.clamp(limitedPitchSpeed, MIN_PITCH_SPEED, MAX_PITCH_DELTA);

float yawAcceleration = MathHelper.clamp(limitedYawSpeed - lastYawSpeed, MIN_YAW_ACCELERATION, MAX_YAW_ACCELERATION);
float pitchAcceleration = MathHelper.clamp(limitedPitchSpeed - lastPitchSpeed, MIN_PITCH_ACCELERATION, MAX_PITCH_ACCELERATION);

lastYawSpeed += yawAcceleration;
lastPitchSpeed += pitchAcceleration;

float randomYaw = (float) (Math.random() * 2 - 1) * RANDOM_FACTOR * MAX_SPEED_YAW;
float randomPitch = (float) (Math.random() * 2 - 1) * RANDOM_FACTOR * MAX_SPEED_PITCH;

float smoothedYaw = lastYaw + lastYawSpeed + randomYaw;
float smoothedPitch = lastPitch + lastPitchSpeed + randomPitch;

smoothedYaw = lastYaw * (1 - SMOOTHING_FACTOR) + smoothedYaw * SMOOTHING_FACTOR;
smoothedPitch = lastPitch * (1 - SMOOTHING_FACTOR) + smoothedPitch * SMOOTHING_FACTOR;

return new Vector2f(smoothedYaw, smoothedPitch);
}
}
 
норм код:
Expand Collapse Copy
package onex.main.utils.rotation;
private static final float MAX_SPEED_YAW = 2.6f;
private static final float MAX_SPEED_PITCH = 1.7f;
private static final float RANDOM_FACTOR = 0.52f;
private static final float MAX_YAW_DELTA = 50f;
private static final float MAX_PITCH_DELTA = 50f;
private static final float MIN_YAW_SPEED = 0.1f;
private static final float MIN_PITCH_SPEED = 0.1f;
private static final float SMOOTHING_FACTOR = 0.5f;
private static final float MAX_YAW_ACCELERATION = 0.5f;
private static final float MAX_PITCH_ACCELERATION = 0.5f;
private static final float MIN_YAW_ACCELERATION = 0.1f;
private static final float MIN_PITCH_ACCELERATION = 0.1f;
}
надеюсь не чат гпт
 
придурок
 
так я просто сообщение отформатировал кодом
я про это
1728567570744.png
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
/del есть на посте где чел кидал секс ауру
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Это обход фантаймика?
 
Назад
Сверху Снизу