package ru.wuq.implement.features.modules.combat.killaura.rotation.angle;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import ru.wuq.common.util.math.MathUtil;
import ru.wuq.implement.features.modules.combat.killaura.rotation.Angle;
import ru.wuq.implement.features.modules.combat.killaura.rotation.AngleUtil;
import java.util.Objects;
public class FunTimeSmoothMode extends AngleSmoothMode {
public FunTimeSmoothMode() {
super("FunTime");
}
@Override
public Angle limitAngleChange(Angle currentAngle, Angle targetAngle, Vec3d vec3d, Entity entity) {
Angle angleDelta = AngleUtil.calculateDelta(currentAngle, targetAngle);
float yawDelta = angleDelta.getYaw();
float pitchDelta = angleDelta.getPitch();
float rotationDifference = (float) Math.hypot(yawDelta, pitchDelta);
float distanceFactor = Math.max(Math.min(Objects.requireNonNull(mc.player).distanceTo(entity) / 2.0F, 1.0F), 0.5F);
float lineYaw = (Math.abs(yawDelta / rotationDifference) * 45) * distanceFactor;
float linePitch = (Math.abs(pitchDelta / rotationDifference) * 40) * distanceFactor;
float moveYaw = MathHelper.clamp(yawDelta, -lineYaw, lineYaw);
float movePitch = MathHelper.clamp(pitchDelta, -linePitch, linePitch);
Angle moveAngle = new Angle(currentAngle.getYaw(), currentAngle.getPitch());
moveAngle.setYaw((float) MathHelper.lerp(0.65F, currentAngle.getYaw(), currentAngle.getYaw() + moveYaw));
moveAngle.setPitch((float) MathHelper.lerp(0.65F, currentAngle.getPitch(), currentAngle.getPitch() + movePitch));
return new Angle(moveAngle.getYaw(), moveAngle.getPitch());
}
@Override
public Vec3d randomValue() {
return new Vec3d(
0F,
0F,
0F
);
}
}