Начинающий
- Статус
- Оффлайн
- Регистрация
- 16 Сен 2025
- Сообщения
- 21
- Реакции
- 0
- Выберите загрузчик игры
- Fabric
ss -
code -
Java:
package fun.rich.utils.features.aura.rotations.impl;
import fun.rich.Rich;
import fun.rich.features.impl.combat.Aura;
import fun.rich.utils.features.aura.point.MultiPoint;
import fun.rich.utils.features.aura.rotations.constructor.RotateConstructor;
import fun.rich.utils.features.aura.striking.StrikeManager;
import fun.rich.utils.features.aura.utils.MathAngle;
import fun.rich.utils.features.aura.warp.Turns;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Pair;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import org.jetbrains.annotations.NotNull;
import java.security.SecureRandom;
import java.util.ArrayDeque;
import java.util.Deque;
public class MlsAngle extends RotateConstructor {
private Vec3d cachedMultiPoint = null;
private Vec3d previousMultiPoint = null;
private Entity cachedEntity = null;
private int tickCounter = 0;
private int nextUpdateTick = 0;
private int interpolationTicks = 0;
private double yawFrequency;
private double pitchFrequency;
private float baseSpeedAttack;
private float baseSpeedIdle;
private float jitterYawMin;
private float jitterYawMax;
private float jitterPitchMin;
private float jitterPitchMax;
private int parameterUpdateCounter = 0;
private int nextParameterUpdate = 0;
public MlsAngle() {
super("Mls");
this.nextUpdateTick = uniqueValueGenerator(70, 131, null, 1.0f);
genParametr();
}
@Override
public Turns limitAngleChange(Turns currentAngle, Turns targetAngle, Vec3d vec3d, Entity entity) {
StrikeManager attackHandler = Rich.getInstance().getAttackPerpetrator().getAttackHandler();
Aura aura = Aura.getInstance();
parameterUpdateCounter++;
if (parameterUpdateCounter >= nextParameterUpdate) {
genParametr();
parameterUpdateCounter = 0;
}
if (entity instanceof LivingEntity livingEntity) {
tickCounter++;
if (cachedMultiPoint == null || cachedEntity != entity || tickCounter >= nextUpdateTick) {
Pair<Vec3d, Box> multiPointResult = new MultiPoint().computeVector(
livingEntity,
6.0f,
currentAngle,
new Vec3d(0.01, 0.07, 0.02),
false
);
previousMultiPoint = cachedMultiPoint;
cachedMultiPoint = multiPointResult.getLeft();
cachedEntity = entity;
tickCounter = 0;
nextUpdateTick = uniqueValueGenerator(70, 131, null, 1.0f);
interpolationTicks = 0;
}
Vec3d targetPoint = cachedMultiPoint;
if (previousMultiPoint != null && interpolationTicks < 10) {
float lerpFactor = interpolationTicks / 10.0f;
targetPoint = previousMultiPoint.lerp(cachedMultiPoint, lerpFactor);
interpolationTicks++;
}
assert mc.player != null;
targetAngle = MathAngle.fromVec3d(targetPoint.subtract(mc.player.getEyePos()));
} else {
cachedMultiPoint = null;
previousMultiPoint = null;
cachedEntity = null;
tickCounter = 0;
}
Turns angleDelta = MathAngle.calculateDelta(currentAngle, targetAngle);
float yawDelta = angleDelta.getYaw();
float pitchDelta = angleDelta.getPitch();
float rotationDifference = (float) Math.hypot(Math.abs(yawDelta), Math.abs(pitchDelta));
boolean canAttack = entity != null && attackHandler.canAttack(aura.getConfig(), 0);
float distanceToTarget = 0;
if (entity != null) {
assert mc.player != null;
distanceToTarget = mc.player.distanceTo(entity);
}
float baseSpeed = canAttack ? baseSpeedAttack : baseSpeedIdle;
if (distanceToTarget > 0 && distanceToTarget < 0.66F) {
float closeRangeSpeed = MathHelper.clamp(distanceToTarget / 1.5F * 0.35F, 0.1F, 0.6F);
baseSpeed = canAttack ? 0.85f : Math.min(baseSpeed, closeRangeSpeed);
}
float lineYaw = (Math.abs(yawDelta / (rotationDifference + 0.001f)) * 180);
float linePitch = (Math.abs(pitchDelta / (rotationDifference + 0.001f)) * 180);
long time = System.currentTimeMillis();
float currentJitterYaw = randomizeLerp(jitterYawMin, jitterYawMax);
float currentJitterPitch = randomizeLerp(jitterPitchMin, jitterPitchMax);
float jitterYaw = canAttack ? 0 : (float) (currentJitterYaw * Math.sin(time / yawFrequency));
float jitterPitch = canAttack ? 0 : (float) (currentJitterPitch * Math.sin(time / pitchFrequency));
if ((!aura.isState() || aura.getTarget() == null) && attackHandler.getAttackTimer().finished(1000)) {
baseSpeed = 0.35F;
jitterYaw = 0;
jitterPitch = 0;
}
float moveYaw = MathHelper.clamp(yawDelta, -lineYaw, lineYaw);
float movePitch = MathHelper.clamp(pitchDelta, -linePitch, linePitch);
Turns moveAngle = new Turns(currentAngle.getYaw(), currentAngle.getPitch());
moveAngle.setYaw(MathHelper.lerp(baseSpeed, currentAngle.getYaw(), currentAngle.getYaw() + moveYaw) + jitterYaw);
moveAngle.setPitch(MathHelper.lerp(baseSpeed, currentAngle.getPitch(), currentAngle.getPitch() + movePitch) + jitterPitch);
return moveAngle;
}
private void genParametr() {
baseSpeedAttack = uniqueValueGenerator(0.91f, 0.95f, new ArrayDeque<>(3), 0.01f);
baseSpeedIdle = uniqueValueGenerator(0.54f, 0.58f, new ArrayDeque<>(3), 0.01f);
yawFrequency = uniqueDouble(23D, 27D, new ArrayDeque<>(3), 0.1);
pitchFrequency = uniqueDouble(25D, 29D, new ArrayDeque<>(3), 0.1);
jitterYawMin = randomizeLerp(18f, 22f);
jitterYawMax = randomizeLerp(24f, 28f);
jitterPitchMin = randomizeLerp(6f, 10f);
jitterPitchMax = randomizeLerp(21f, 25f);
nextParameterUpdate = 15 + new SecureRandom().nextInt(26);
new ArrayDeque<>(3).addLast(baseSpeedAttack);
if (new ArrayDeque<>(3).size() > 2) new ArrayDeque<>(3).removeFirst();
new ArrayDeque<>(3).addLast(baseSpeedIdle);
if (new ArrayDeque<>(3).size() > 2) new ArrayDeque<>(3).removeFirst();
new ArrayDeque<>(3).addLast(yawFrequency);
if (new ArrayDeque<>(3).size() > 2) new ArrayDeque<>(3).removeFirst();
new ArrayDeque<>(3).addLast(pitchFrequency);
if (new ArrayDeque<>(3).size() > 2) new ArrayDeque<>(3).removeFirst();
}
private float uniqueValueGenerator(float min, float max, Deque<Float> history, float tolerance) {
float value;
int attempts = 0;
do {
value = randomizeLerp(min, max);
attempts++;
if (attempts > 50) break;
} while (history != null && duplicatepasta(value, history, tolerance));
return value;
}
private int uniqueValueGenerator(int min, int max, Deque<Float> history, float tolerance) {
int value;
int attempts = 0;
do {
value = min + new SecureRandom().nextInt(max - min);
attempts++;
if (attempts > 50) break;
} while (history != null && duplicatepasta((float) value, history, tolerance));
return value;
}
private double uniqueDouble(double min, double max, Deque<Double> history, double tolerance) {
double value;
int attempts = 0;
do {
value = randomizeLerpDouble(min, max);
attempts++;
if (attempts > 50) break;
} while (history != null && duplicatepastadouble(value, history, tolerance));
return value;
}
private boolean duplicatepasta(float value, @NotNull Deque<Float> history, float tolerance) {
if (history.size() < 2) return false;
Float[] arr = history.toArray(new Float[0]);
return Math.abs(value - arr[arr.length - 1]) < tolerance &&
Math.abs(value - arr[arr.length - 2]) < tolerance;
}
private boolean duplicatepastadouble(double value, @NotNull Deque<Double> history, double tolerance) {
if (history.size() < 2) return false;
Double[] arr = history.toArray(new Double[0]);
return Math.abs(value - arr[arr.length - 1]) < tolerance &&
Math.abs(value - arr[arr.length - 2]) < tolerance;
}
private float randomizeLerp(float min, float max) {
return MathHelper.lerp(new SecureRandom().nextFloat(), min, max);
}
private double randomizeLerpDouble(double min, double max) {
return MathHelper.lerp(new SecureRandom().nextDouble(), min, max);
}
@Override
public Vec3d randomValue() {
return new Vec3d(0.01, 0.07, 0.02);
}
}