-
Автор темы
- #1
Перед прочтением основного контента ниже, пожалуйста, обратите внимание на обновление внутри секции Майна на нашем форуме. У нас появились:
- бесплатные читы для Майнкрафт — любое использование на свой страх и риск;
- маркетплейс Майнкрафт — абсолютно любая коммерция, связанная с игрой, за исключением продажи читов (аккаунты, предоставления услуг, поиск кодеров читов и так далее);
- приватные читы для Minecraft — в этом разделе только платные хаки для игры, покупайте группу "Продавец" и выставляйте на продажу свой софт;
- обсуждения и гайды — всё тот же раздел с вопросами, но теперь модернизированный: поиск нужных хаков, пати с игроками-читерами и другая полезная информация.
Спасибо!
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);
}
}
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);
}
}