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

Часть функционала Топовая киллаура exp 3.1

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
27 Янв 2025
Сообщения
56
Реакции
2
Выберите загрузчик игры
  1. Прочие моды
новая селфкод килка для топовых пастеров нафик кто понил тот понял спасиба маему кинту Хз М. за что что предоставил свою топовую килку
вот код
Код:
Expand Collapse Copy
package im.expensive.functions.impl.combat;

import com.google.common.eventbus.Subscribe;
import im.expensive.command.friends.FriendStorage;
import im.expensive.events.EventInput;
import im.expensive.events.EventMotion;
import im.expensive.events.EventUpdate;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.functions.settings.impl.BooleanSetting;
import im.expensive.functions.settings.impl.ModeListSetting;
import im.expensive.functions.settings.impl.ModeSetting;
import im.expensive.functions.settings.impl.SliderSetting;
import im.expensive.utils.math.SensUtils;
import im.expensive.utils.player.InventoryUtil;
import im.expensive.utils.player.MouseUtil;
import im.expensive.utils.player.MoveUtils;
import lombok.Getter;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ArmorStandEntity;
import net.minecraft.entity.monster.MonsterEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.ClickType;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.CHeldItemChangePacket;
import net.minecraft.util.Hand;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Random;

import static java.lang.Math.hypot;
import static net.minecraft.util.math.MathHelper.clamp;
import static net.minecraft.util.math.MathHelper.wrapDegrees;

@FunctionRegister(name = "KillAura", type = Category.Combat)
public class KillAura extends Function {
    @Getter
    private final ModeSetting rotationType = new ModeSetting("Тип ротации", "Выключена", "Выключена", "Плавная", "Снап", "HVH Плавная", "HVH Снап");

    // Основные настройки
    private final SliderSetting attackRange = new SliderSetting("Дальность атаки", 3.2f, 3f, 6f, 0.1f);
    private final SliderSetting fov = new SliderSetting("Поле зрения", 180f, 30f, 360f, 1f);

    // Настройки для снап ротации (мгновенная)
    private final SliderSetting snapAccuracy = new SliderSetting("Точность снапа", 1.0f, 0.5f, 5f, 0.1f);
    private final BooleanSetting snapPrediction = new BooleanSetting("Предсказание траектории", true);
    private final SliderSetting predictionStrength = new SliderSetting("Сила предсказания", 1.5f, 0.5f, 3f, 0.1f);
    private final BooleanSetting snapSilent = new BooleanSetting("Скрытный снап", false);
    private final BooleanSetting snapAntiAim = new BooleanSetting("Противоаим", false);
    private final SliderSetting snapAntiAimAmount = new SliderSetting("Сила противоаима", 5f, 1f, 15f, 0.5f);

    // Настройки для HVH ротаций
    private final SliderSetting hvhRotationSpeed = new SliderSetting("Скорость плавного поворота", 60f, 10f, 360f, 1f);
    private final SliderSetting hvhPitchSpeed = new SliderSetting("Скорость плавного наклона", 40f, 10f, 180f, 1f);
    private final BooleanSetting silentAim = new BooleanSetting("Скрытное наведение", false);
    private final BooleanSetting randomization = new BooleanSetting("Случайные отклонения", false);

    final ModeListSetting targetSelection = new ModeListSetting("Выбор целей",
            new BooleanSetting("Игроки", true),
            new BooleanSetting("Без брони", true),
            new BooleanSetting("Враждебные мобы", false),
            new BooleanSetting("Мирные мобы", false),
            new BooleanSetting("Друзья", false),
            new BooleanSetting("Невидимые без брони", true),
            new BooleanSetting("Невидимые", true));

    @Getter
    final ModeListSetting advancedOptions = new ModeListSetting("Дополнительно",
            new BooleanSetting("Только с критом", false),
            new BooleanSetting("Ломать щиты", true),
            new BooleanSetting("Отжимать щиты", true),
            new BooleanSetting("Ускорять при атаке", true),
            new BooleanSetting("Синхронизация с TPS", false),
            new BooleanSetting("Фиксировать цель", true),
            new BooleanSetting("Корректировка движения", true),
            new BooleanSetting("Пауза при использовании предметов", true),
            new BooleanSetting("Снап при атаке", true));

    final ModeSetting movementCorrection = new ModeSetting("Стиль коррекции", "Плавный", "Плавный", "Агрессивный");

    private Vector2f rotationVector = new Vector2f(0, 0);
    @Getter
    private LivingEntity currentTarget;
    private Entity selectedEntity;

    private int rotationTicks = 0;
    private boolean isRotating;

    // Для снап ротации
    private float lastSnapYaw = 0;
    private float lastSnapPitch = 0;
    private int snapDelay = 0;
    private boolean wasSnapping = false;
    private int snapCounter = 0;
    private float[] snapHistory = new float[10];
    private int snapHistoryIndex = 0;
    private float antiAimOffset = 0f;

    // Для случайных отклонений в HVH
    private float randomDeviation = 0f;
    private int randomDeviationTimer = 0;

    // Таймеры для атаки
    private int attackTimer = 0;
    private boolean canPerformAttack = true;

    private final Random randomGenerator = new Random();
    private final Random snapRandom = new Random();

    public KillAura(AutoPotion autopotion) {
        addSettings(rotationType, attackRange, fov, targetSelection, advancedOptions, movementCorrection);
        addSettings(snapAccuracy, snapPrediction, predictionStrength, snapSilent, snapAntiAim, snapAntiAimAmount);
        addSettings(hvhRotationSpeed, hvhPitchSpeed, silentAim, randomization);
    }

    @Subscribe
    public void onInput(EventInput eventInput) {
        if (!isState() || currentTarget == null || mc.player == null) return;

        if (advancedOptions.getValueByName("Корректировка движения").get() && movementCorrection.is("Плавный")) {
            MoveUtils.fixMovement(eventInput, rotationVector.x);
        }
    }

    @Subscribe
    public void onUpdate(EventUpdate e) {
        if (!isState() || mc.player == null) return;

        // Обновление таймера атаки
        if (attackTimer > 0) {
            attackTimer--;
        } else {
            canPerformAttack = true;
        }

        // Обновление задержки снапа
        if (snapDelay > 0) {
            snapDelay--;
        }

        // Поиск новой цели
        if (advancedOptions.getValueByName("Фиксировать цель").get() && (currentTarget == null || !isValidTarget(currentTarget)) ||
                !advancedOptions.getValueByName("Фиксировать цель").get()) {
            findNewTarget();
        }

        // Обновление случайных отклонений
        if (randomDeviationTimer > 0) {
            randomDeviationTimer--;
        } else if (randomization.get() && (rotationType.is("HVH Плавная") || rotationType.is("HVH Снап"))) {
            randomDeviation = (float) ((randomGenerator.nextFloat() - 0.5) * 10f);
            randomDeviationTimer = 20 + randomGenerator.nextInt(20);
        }

        // Обновление противоаима для снапа
        if (snapAntiAim.get() && rotationType.is("Снап")) {
            antiAimOffset = (float) Math.sin(System.currentTimeMillis() / 200.0) * snapAntiAimAmount.get();
        } else {
            antiAimOffset = 0f;
        }

        if (currentTarget != null) {
            isRotating = false;

            // Обновление ротации в зависимости от выбранного типа
            if (!rotationType.is("Выключена")) {
                String currentRotationType = rotationType.get();
                switch (currentRotationType) {
                    case "Снап":
                        updateSnapRotation();
                        break;
                    case "HVH Плавная":
                        updateHvHSmoothRotation(false);
                        break;
                    case "HVH Снап":
                        updateHvHSnapRotation(false);
                        break;
                    case "Плавная":
                        if (!isRotating) {
                            updateSmoothRotation(false);
                        }
                        break;
                }
            }

            // Проверка условий для атаки
            if (canAttack() && canPerformAttack) {
                performAttack();
                rotationTicks = 2;
                attackTimer = 10;
                canPerformAttack = false;
            }
        } else {
            resetAll();
        }

        // Сохранение истории снапа
        if (rotationType.is("Снап")) {
            snapHistory[snapHistoryIndex] = rotationVector.x;
            snapHistoryIndex = (snapHistoryIndex + 1) % snapHistory.length;
        }
    }

    @Subscribe
    private void onWalking(EventMotion e) {
        if (!isState() || currentTarget == null) return;

        // Для скрытного наведения в HVH режимах и снап ротации
        boolean shouldBeSilent = (rotationType.is("HVH Плавная") || rotationType.is("HVH Снап")) && silentAim.get() ||
                rotationType.is("Снап") && snapSilent.get();

        if (shouldBeSilent) {
            return;
        }

        // Применение ротации
        if (!rotationType.is("Выключена")) {
            float yaw = rotationVector.x;
            float pitch = rotationVector.y;

            // Добавляем противоаим
            if (snapAntiAim.get() && rotationType.is("Снап")) {
                yaw += antiAimOffset;
            }

            e.setYaw(yaw);
            e.setPitch(pitch);
            mc.player.rotationYawHead = yaw;
            mc.player.renderYawOffset = yaw;
            mc.player.rotationPitchHead = pitch;
        }
    }

    private void findNewTarget() {
        if (mc.player == null || mc.world == null) return;

        List<LivingEntity> potentialTargets = new ArrayList<>();

        for (Entity entity : mc.world.getAllEntities()) {
            if (entity instanceof LivingEntity living && isValidTarget(living)) {
                if (isWithinFieldOfView(living)) {
                    potentialTargets.add(living);
                }
            }
        }

        if (potentialTargets.isEmpty()) {
            currentTarget = null;
            return;
        }

        // Сортировка по расстоянию
        potentialTargets.sort(Comparator.comparingDouble(entity -> mc.player.getDistance(entity)));

        currentTarget = potentialTargets.get(0);
    }

    private boolean isWithinFieldOfView(LivingEntity entity) {
        if (fov.get() >= 360f) return true;
        if (mc.player == null) return false;

        Vector3d directionVector = entity.getBoundingBox().getCenter()
                .subtract(mc.player.getEyePosition(1.0F));

        float targetYaw = (float) MathHelper.wrapDegrees(Math.toDegrees(Math.atan2(directionVector.z, directionVector.x)) - 90);
        float targetPitch = (float) (-Math.toDegrees(Math.atan2(directionVector.y, hypot(directionVector.x, directionVector.z))));

        float yawDifference = Math.abs(wrapDegrees(targetYaw - mc.player.rotationYaw));
        float pitchDifference = Math.abs(wrapDegrees(targetPitch - mc.player.rotationPitch));

        return yawDifference <= fov.get() / 2 && pitchDifference <= fov.get() / 2;
    }

    private Vector3d calculatePredictedPosition(LivingEntity target) {
        if (!snapPrediction.get() || target == null) {
            return target.getBoundingBox().getCenter();
        }

        Vector3d currentPos = target.getBoundingBox().getCenter();

        // Получаем вектор движения цели
        Vector3d motion = new Vector3d(
                target.getPosX() - target.prevPosX,
                target.getPosY() - target.prevPosY,
                target.getPosZ() - target.prevPosZ
        );

        // Рассчитываем время полета удара
        double distance = mc.player.getDistance(target);
        double timeToTarget = distance / 8.0; // Примерная скорость удара

        // Усиливаем предсказание
        timeToTarget *= predictionStrength.get();

        // Учитываем вертикальное движение
        if (!target.isOnGround()) {
            motion = motion.add(0, motion.y * 0.5, 0);
        }

        // Предсказанная позиция
        Vector3d predictedPos = currentPos.add(motion.scale(timeToTarget));

        // Минимальная коррекция для стоящих целей
        if (motion.length() < 0.05) {
            predictedPos = currentPos;
        }

        return predictedPos;
    }

    private Vector2f calculateSnapAngles(Vector3d targetPos) {
        if (mc.player == null) return new Vector2f(0, 0);

        Vector3d eyePos = mc.player.getEyePosition(1.0F);
        Vector3d diff = targetPos.subtract(eyePos);

        double diffX = diff.x;
        double diffY = diff.y;
        double diffZ = diff.z;
        double dist = Math.sqrt(diffX * diffX + diffZ * diffZ);

        float yaw = (float) Math.toDegrees(Math.atan2(diffZ, diffX)) - 90.0F;
        float pitch = (float) (-Math.toDegrees(Math.atan2(diffY, dist)));

        // Выбираем кратчайший путь поворота
        float currentYaw = rotationVector.x;
        float deltaYaw = wrapDegrees(yaw - currentYaw);

        if (Math.abs(deltaYaw) > 180) {
            deltaYaw = deltaYaw - Math.copySign(360, deltaYaw);
        }

        yaw = currentYaw + deltaYaw;

        // Ограничиваем угол наклона
        pitch = clamp(pitch, -89, 89);

        // Добавляем точность (случайное отклонение для натуральности)
        float accuracyFactor = 1.0f / snapAccuracy.get();
        if (accuracyFactor > 0.1f) {
            float randomYawOffset = (snapRandom.nextFloat() - 0.5f) * 2f * accuracyFactor;
            float randomPitchOffset = (snapRandom.nextFloat() - 0.5f) * accuracyFactor;

            yaw += randomYawOffset;
            pitch += randomPitchOffset;
        }

        return new Vector2f(wrapDegrees(yaw), pitch);
    }

    private void updateSnapRotation() {
        if (currentTarget == null || mc.player == null || snapDelay > 0) return;

        isRotating = true;

        // Получаем предсказанную позицию
        Vector3d targetPos = calculatePredictedPosition(currentTarget);

        // Рассчитываем углы снапа
        Vector2f snapAngles = calculateSnapAngles(targetPos);
        float targetYaw = snapAngles.x;
        float targetPitch = snapAngles.y;

        // Проверяем, нужно ли делать снап (слишком большой угол или опция "Снап при атаке")
        boolean shouldSnap = shouldPerformSnap(targetYaw, targetPitch);

        if (shouldSnap) {
            // Мгновенный снап
            performInstantSnap(targetYaw, targetPitch);
            snapCounter++;

            // Случайная задержка между снапами для натуральности
            if (snapCounter > 3) {
                snapDelay = 1 + snapRandom.nextInt(2);
                snapCounter = 0;
            }
        } else {
            // Плавный переход к цели
            performSmoothTransition(targetYaw, targetPitch);
        }

        // Корректировка движения
        if (advancedOptions.getValueByName("Корректировка движения").get() && !snapSilent.get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }

        // Сохраняем последние углы
        lastSnapYaw = targetYaw;
        lastSnapPitch = targetPitch;
        wasSnapping = shouldSnap;
    }

    private boolean shouldPerformSnap(float targetYaw, float targetPitch) {
        // Всегда делаем снап при атаке, если опция включена
        if (advancedOptions.getValueByName("Снап при атаке").get() &&
                advancedOptions.getValueByName("Ускорять при атаке").get() &&
                canPerformAttack) {
            return true;
        }

        // Проверяем угол отклонения
        float yawDiff = Math.abs(wrapDegrees(targetYaw - rotationVector.x));
        float pitchDiff = Math.abs(wrapDegrees(targetPitch - rotationVector.y));

        // Делаем снап при большом отклонении
        return yawDiff > 15f || pitchDiff > 8f;
    }

    private void performInstantSnap(float targetYaw, float targetPitch) {
        // Мгновенный снап с учетом GCD
        float newYaw = targetYaw;
        float newPitch = targetPitch;

        // Применяем коррекцию чувствительности
        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            float deltaYaw = newYaw - rotationVector.x;
            float deltaPitch = newPitch - rotationVector.y;

            deltaYaw -= deltaYaw % gcd;
            deltaPitch -= deltaPitch % gcd;

            newYaw = rotationVector.x + deltaYaw;
            newPitch = rotationVector.y + deltaPitch;
        }

        // Ограничиваем угол наклона
        newPitch = clamp(newPitch, -89, 89);

        rotationVector = new Vector2f(newYaw, newPitch);
    }

    private void performSmoothTransition(float targetYaw, float targetPitch) {
        // Плавный переход для небольших корректировок
        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // Медленная корректировка
        float yawStep = yawDiff * 0.3f;
        float pitchStep = pitchDiff * 0.2f;

        float newYaw = rotationVector.x + yawStep;
        float newPitch = clamp(rotationVector.y + pitchStep, -89, 89);

        // GCD коррекция
        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);
    }

    private void updateSmoothRotation(boolean isAttacking) {
        if (currentTarget == null || mc.player == null) return;

        isRotating = true;

        Vector3d targetPos = calculatePredictedPosition(currentTarget);
        Vector2f targetAngles = calculateSnapAngles(targetPos);

        float targetYaw = targetAngles.x;
        float targetPitch = clamp(targetAngles.y, -89, 89);

        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // Плавная интерполяция
        float smoothFactor = isAttacking ? 0.8f : 0.3f;
        float newYaw = rotationVector.x + yawDiff * smoothFactor;
        float newPitch = clamp(rotationVector.y + pitchDiff * smoothFactor, -89, 89);

        // Коррекция чувствительности
        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);

        if (advancedOptions.getValueByName("Корректировка движения").get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }
    }

    private void updateHvHSmoothRotation(boolean isAttacking) {
        if (currentTarget == null || mc.player == null) return;

        Vector3d targetPos = calculatePredictedPosition(currentTarget);
        Vector2f targetAngles = calculateSnapAngles(targetPos);

        float targetYaw = targetAngles.x;
        float targetPitch = clamp(targetAngles.y, -89, 89);

        // Добавление случайных отклонений
        if (randomization.get()) {
            targetYaw += randomDeviation;
            targetPitch += randomDeviation * 0.5f;
        }

        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // Плавная ротация с настройками HVH
        float yawStep = Math.min(Math.max(Math.abs(yawDiff), 1.0f), hvhRotationSpeed.get());
        float pitchStep = Math.min(Math.max(Math.abs(pitchDiff), 1.0f), hvhPitchSpeed.get());

        if (isAttacking && advancedOptions.getValueByName("Ускорять при атаке").get()) {
            yawStep *= 1.5f;
            pitchStep *= 1.5f;
        }

        float newYaw = rotationVector.x + (yawDiff > 0 ? yawStep : -yawStep);
        float newPitch = clamp(rotationVector.y + (pitchDiff > 0 ? pitchStep : -pitchStep), -89.0F, 89.0F);

        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);

        if (advancedOptions.getValueByName("Корректировка движения").get() && !silentAim.get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }
    }

    private void updateHvHSnapRotation(boolean isAttacking) {
        if (currentTarget == null || mc.player == null) return;

        Vector3d targetPos = calculatePredictedPosition(currentTarget);
        Vector2f targetAngles = calculateSnapAngles(targetPos);

        float targetYaw = targetAngles.x;
        float targetPitch = clamp(targetAngles.y, -89, 89);

        if (randomization.get()) {
            targetYaw += randomDeviation;
            targetPitch += randomDeviation * 0.5f;
        }

        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // HVH снап - быстрый но не мгновенный
        float maxYawChange = hvhRotationSpeed.get() * 3f;
        float maxPitchChange = hvhPitchSpeed.get() * 2f;

        float yawChange = Math.copySign(Math.min(Math.abs(yawDiff), maxYawChange), yawDiff);
        float pitchChange = Math.copySign(Math.min(Math.abs(pitchDiff), maxPitchChange), pitchDiff);

        // Ускорение при атаке
        if (isAttacking && advancedOptions.getValueByName("Ускорять при атаке").get()) {
            yawChange *= 1.8f;
            pitchChange *= 1.5f;
        }

        float newYaw = rotationVector.x + yawChange;
        float newPitch = clamp(rotationVector.y + pitchChange, -89.0F, 89.0F);

        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);

        if (advancedOptions.getValueByName("Корректировка движения").get() && !silentAim.get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }
    }

    private void performAttack() {
        if (currentTarget == null || mc.playerController == null || mc.player == null) return;

        // Проверка паузы при использовании предметов
        if (advancedOptions.getValueByName("Пауза при использовании предметов").get() && isUsingItem()) {
            return;
        }

        // Проверка наведения для ротации
        if (!rotationType.is("Выключена")) {
            selectedEntity = MouseUtil.getMouseOver(currentTarget, rotationVector.x, rotationVector.y, attackRange.get());

            if (advancedOptions.getValueByName("Ускорять при атаке").get()) {
                String currentRotationType = rotationType.get();
                switch (currentRotationType) {
                    case "Снап":
                        // Для снапа просто обновляем (уже мгновенный)
                        break;
                    case "HVH Плавная":
                        updateHvHSmoothRotation(true);
                        break;
                    case "HVH Снап":
                        updateHvHSnapRotation(true);
                        break;
                    case "Плавная":
                        updateSmoothRotation(true);
                        break;
                }
            }

            if ((selectedEntity == null || selectedEntity != currentTarget) && !mc.player.isElytraFlying()) {
                return;
            }
        } else {
            selectedEntity = MouseUtil.getMouseOver(currentTarget, mc.player.rotationYaw, mc.player.rotationPitch, attackRange.get());

            if ((selectedEntity == null || selectedEntity != currentTarget) && !mc.player.isElytraFlying()) {
                return;
            }
        }

        if (mc.player.isBlocking() && advancedOptions.getValueByName("Отжимать щиты").get()) {
            mc.playerController.onStoppedUsingItem(mc.player);
        }

        // Выполнение атаки
        try {
            mc.playerController.attackEntity(mc.player, currentTarget);
            mc.player.swingArm(Hand.MAIN_HAND);

            if (currentTarget instanceof PlayerEntity player && advancedOptions.getValueByName("Ломать щиты").get()) {
                performShieldBreak(player);
            }
        } catch (Exception e) {
            // Игнорирование ошибок атаки
        }
    }

    private boolean isUsingItem() {
        if (mc.player == null) return false;

        return mc.player.isHandActive() && mc.player.getActiveItemStack() != null &&
                (mc.player.getActiveItemStack().getItem().isFood() ||
                        mc.player.getActiveItemStack().getItem().isDrinkable());
    }

    private boolean canAttack() {
        // Проверка паузы при использовании предметов
        if (advancedOptions.getValueByName("Пауза при использовании предметов").get() && isUsingItem()) {
            return false;
        }

        if (advancedOptions.getValueByName("Только с критом").get()) {
            return !mc.player.isOnGround() && mc.player.fallDistance > 0;
        }

        return true;
    }

    private boolean isValidTarget(LivingEntity entity) {
        if (entity == null || entity instanceof ClientPlayerEntity) return false;
        if (mc.player == null) return false;

        if (entity.ticksExisted < 3) return false;
        if (mc.player.getDistance(entity) > attackRange.get()) return false;

        if (entity instanceof PlayerEntity p) {
            if (!targetSelection.getValueByName("Друзья").get() && FriendStorage.isFriend(p.getName().getString())) {
                return false;
            }
            if (p.getName().getString().equals(mc.player.getName().getString())) return false;
        }

        if (entity instanceof PlayerEntity) {
            if (!targetSelection.getValueByName("Игроки").get()) return false;
            if (entity.getTotalArmorValue() == 0 && !targetSelection.getValueByName("Без брони").get()) return false;
            if (entity.isInvisible() && entity.getTotalArmorValue() == 0 &&
                    !targetSelection.getValueByName("Невидимые без брони").get()) return false;
            if (entity.isInvisible() && !targetSelection.getValueByName("Невидимые").get()) return false;
        } else if (entity instanceof MonsterEntity && !targetSelection.getValueByName("Враждебные мобы").get()) {
            return false;
        } else if (entity instanceof AnimalEntity && !targetSelection.getValueByName("Мирные мобы").get()) {
            return false;
        }

        return !entity.isInvulnerable() && entity.isAlive() && !(entity instanceof ArmorStandEntity);
    }

    private void performShieldBreak(PlayerEntity targetPlayer) {
        if (!targetPlayer.isBlocking() || mc.playerController == null) return;

        int inventorySlot = InventoryUtil.getInstance().getAxeInInventory(false);
        int hotbarSlot = InventoryUtil.getInstance().getAxeInInventory(true);

        if (hotbarSlot == -1 && inventorySlot != -1) {
            int bestHotbarSlot = InventoryUtil.getInstance().findBestSlotInHotBar();
            if (bestHotbarSlot == -1) return;

            try {
                mc.playerController.windowClick(0, inventorySlot, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(0, bestHotbarSlot + 36, 0, ClickType.PICKUP, mc.player);

                mc.player.connection.sendPacket(new CHeldItemChangePacket(bestHotbarSlot));
                mc.playerController.attackEntity(mc.player, targetPlayer);
                mc.player.swingArm(Hand.MAIN_HAND);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(mc.player.inventory.currentItem));

                mc.playerController.windowClick(0, bestHotbarSlot + 36, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(0, inventorySlot, 0, ClickType.PICKUP, mc.player);
            } catch (Exception e) {
                // Игнорирование ошибок
            }
        }

        if (hotbarSlot != -1) {
            try {
                mc.player.connection.sendPacket(new CHeldItemChangePacket(hotbarSlot));
                mc.playerController.attackEntity(mc.player, targetPlayer);
                mc.player.swingArm(Hand.MAIN_HAND);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(mc.player.inventory.currentItem));
            } catch (Exception e) {
                // Игнорирование ошибок
            }
        }
    }

    private void resetAll() {
        if (mc.player != null) {
            if (advancedOptions.getValueByName("Корректировка движения").get()) {
                mc.player.rotationYawOffset = Integer.MIN_VALUE;
            }
            rotationVector = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
        }
        randomDeviation = 0f;
        randomDeviationTimer = 0;
        attackTimer = 0;
        canPerformAttack = true;
        currentTarget = null;
        selectedEntity = null;
        isRotating = false;
        rotationTicks = 0;

        // Сброс данных снап ротации
        lastSnapYaw = 0;
        lastSnapPitch = 0;
        snapDelay = 0;
        wasSnapping = false;
        snapCounter = 0;
        snapHistory = new float[10];
        snapHistoryIndex = 0;
        antiAimOffset = 0f;
    }

    @Override
    public void onEnable() {
        super.onEnable();
        resetAll();
    }

    @Override
    public void onDisable() {
        super.onDisable();
        resetAll();
    }

    // Методы для расчета характеристик цели
    private double calculateArmorValue(PlayerEntity player) {
        double armorTotal = 0.0;
        for (int i = 0; i < 4; ++i) {
            ItemStack armorPiece = player.inventory.armorInventory.get(i);
            if (!(armorPiece.getItem() instanceof ArmorItem)) continue;
            armorTotal += getArmorProtectionValue(armorPiece);
        }
        return armorTotal;
    }

    private double getArmorProtectionValue(ItemStack armorStack) {
        if (armorStack.getItem() instanceof ArmorItem armorItem) {
            double baseProtection = armorItem.getDamageReduceAmount();
            if (armorStack.isEnchanted()) {
                baseProtection += (double) EnchantmentHelper.getEnchantmentLevel(Enchantments.PROTECTION, armorStack) * 0.25;
            }
            return baseProtection;
        }
        return 0;
    }

    private double calculateEffectiveHealth(LivingEntity entity) {
        if (entity instanceof PlayerEntity player) {
            return (double) (player.getHealth() + player.getAbsorptionAmount()) * (calculateArmorValue(player) / 20.0);
        }
        return entity.getHealth() + entity.getAbsorptionAmount();
    }

    public LivingEntity getTarget() {
        return null;
    }
}
 
новая селфкод килка для топовых пастеров нафик кто понил тот понял спасиба маему кинту Хз М. за что что предоставил свою топовую килку
вот код
Код:
Expand Collapse Copy
package im.expensive.functions.impl.combat;

import com.google.common.eventbus.Subscribe;
import im.expensive.command.friends.FriendStorage;
import im.expensive.events.EventInput;
import im.expensive.events.EventMotion;
import im.expensive.events.EventUpdate;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.functions.settings.impl.BooleanSetting;
import im.expensive.functions.settings.impl.ModeListSetting;
import im.expensive.functions.settings.impl.ModeSetting;
import im.expensive.functions.settings.impl.SliderSetting;
import im.expensive.utils.math.SensUtils;
import im.expensive.utils.player.InventoryUtil;
import im.expensive.utils.player.MouseUtil;
import im.expensive.utils.player.MoveUtils;
import lombok.Getter;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ArmorStandEntity;
import net.minecraft.entity.monster.MonsterEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.ClickType;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.CHeldItemChangePacket;
import net.minecraft.util.Hand;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Random;

import static java.lang.Math.hypot;
import static net.minecraft.util.math.MathHelper.clamp;
import static net.minecraft.util.math.MathHelper.wrapDegrees;

@FunctionRegister(name = "KillAura", type = Category.Combat)
public class KillAura extends Function {
    @Getter
    private final ModeSetting rotationType = new ModeSetting("Тип ротации", "Выключена", "Выключена", "Плавная", "Снап", "HVH Плавная", "HVH Снап");

    // Основные настройки
    private final SliderSetting attackRange = new SliderSetting("Дальность атаки", 3.2f, 3f, 6f, 0.1f);
    private final SliderSetting fov = new SliderSetting("Поле зрения", 180f, 30f, 360f, 1f);

    // Настройки для снап ротации (мгновенная)
    private final SliderSetting snapAccuracy = new SliderSetting("Точность снапа", 1.0f, 0.5f, 5f, 0.1f);
    private final BooleanSetting snapPrediction = new BooleanSetting("Предсказание траектории", true);
    private final SliderSetting predictionStrength = new SliderSetting("Сила предсказания", 1.5f, 0.5f, 3f, 0.1f);
    private final BooleanSetting snapSilent = new BooleanSetting("Скрытный снап", false);
    private final BooleanSetting snapAntiAim = new BooleanSetting("Противоаим", false);
    private final SliderSetting snapAntiAimAmount = new SliderSetting("Сила противоаима", 5f, 1f, 15f, 0.5f);

    // Настройки для HVH ротаций
    private final SliderSetting hvhRotationSpeed = new SliderSetting("Скорость плавного поворота", 60f, 10f, 360f, 1f);
    private final SliderSetting hvhPitchSpeed = new SliderSetting("Скорость плавного наклона", 40f, 10f, 180f, 1f);
    private final BooleanSetting silentAim = new BooleanSetting("Скрытное наведение", false);
    private final BooleanSetting randomization = new BooleanSetting("Случайные отклонения", false);

    final ModeListSetting targetSelection = new ModeListSetting("Выбор целей",
            new BooleanSetting("Игроки", true),
            new BooleanSetting("Без брони", true),
            new BooleanSetting("Враждебные мобы", false),
            new BooleanSetting("Мирные мобы", false),
            new BooleanSetting("Друзья", false),
            new BooleanSetting("Невидимые без брони", true),
            new BooleanSetting("Невидимые", true));

    @Getter
    final ModeListSetting advancedOptions = new ModeListSetting("Дополнительно",
            new BooleanSetting("Только с критом", false),
            new BooleanSetting("Ломать щиты", true),
            new BooleanSetting("Отжимать щиты", true),
            new BooleanSetting("Ускорять при атаке", true),
            new BooleanSetting("Синхронизация с TPS", false),
            new BooleanSetting("Фиксировать цель", true),
            new BooleanSetting("Корректировка движения", true),
            new BooleanSetting("Пауза при использовании предметов", true),
            new BooleanSetting("Снап при атаке", true));

    final ModeSetting movementCorrection = new ModeSetting("Стиль коррекции", "Плавный", "Плавный", "Агрессивный");

    private Vector2f rotationVector = new Vector2f(0, 0);
    @Getter
    private LivingEntity currentTarget;
    private Entity selectedEntity;

    private int rotationTicks = 0;
    private boolean isRotating;

    // Для снап ротации
    private float lastSnapYaw = 0;
    private float lastSnapPitch = 0;
    private int snapDelay = 0;
    private boolean wasSnapping = false;
    private int snapCounter = 0;
    private float[] snapHistory = new float[10];
    private int snapHistoryIndex = 0;
    private float antiAimOffset = 0f;

    // Для случайных отклонений в HVH
    private float randomDeviation = 0f;
    private int randomDeviationTimer = 0;

    // Таймеры для атаки
    private int attackTimer = 0;
    private boolean canPerformAttack = true;

    private final Random randomGenerator = new Random();
    private final Random snapRandom = new Random();

    public KillAura(AutoPotion autopotion) {
        addSettings(rotationType, attackRange, fov, targetSelection, advancedOptions, movementCorrection);
        addSettings(snapAccuracy, snapPrediction, predictionStrength, snapSilent, snapAntiAim, snapAntiAimAmount);
        addSettings(hvhRotationSpeed, hvhPitchSpeed, silentAim, randomization);
    }

    @Subscribe
    public void onInput(EventInput eventInput) {
        if (!isState() || currentTarget == null || mc.player == null) return;

        if (advancedOptions.getValueByName("Корректировка движения").get() && movementCorrection.is("Плавный")) {
            MoveUtils.fixMovement(eventInput, rotationVector.x);
        }
    }

    @Subscribe
    public void onUpdate(EventUpdate e) {
        if (!isState() || mc.player == null) return;

        // Обновление таймера атаки
        if (attackTimer > 0) {
            attackTimer--;
        } else {
            canPerformAttack = true;
        }

        // Обновление задержки снапа
        if (snapDelay > 0) {
            snapDelay--;
        }

        // Поиск новой цели
        if (advancedOptions.getValueByName("Фиксировать цель").get() && (currentTarget == null || !isValidTarget(currentTarget)) ||
                !advancedOptions.getValueByName("Фиксировать цель").get()) {
            findNewTarget();
        }

        // Обновление случайных отклонений
        if (randomDeviationTimer > 0) {
            randomDeviationTimer--;
        } else if (randomization.get() && (rotationType.is("HVH Плавная") || rotationType.is("HVH Снап"))) {
            randomDeviation = (float) ((randomGenerator.nextFloat() - 0.5) * 10f);
            randomDeviationTimer = 20 + randomGenerator.nextInt(20);
        }

        // Обновление противоаима для снапа
        if (snapAntiAim.get() && rotationType.is("Снап")) {
            antiAimOffset = (float) Math.sin(System.currentTimeMillis() / 200.0) * snapAntiAimAmount.get();
        } else {
            antiAimOffset = 0f;
        }

        if (currentTarget != null) {
            isRotating = false;

            // Обновление ротации в зависимости от выбранного типа
            if (!rotationType.is("Выключена")) {
                String currentRotationType = rotationType.get();
                switch (currentRotationType) {
                    case "Снап":
                        updateSnapRotation();
                        break;
                    case "HVH Плавная":
                        updateHvHSmoothRotation(false);
                        break;
                    case "HVH Снап":
                        updateHvHSnapRotation(false);
                        break;
                    case "Плавная":
                        if (!isRotating) {
                            updateSmoothRotation(false);
                        }
                        break;
                }
            }

            // Проверка условий для атаки
            if (canAttack() && canPerformAttack) {
                performAttack();
                rotationTicks = 2;
                attackTimer = 10;
                canPerformAttack = false;
            }
        } else {
            resetAll();
        }

        // Сохранение истории снапа
        if (rotationType.is("Снап")) {
            snapHistory[snapHistoryIndex] = rotationVector.x;
            snapHistoryIndex = (snapHistoryIndex + 1) % snapHistory.length;
        }
    }

    @Subscribe
    private void onWalking(EventMotion e) {
        if (!isState() || currentTarget == null) return;

        // Для скрытного наведения в HVH режимах и снап ротации
        boolean shouldBeSilent = (rotationType.is("HVH Плавная") || rotationType.is("HVH Снап")) && silentAim.get() ||
                rotationType.is("Снап") && snapSilent.get();

        if (shouldBeSilent) {
            return;
        }

        // Применение ротации
        if (!rotationType.is("Выключена")) {
            float yaw = rotationVector.x;
            float pitch = rotationVector.y;

            // Добавляем противоаим
            if (snapAntiAim.get() && rotationType.is("Снап")) {
                yaw += antiAimOffset;
            }

            e.setYaw(yaw);
            e.setPitch(pitch);
            mc.player.rotationYawHead = yaw;
            mc.player.renderYawOffset = yaw;
            mc.player.rotationPitchHead = pitch;
        }
    }

    private void findNewTarget() {
        if (mc.player == null || mc.world == null) return;

        List<LivingEntity> potentialTargets = new ArrayList<>();

        for (Entity entity : mc.world.getAllEntities()) {
            if (entity instanceof LivingEntity living && isValidTarget(living)) {
                if (isWithinFieldOfView(living)) {
                    potentialTargets.add(living);
                }
            }
        }

        if (potentialTargets.isEmpty()) {
            currentTarget = null;
            return;
        }

        // Сортировка по расстоянию
        potentialTargets.sort(Comparator.comparingDouble(entity -> mc.player.getDistance(entity)));

        currentTarget = potentialTargets.get(0);
    }

    private boolean isWithinFieldOfView(LivingEntity entity) {
        if (fov.get() >= 360f) return true;
        if (mc.player == null) return false;

        Vector3d directionVector = entity.getBoundingBox().getCenter()
                .subtract(mc.player.getEyePosition(1.0F));

        float targetYaw = (float) MathHelper.wrapDegrees(Math.toDegrees(Math.atan2(directionVector.z, directionVector.x)) - 90);
        float targetPitch = (float) (-Math.toDegrees(Math.atan2(directionVector.y, hypot(directionVector.x, directionVector.z))));

        float yawDifference = Math.abs(wrapDegrees(targetYaw - mc.player.rotationYaw));
        float pitchDifference = Math.abs(wrapDegrees(targetPitch - mc.player.rotationPitch));

        return yawDifference <= fov.get() / 2 && pitchDifference <= fov.get() / 2;
    }

    private Vector3d calculatePredictedPosition(LivingEntity target) {
        if (!snapPrediction.get() || target == null) {
            return target.getBoundingBox().getCenter();
        }

        Vector3d currentPos = target.getBoundingBox().getCenter();

        // Получаем вектор движения цели
        Vector3d motion = new Vector3d(
                target.getPosX() - target.prevPosX,
                target.getPosY() - target.prevPosY,
                target.getPosZ() - target.prevPosZ
        );

        // Рассчитываем время полета удара
        double distance = mc.player.getDistance(target);
        double timeToTarget = distance / 8.0; // Примерная скорость удара

        // Усиливаем предсказание
        timeToTarget *= predictionStrength.get();

        // Учитываем вертикальное движение
        if (!target.isOnGround()) {
            motion = motion.add(0, motion.y * 0.5, 0);
        }

        // Предсказанная позиция
        Vector3d predictedPos = currentPos.add(motion.scale(timeToTarget));

        // Минимальная коррекция для стоящих целей
        if (motion.length() < 0.05) {
            predictedPos = currentPos;
        }

        return predictedPos;
    }

    private Vector2f calculateSnapAngles(Vector3d targetPos) {
        if (mc.player == null) return new Vector2f(0, 0);

        Vector3d eyePos = mc.player.getEyePosition(1.0F);
        Vector3d diff = targetPos.subtract(eyePos);

        double diffX = diff.x;
        double diffY = diff.y;
        double diffZ = diff.z;
        double dist = Math.sqrt(diffX * diffX + diffZ * diffZ);

        float yaw = (float) Math.toDegrees(Math.atan2(diffZ, diffX)) - 90.0F;
        float pitch = (float) (-Math.toDegrees(Math.atan2(diffY, dist)));

        // Выбираем кратчайший путь поворота
        float currentYaw = rotationVector.x;
        float deltaYaw = wrapDegrees(yaw - currentYaw);

        if (Math.abs(deltaYaw) > 180) {
            deltaYaw = deltaYaw - Math.copySign(360, deltaYaw);
        }

        yaw = currentYaw + deltaYaw;

        // Ограничиваем угол наклона
        pitch = clamp(pitch, -89, 89);

        // Добавляем точность (случайное отклонение для натуральности)
        float accuracyFactor = 1.0f / snapAccuracy.get();
        if (accuracyFactor > 0.1f) {
            float randomYawOffset = (snapRandom.nextFloat() - 0.5f) * 2f * accuracyFactor;
            float randomPitchOffset = (snapRandom.nextFloat() - 0.5f) * accuracyFactor;

            yaw += randomYawOffset;
            pitch += randomPitchOffset;
        }

        return new Vector2f(wrapDegrees(yaw), pitch);
    }

    private void updateSnapRotation() {
        if (currentTarget == null || mc.player == null || snapDelay > 0) return;

        isRotating = true;

        // Получаем предсказанную позицию
        Vector3d targetPos = calculatePredictedPosition(currentTarget);

        // Рассчитываем углы снапа
        Vector2f snapAngles = calculateSnapAngles(targetPos);
        float targetYaw = snapAngles.x;
        float targetPitch = snapAngles.y;

        // Проверяем, нужно ли делать снап (слишком большой угол или опция "Снап при атаке")
        boolean shouldSnap = shouldPerformSnap(targetYaw, targetPitch);

        if (shouldSnap) {
            // Мгновенный снап
            performInstantSnap(targetYaw, targetPitch);
            snapCounter++;

            // Случайная задержка между снапами для натуральности
            if (snapCounter > 3) {
                snapDelay = 1 + snapRandom.nextInt(2);
                snapCounter = 0;
            }
        } else {
            // Плавный переход к цели
            performSmoothTransition(targetYaw, targetPitch);
        }

        // Корректировка движения
        if (advancedOptions.getValueByName("Корректировка движения").get() && !snapSilent.get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }

        // Сохраняем последние углы
        lastSnapYaw = targetYaw;
        lastSnapPitch = targetPitch;
        wasSnapping = shouldSnap;
    }

    private boolean shouldPerformSnap(float targetYaw, float targetPitch) {
        // Всегда делаем снап при атаке, если опция включена
        if (advancedOptions.getValueByName("Снап при атаке").get() &&
                advancedOptions.getValueByName("Ускорять при атаке").get() &&
                canPerformAttack) {
            return true;
        }

        // Проверяем угол отклонения
        float yawDiff = Math.abs(wrapDegrees(targetYaw - rotationVector.x));
        float pitchDiff = Math.abs(wrapDegrees(targetPitch - rotationVector.y));

        // Делаем снап при большом отклонении
        return yawDiff > 15f || pitchDiff > 8f;
    }

    private void performInstantSnap(float targetYaw, float targetPitch) {
        // Мгновенный снап с учетом GCD
        float newYaw = targetYaw;
        float newPitch = targetPitch;

        // Применяем коррекцию чувствительности
        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            float deltaYaw = newYaw - rotationVector.x;
            float deltaPitch = newPitch - rotationVector.y;

            deltaYaw -= deltaYaw % gcd;
            deltaPitch -= deltaPitch % gcd;

            newYaw = rotationVector.x + deltaYaw;
            newPitch = rotationVector.y + deltaPitch;
        }

        // Ограничиваем угол наклона
        newPitch = clamp(newPitch, -89, 89);

        rotationVector = new Vector2f(newYaw, newPitch);
    }

    private void performSmoothTransition(float targetYaw, float targetPitch) {
        // Плавный переход для небольших корректировок
        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // Медленная корректировка
        float yawStep = yawDiff * 0.3f;
        float pitchStep = pitchDiff * 0.2f;

        float newYaw = rotationVector.x + yawStep;
        float newPitch = clamp(rotationVector.y + pitchStep, -89, 89);

        // GCD коррекция
        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);
    }

    private void updateSmoothRotation(boolean isAttacking) {
        if (currentTarget == null || mc.player == null) return;

        isRotating = true;

        Vector3d targetPos = calculatePredictedPosition(currentTarget);
        Vector2f targetAngles = calculateSnapAngles(targetPos);

        float targetYaw = targetAngles.x;
        float targetPitch = clamp(targetAngles.y, -89, 89);

        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // Плавная интерполяция
        float smoothFactor = isAttacking ? 0.8f : 0.3f;
        float newYaw = rotationVector.x + yawDiff * smoothFactor;
        float newPitch = clamp(rotationVector.y + pitchDiff * smoothFactor, -89, 89);

        // Коррекция чувствительности
        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);

        if (advancedOptions.getValueByName("Корректировка движения").get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }
    }

    private void updateHvHSmoothRotation(boolean isAttacking) {
        if (currentTarget == null || mc.player == null) return;

        Vector3d targetPos = calculatePredictedPosition(currentTarget);
        Vector2f targetAngles = calculateSnapAngles(targetPos);

        float targetYaw = targetAngles.x;
        float targetPitch = clamp(targetAngles.y, -89, 89);

        // Добавление случайных отклонений
        if (randomization.get()) {
            targetYaw += randomDeviation;
            targetPitch += randomDeviation * 0.5f;
        }

        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // Плавная ротация с настройками HVH
        float yawStep = Math.min(Math.max(Math.abs(yawDiff), 1.0f), hvhRotationSpeed.get());
        float pitchStep = Math.min(Math.max(Math.abs(pitchDiff), 1.0f), hvhPitchSpeed.get());

        if (isAttacking && advancedOptions.getValueByName("Ускорять при атаке").get()) {
            yawStep *= 1.5f;
            pitchStep *= 1.5f;
        }

        float newYaw = rotationVector.x + (yawDiff > 0 ? yawStep : -yawStep);
        float newPitch = clamp(rotationVector.y + (pitchDiff > 0 ? pitchStep : -pitchStep), -89.0F, 89.0F);

        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);

        if (advancedOptions.getValueByName("Корректировка движения").get() && !silentAim.get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }
    }

    private void updateHvHSnapRotation(boolean isAttacking) {
        if (currentTarget == null || mc.player == null) return;

        Vector3d targetPos = calculatePredictedPosition(currentTarget);
        Vector2f targetAngles = calculateSnapAngles(targetPos);

        float targetYaw = targetAngles.x;
        float targetPitch = clamp(targetAngles.y, -89, 89);

        if (randomization.get()) {
            targetYaw += randomDeviation;
            targetPitch += randomDeviation * 0.5f;
        }

        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // HVH снап - быстрый но не мгновенный
        float maxYawChange = hvhRotationSpeed.get() * 3f;
        float maxPitchChange = hvhPitchSpeed.get() * 2f;

        float yawChange = Math.copySign(Math.min(Math.abs(yawDiff), maxYawChange), yawDiff);
        float pitchChange = Math.copySign(Math.min(Math.abs(pitchDiff), maxPitchChange), pitchDiff);

        // Ускорение при атаке
        if (isAttacking && advancedOptions.getValueByName("Ускорять при атаке").get()) {
            yawChange *= 1.8f;
            pitchChange *= 1.5f;
        }

        float newYaw = rotationVector.x + yawChange;
        float newPitch = clamp(rotationVector.y + pitchChange, -89.0F, 89.0F);

        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);

        if (advancedOptions.getValueByName("Корректировка движения").get() && !silentAim.get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }
    }

    private void performAttack() {
        if (currentTarget == null || mc.playerController == null || mc.player == null) return;

        // Проверка паузы при использовании предметов
        if (advancedOptions.getValueByName("Пауза при использовании предметов").get() && isUsingItem()) {
            return;
        }

        // Проверка наведения для ротации
        if (!rotationType.is("Выключена")) {
            selectedEntity = MouseUtil.getMouseOver(currentTarget, rotationVector.x, rotationVector.y, attackRange.get());

            if (advancedOptions.getValueByName("Ускорять при атаке").get()) {
                String currentRotationType = rotationType.get();
                switch (currentRotationType) {
                    case "Снап":
                        // Для снапа просто обновляем (уже мгновенный)
                        break;
                    case "HVH Плавная":
                        updateHvHSmoothRotation(true);
                        break;
                    case "HVH Снап":
                        updateHvHSnapRotation(true);
                        break;
                    case "Плавная":
                        updateSmoothRotation(true);
                        break;
                }
            }

            if ((selectedEntity == null || selectedEntity != currentTarget) && !mc.player.isElytraFlying()) {
                return;
            }
        } else {
            selectedEntity = MouseUtil.getMouseOver(currentTarget, mc.player.rotationYaw, mc.player.rotationPitch, attackRange.get());

            if ((selectedEntity == null || selectedEntity != currentTarget) && !mc.player.isElytraFlying()) {
                return;
            }
        }

        if (mc.player.isBlocking() && advancedOptions.getValueByName("Отжимать щиты").get()) {
            mc.playerController.onStoppedUsingItem(mc.player);
        }

        // Выполнение атаки
        try {
            mc.playerController.attackEntity(mc.player, currentTarget);
            mc.player.swingArm(Hand.MAIN_HAND);

            if (currentTarget instanceof PlayerEntity player && advancedOptions.getValueByName("Ломать щиты").get()) {
                performShieldBreak(player);
            }
        } catch (Exception e) {
            // Игнорирование ошибок атаки
        }
    }

    private boolean isUsingItem() {
        if (mc.player == null) return false;

        return mc.player.isHandActive() && mc.player.getActiveItemStack() != null &&
                (mc.player.getActiveItemStack().getItem().isFood() ||
                        mc.player.getActiveItemStack().getItem().isDrinkable());
    }

    private boolean canAttack() {
        // Проверка паузы при использовании предметов
        if (advancedOptions.getValueByName("Пауза при использовании предметов").get() && isUsingItem()) {
            return false;
        }

        if (advancedOptions.getValueByName("Только с критом").get()) {
            return !mc.player.isOnGround() && mc.player.fallDistance > 0;
        }

        return true;
    }

    private boolean isValidTarget(LivingEntity entity) {
        if (entity == null || entity instanceof ClientPlayerEntity) return false;
        if (mc.player == null) return false;

        if (entity.ticksExisted < 3) return false;
        if (mc.player.getDistance(entity) > attackRange.get()) return false;

        if (entity instanceof PlayerEntity p) {
            if (!targetSelection.getValueByName("Друзья").get() && FriendStorage.isFriend(p.getName().getString())) {
                return false;
            }
            if (p.getName().getString().equals(mc.player.getName().getString())) return false;
        }

        if (entity instanceof PlayerEntity) {
            if (!targetSelection.getValueByName("Игроки").get()) return false;
            if (entity.getTotalArmorValue() == 0 && !targetSelection.getValueByName("Без брони").get()) return false;
            if (entity.isInvisible() && entity.getTotalArmorValue() == 0 &&
                    !targetSelection.getValueByName("Невидимые без брони").get()) return false;
            if (entity.isInvisible() && !targetSelection.getValueByName("Невидимые").get()) return false;
        } else if (entity instanceof MonsterEntity && !targetSelection.getValueByName("Враждебные мобы").get()) {
            return false;
        } else if (entity instanceof AnimalEntity && !targetSelection.getValueByName("Мирные мобы").get()) {
            return false;
        }

        return !entity.isInvulnerable() && entity.isAlive() && !(entity instanceof ArmorStandEntity);
    }

    private void performShieldBreak(PlayerEntity targetPlayer) {
        if (!targetPlayer.isBlocking() || mc.playerController == null) return;

        int inventorySlot = InventoryUtil.getInstance().getAxeInInventory(false);
        int hotbarSlot = InventoryUtil.getInstance().getAxeInInventory(true);

        if (hotbarSlot == -1 && inventorySlot != -1) {
            int bestHotbarSlot = InventoryUtil.getInstance().findBestSlotInHotBar();
            if (bestHotbarSlot == -1) return;

            try {
                mc.playerController.windowClick(0, inventorySlot, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(0, bestHotbarSlot + 36, 0, ClickType.PICKUP, mc.player);

                mc.player.connection.sendPacket(new CHeldItemChangePacket(bestHotbarSlot));
                mc.playerController.attackEntity(mc.player, targetPlayer);
                mc.player.swingArm(Hand.MAIN_HAND);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(mc.player.inventory.currentItem));

                mc.playerController.windowClick(0, bestHotbarSlot + 36, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(0, inventorySlot, 0, ClickType.PICKUP, mc.player);
            } catch (Exception e) {
                // Игнорирование ошибок
            }
        }

        if (hotbarSlot != -1) {
            try {
                mc.player.connection.sendPacket(new CHeldItemChangePacket(hotbarSlot));
                mc.playerController.attackEntity(mc.player, targetPlayer);
                mc.player.swingArm(Hand.MAIN_HAND);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(mc.player.inventory.currentItem));
            } catch (Exception e) {
                // Игнорирование ошибок
            }
        }
    }

    private void resetAll() {
        if (mc.player != null) {
            if (advancedOptions.getValueByName("Корректировка движения").get()) {
                mc.player.rotationYawOffset = Integer.MIN_VALUE;
            }
            rotationVector = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
        }
        randomDeviation = 0f;
        randomDeviationTimer = 0;
        attackTimer = 0;
        canPerformAttack = true;
        currentTarget = null;
        selectedEntity = null;
        isRotating = false;
        rotationTicks = 0;

        // Сброс данных снап ротации
        lastSnapYaw = 0;
        lastSnapPitch = 0;
        snapDelay = 0;
        wasSnapping = false;
        snapCounter = 0;
        snapHistory = new float[10];
        snapHistoryIndex = 0;
        antiAimOffset = 0f;
    }

    @Override
    public void onEnable() {
        super.onEnable();
        resetAll();
    }

    @Override
    public void onDisable() {
        super.onDisable();
        resetAll();
    }

    // Методы для расчета характеристик цели
    private double calculateArmorValue(PlayerEntity player) {
        double armorTotal = 0.0;
        for (int i = 0; i < 4; ++i) {
            ItemStack armorPiece = player.inventory.armorInventory.get(i);
            if (!(armorPiece.getItem() instanceof ArmorItem)) continue;
            armorTotal += getArmorProtectionValue(armorPiece);
        }
        return armorTotal;
    }

    private double getArmorProtectionValue(ItemStack armorStack) {
        if (armorStack.getItem() instanceof ArmorItem armorItem) {
            double baseProtection = armorItem.getDamageReduceAmount();
            if (armorStack.isEnchanted()) {
                baseProtection += (double) EnchantmentHelper.getEnchantmentLevel(Enchantments.PROTECTION, armorStack) * 0.25;
            }
            return baseProtection;
        }
        return 0;
    }

    private double calculateEffectiveHealth(LivingEntity entity) {
        if (entity instanceof PlayerEntity player) {
            return (double) (player.getHealth() + player.getAbsorptionAmount()) * (calculateArmorValue(player) / 20.0);
        }
        return entity.getHealth() + entity.getAbsorptionAmount();
    }

    public LivingEntity getTarget() {
        return null;
    }
}
и что ЭТО обходит
 
новая селфкод килка для топовых пастеров нафик кто понил тот понял спасиба маему кинту Хз М. за что что предоставил свою топовую килку
вот код
Код:
Expand Collapse Copy
package im.expensive.functions.impl.combat;

import com.google.common.eventbus.Subscribe;
import im.expensive.command.friends.FriendStorage;
import im.expensive.events.EventInput;
import im.expensive.events.EventMotion;
import im.expensive.events.EventUpdate;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.functions.settings.impl.BooleanSetting;
import im.expensive.functions.settings.impl.ModeListSetting;
import im.expensive.functions.settings.impl.ModeSetting;
import im.expensive.functions.settings.impl.SliderSetting;
import im.expensive.utils.math.SensUtils;
import im.expensive.utils.player.InventoryUtil;
import im.expensive.utils.player.MouseUtil;
import im.expensive.utils.player.MoveUtils;
import lombok.Getter;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ArmorStandEntity;
import net.minecraft.entity.monster.MonsterEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.ClickType;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.CHeldItemChangePacket;
import net.minecraft.util.Hand;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Random;

import static java.lang.Math.hypot;
import static net.minecraft.util.math.MathHelper.clamp;
import static net.minecraft.util.math.MathHelper.wrapDegrees;

@FunctionRegister(name = "KillAura", type = Category.Combat)
public class KillAura extends Function {
    @Getter
    private final ModeSetting rotationType = new ModeSetting("Тип ротации", "Выключена", "Выключена", "Плавная", "Снап", "HVH Плавная", "HVH Снап");

    // Основные настройки
    private final SliderSetting attackRange = new SliderSetting("Дальность атаки", 3.2f, 3f, 6f, 0.1f);
    private final SliderSetting fov = new SliderSetting("Поле зрения", 180f, 30f, 360f, 1f);

    // Настройки для снап ротации (мгновенная)
    private final SliderSetting snapAccuracy = new SliderSetting("Точность снапа", 1.0f, 0.5f, 5f, 0.1f);
    private final BooleanSetting snapPrediction = new BooleanSetting("Предсказание траектории", true);
    private final SliderSetting predictionStrength = new SliderSetting("Сила предсказания", 1.5f, 0.5f, 3f, 0.1f);
    private final BooleanSetting snapSilent = new BooleanSetting("Скрытный снап", false);
    private final BooleanSetting snapAntiAim = new BooleanSetting("Противоаим", false);
    private final SliderSetting snapAntiAimAmount = new SliderSetting("Сила противоаима", 5f, 1f, 15f, 0.5f);

    // Настройки для HVH ротаций
    private final SliderSetting hvhRotationSpeed = new SliderSetting("Скорость плавного поворота", 60f, 10f, 360f, 1f);
    private final SliderSetting hvhPitchSpeed = new SliderSetting("Скорость плавного наклона", 40f, 10f, 180f, 1f);
    private final BooleanSetting silentAim = new BooleanSetting("Скрытное наведение", false);
    private final BooleanSetting randomization = new BooleanSetting("Случайные отклонения", false);

    final ModeListSetting targetSelection = new ModeListSetting("Выбор целей",
            new BooleanSetting("Игроки", true),
            new BooleanSetting("Без брони", true),
            new BooleanSetting("Враждебные мобы", false),
            new BooleanSetting("Мирные мобы", false),
            new BooleanSetting("Друзья", false),
            new BooleanSetting("Невидимые без брони", true),
            new BooleanSetting("Невидимые", true));

    @Getter
    final ModeListSetting advancedOptions = new ModeListSetting("Дополнительно",
            new BooleanSetting("Только с критом", false),
            new BooleanSetting("Ломать щиты", true),
            new BooleanSetting("Отжимать щиты", true),
            new BooleanSetting("Ускорять при атаке", true),
            new BooleanSetting("Синхронизация с TPS", false),
            new BooleanSetting("Фиксировать цель", true),
            new BooleanSetting("Корректировка движения", true),
            new BooleanSetting("Пауза при использовании предметов", true),
            new BooleanSetting("Снап при атаке", true));

    final ModeSetting movementCorrection = new ModeSetting("Стиль коррекции", "Плавный", "Плавный", "Агрессивный");

    private Vector2f rotationVector = new Vector2f(0, 0);
    @Getter
    private LivingEntity currentTarget;
    private Entity selectedEntity;

    private int rotationTicks = 0;
    private boolean isRotating;

    // Для снап ротации
    private float lastSnapYaw = 0;
    private float lastSnapPitch = 0;
    private int snapDelay = 0;
    private boolean wasSnapping = false;
    private int snapCounter = 0;
    private float[] snapHistory = new float[10];
    private int snapHistoryIndex = 0;
    private float antiAimOffset = 0f;

    // Для случайных отклонений в HVH
    private float randomDeviation = 0f;
    private int randomDeviationTimer = 0;

    // Таймеры для атаки
    private int attackTimer = 0;
    private boolean canPerformAttack = true;

    private final Random randomGenerator = new Random();
    private final Random snapRandom = new Random();

    public KillAura(AutoPotion autopotion) {
        addSettings(rotationType, attackRange, fov, targetSelection, advancedOptions, movementCorrection);
        addSettings(snapAccuracy, snapPrediction, predictionStrength, snapSilent, snapAntiAim, snapAntiAimAmount);
        addSettings(hvhRotationSpeed, hvhPitchSpeed, silentAim, randomization);
    }

    @Subscribe
    public void onInput(EventInput eventInput) {
        if (!isState() || currentTarget == null || mc.player == null) return;

        if (advancedOptions.getValueByName("Корректировка движения").get() && movementCorrection.is("Плавный")) {
            MoveUtils.fixMovement(eventInput, rotationVector.x);
        }
    }

    @Subscribe
    public void onUpdate(EventUpdate e) {
        if (!isState() || mc.player == null) return;

        // Обновление таймера атаки
        if (attackTimer > 0) {
            attackTimer--;
        } else {
            canPerformAttack = true;
        }

        // Обновление задержки снапа
        if (snapDelay > 0) {
            snapDelay--;
        }

        // Поиск новой цели
        if (advancedOptions.getValueByName("Фиксировать цель").get() && (currentTarget == null || !isValidTarget(currentTarget)) ||
                !advancedOptions.getValueByName("Фиксировать цель").get()) {
            findNewTarget();
        }

        // Обновление случайных отклонений
        if (randomDeviationTimer > 0) {
            randomDeviationTimer--;
        } else if (randomization.get() && (rotationType.is("HVH Плавная") || rotationType.is("HVH Снап"))) {
            randomDeviation = (float) ((randomGenerator.nextFloat() - 0.5) * 10f);
            randomDeviationTimer = 20 + randomGenerator.nextInt(20);
        }

        // Обновление противоаима для снапа
        if (snapAntiAim.get() && rotationType.is("Снап")) {
            antiAimOffset = (float) Math.sin(System.currentTimeMillis() / 200.0) * snapAntiAimAmount.get();
        } else {
            antiAimOffset = 0f;
        }

        if (currentTarget != null) {
            isRotating = false;

            // Обновление ротации в зависимости от выбранного типа
            if (!rotationType.is("Выключена")) {
                String currentRotationType = rotationType.get();
                switch (currentRotationType) {
                    case "Снап":
                        updateSnapRotation();
                        break;
                    case "HVH Плавная":
                        updateHvHSmoothRotation(false);
                        break;
                    case "HVH Снап":
                        updateHvHSnapRotation(false);
                        break;
                    case "Плавная":
                        if (!isRotating) {
                            updateSmoothRotation(false);
                        }
                        break;
                }
            }

            // Проверка условий для атаки
            if (canAttack() && canPerformAttack) {
                performAttack();
                rotationTicks = 2;
                attackTimer = 10;
                canPerformAttack = false;
            }
        } else {
            resetAll();
        }

        // Сохранение истории снапа
        if (rotationType.is("Снап")) {
            snapHistory[snapHistoryIndex] = rotationVector.x;
            snapHistoryIndex = (snapHistoryIndex + 1) % snapHistory.length;
        }
    }

    @Subscribe
    private void onWalking(EventMotion e) {
        if (!isState() || currentTarget == null) return;

        // Для скрытного наведения в HVH режимах и снап ротации
        boolean shouldBeSilent = (rotationType.is("HVH Плавная") || rotationType.is("HVH Снап")) && silentAim.get() ||
                rotationType.is("Снап") && snapSilent.get();

        if (shouldBeSilent) {
            return;
        }

        // Применение ротации
        if (!rotationType.is("Выключена")) {
            float yaw = rotationVector.x;
            float pitch = rotationVector.y;

            // Добавляем противоаим
            if (snapAntiAim.get() && rotationType.is("Снап")) {
                yaw += antiAimOffset;
            }

            e.setYaw(yaw);
            e.setPitch(pitch);
            mc.player.rotationYawHead = yaw;
            mc.player.renderYawOffset = yaw;
            mc.player.rotationPitchHead = pitch;
        }
    }

    private void findNewTarget() {
        if (mc.player == null || mc.world == null) return;

        List<LivingEntity> potentialTargets = new ArrayList<>();

        for (Entity entity : mc.world.getAllEntities()) {
            if (entity instanceof LivingEntity living && isValidTarget(living)) {
                if (isWithinFieldOfView(living)) {
                    potentialTargets.add(living);
                }
            }
        }

        if (potentialTargets.isEmpty()) {
            currentTarget = null;
            return;
        }

        // Сортировка по расстоянию
        potentialTargets.sort(Comparator.comparingDouble(entity -> mc.player.getDistance(entity)));

        currentTarget = potentialTargets.get(0);
    }

    private boolean isWithinFieldOfView(LivingEntity entity) {
        if (fov.get() >= 360f) return true;
        if (mc.player == null) return false;

        Vector3d directionVector = entity.getBoundingBox().getCenter()
                .subtract(mc.player.getEyePosition(1.0F));

        float targetYaw = (float) MathHelper.wrapDegrees(Math.toDegrees(Math.atan2(directionVector.z, directionVector.x)) - 90);
        float targetPitch = (float) (-Math.toDegrees(Math.atan2(directionVector.y, hypot(directionVector.x, directionVector.z))));

        float yawDifference = Math.abs(wrapDegrees(targetYaw - mc.player.rotationYaw));
        float pitchDifference = Math.abs(wrapDegrees(targetPitch - mc.player.rotationPitch));

        return yawDifference <= fov.get() / 2 && pitchDifference <= fov.get() / 2;
    }

    private Vector3d calculatePredictedPosition(LivingEntity target) {
        if (!snapPrediction.get() || target == null) {
            return target.getBoundingBox().getCenter();
        }

        Vector3d currentPos = target.getBoundingBox().getCenter();

        // Получаем вектор движения цели
        Vector3d motion = new Vector3d(
                target.getPosX() - target.prevPosX,
                target.getPosY() - target.prevPosY,
                target.getPosZ() - target.prevPosZ
        );

        // Рассчитываем время полета удара
        double distance = mc.player.getDistance(target);
        double timeToTarget = distance / 8.0; // Примерная скорость удара

        // Усиливаем предсказание
        timeToTarget *= predictionStrength.get();

        // Учитываем вертикальное движение
        if (!target.isOnGround()) {
            motion = motion.add(0, motion.y * 0.5, 0);
        }

        // Предсказанная позиция
        Vector3d predictedPos = currentPos.add(motion.scale(timeToTarget));

        // Минимальная коррекция для стоящих целей
        if (motion.length() < 0.05) {
            predictedPos = currentPos;
        }

        return predictedPos;
    }

    private Vector2f calculateSnapAngles(Vector3d targetPos) {
        if (mc.player == null) return new Vector2f(0, 0);

        Vector3d eyePos = mc.player.getEyePosition(1.0F);
        Vector3d diff = targetPos.subtract(eyePos);

        double diffX = diff.x;
        double diffY = diff.y;
        double diffZ = diff.z;
        double dist = Math.sqrt(diffX * diffX + diffZ * diffZ);

        float yaw = (float) Math.toDegrees(Math.atan2(diffZ, diffX)) - 90.0F;
        float pitch = (float) (-Math.toDegrees(Math.atan2(diffY, dist)));

        // Выбираем кратчайший путь поворота
        float currentYaw = rotationVector.x;
        float deltaYaw = wrapDegrees(yaw - currentYaw);

        if (Math.abs(deltaYaw) > 180) {
            deltaYaw = deltaYaw - Math.copySign(360, deltaYaw);
        }

        yaw = currentYaw + deltaYaw;

        // Ограничиваем угол наклона
        pitch = clamp(pitch, -89, 89);

        // Добавляем точность (случайное отклонение для натуральности)
        float accuracyFactor = 1.0f / snapAccuracy.get();
        if (accuracyFactor > 0.1f) {
            float randomYawOffset = (snapRandom.nextFloat() - 0.5f) * 2f * accuracyFactor;
            float randomPitchOffset = (snapRandom.nextFloat() - 0.5f) * accuracyFactor;

            yaw += randomYawOffset;
            pitch += randomPitchOffset;
        }

        return new Vector2f(wrapDegrees(yaw), pitch);
    }

    private void updateSnapRotation() {
        if (currentTarget == null || mc.player == null || snapDelay > 0) return;

        isRotating = true;

        // Получаем предсказанную позицию
        Vector3d targetPos = calculatePredictedPosition(currentTarget);

        // Рассчитываем углы снапа
        Vector2f snapAngles = calculateSnapAngles(targetPos);
        float targetYaw = snapAngles.x;
        float targetPitch = snapAngles.y;

        // Проверяем, нужно ли делать снап (слишком большой угол или опция "Снап при атаке")
        boolean shouldSnap = shouldPerformSnap(targetYaw, targetPitch);

        if (shouldSnap) {
            // Мгновенный снап
            performInstantSnap(targetYaw, targetPitch);
            snapCounter++;

            // Случайная задержка между снапами для натуральности
            if (snapCounter > 3) {
                snapDelay = 1 + snapRandom.nextInt(2);
                snapCounter = 0;
            }
        } else {
            // Плавный переход к цели
            performSmoothTransition(targetYaw, targetPitch);
        }

        // Корректировка движения
        if (advancedOptions.getValueByName("Корректировка движения").get() && !snapSilent.get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }

        // Сохраняем последние углы
        lastSnapYaw = targetYaw;
        lastSnapPitch = targetPitch;
        wasSnapping = shouldSnap;
    }

    private boolean shouldPerformSnap(float targetYaw, float targetPitch) {
        // Всегда делаем снап при атаке, если опция включена
        if (advancedOptions.getValueByName("Снап при атаке").get() &&
                advancedOptions.getValueByName("Ускорять при атаке").get() &&
                canPerformAttack) {
            return true;
        }

        // Проверяем угол отклонения
        float yawDiff = Math.abs(wrapDegrees(targetYaw - rotationVector.x));
        float pitchDiff = Math.abs(wrapDegrees(targetPitch - rotationVector.y));

        // Делаем снап при большом отклонении
        return yawDiff > 15f || pitchDiff > 8f;
    }

    private void performInstantSnap(float targetYaw, float targetPitch) {
        // Мгновенный снап с учетом GCD
        float newYaw = targetYaw;
        float newPitch = targetPitch;

        // Применяем коррекцию чувствительности
        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            float deltaYaw = newYaw - rotationVector.x;
            float deltaPitch = newPitch - rotationVector.y;

            deltaYaw -= deltaYaw % gcd;
            deltaPitch -= deltaPitch % gcd;

            newYaw = rotationVector.x + deltaYaw;
            newPitch = rotationVector.y + deltaPitch;
        }

        // Ограничиваем угол наклона
        newPitch = clamp(newPitch, -89, 89);

        rotationVector = new Vector2f(newYaw, newPitch);
    }

    private void performSmoothTransition(float targetYaw, float targetPitch) {
        // Плавный переход для небольших корректировок
        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // Медленная корректировка
        float yawStep = yawDiff * 0.3f;
        float pitchStep = pitchDiff * 0.2f;

        float newYaw = rotationVector.x + yawStep;
        float newPitch = clamp(rotationVector.y + pitchStep, -89, 89);

        // GCD коррекция
        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);
    }

    private void updateSmoothRotation(boolean isAttacking) {
        if (currentTarget == null || mc.player == null) return;

        isRotating = true;

        Vector3d targetPos = calculatePredictedPosition(currentTarget);
        Vector2f targetAngles = calculateSnapAngles(targetPos);

        float targetYaw = targetAngles.x;
        float targetPitch = clamp(targetAngles.y, -89, 89);

        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // Плавная интерполяция
        float smoothFactor = isAttacking ? 0.8f : 0.3f;
        float newYaw = rotationVector.x + yawDiff * smoothFactor;
        float newPitch = clamp(rotationVector.y + pitchDiff * smoothFactor, -89, 89);

        // Коррекция чувствительности
        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);

        if (advancedOptions.getValueByName("Корректировка движения").get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }
    }

    private void updateHvHSmoothRotation(boolean isAttacking) {
        if (currentTarget == null || mc.player == null) return;

        Vector3d targetPos = calculatePredictedPosition(currentTarget);
        Vector2f targetAngles = calculateSnapAngles(targetPos);

        float targetYaw = targetAngles.x;
        float targetPitch = clamp(targetAngles.y, -89, 89);

        // Добавление случайных отклонений
        if (randomization.get()) {
            targetYaw += randomDeviation;
            targetPitch += randomDeviation * 0.5f;
        }

        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // Плавная ротация с настройками HVH
        float yawStep = Math.min(Math.max(Math.abs(yawDiff), 1.0f), hvhRotationSpeed.get());
        float pitchStep = Math.min(Math.max(Math.abs(pitchDiff), 1.0f), hvhPitchSpeed.get());

        if (isAttacking && advancedOptions.getValueByName("Ускорять при атаке").get()) {
            yawStep *= 1.5f;
            pitchStep *= 1.5f;
        }

        float newYaw = rotationVector.x + (yawDiff > 0 ? yawStep : -yawStep);
        float newPitch = clamp(rotationVector.y + (pitchDiff > 0 ? pitchStep : -pitchStep), -89.0F, 89.0F);

        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);

        if (advancedOptions.getValueByName("Корректировка движения").get() && !silentAim.get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }
    }

    private void updateHvHSnapRotation(boolean isAttacking) {
        if (currentTarget == null || mc.player == null) return;

        Vector3d targetPos = calculatePredictedPosition(currentTarget);
        Vector2f targetAngles = calculateSnapAngles(targetPos);

        float targetYaw = targetAngles.x;
        float targetPitch = clamp(targetAngles.y, -89, 89);

        if (randomization.get()) {
            targetYaw += randomDeviation;
            targetPitch += randomDeviation * 0.5f;
        }

        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // HVH снап - быстрый но не мгновенный
        float maxYawChange = hvhRotationSpeed.get() * 3f;
        float maxPitchChange = hvhPitchSpeed.get() * 2f;

        float yawChange = Math.copySign(Math.min(Math.abs(yawDiff), maxYawChange), yawDiff);
        float pitchChange = Math.copySign(Math.min(Math.abs(pitchDiff), maxPitchChange), pitchDiff);

        // Ускорение при атаке
        if (isAttacking && advancedOptions.getValueByName("Ускорять при атаке").get()) {
            yawChange *= 1.8f;
            pitchChange *= 1.5f;
        }

        float newYaw = rotationVector.x + yawChange;
        float newPitch = clamp(rotationVector.y + pitchChange, -89.0F, 89.0F);

        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);

        if (advancedOptions.getValueByName("Корректировка движения").get() && !silentAim.get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }
    }

    private void performAttack() {
        if (currentTarget == null || mc.playerController == null || mc.player == null) return;

        // Проверка паузы при использовании предметов
        if (advancedOptions.getValueByName("Пауза при использовании предметов").get() && isUsingItem()) {
            return;
        }

        // Проверка наведения для ротации
        if (!rotationType.is("Выключена")) {
            selectedEntity = MouseUtil.getMouseOver(currentTarget, rotationVector.x, rotationVector.y, attackRange.get());

            if (advancedOptions.getValueByName("Ускорять при атаке").get()) {
                String currentRotationType = rotationType.get();
                switch (currentRotationType) {
                    case "Снап":
                        // Для снапа просто обновляем (уже мгновенный)
                        break;
                    case "HVH Плавная":
                        updateHvHSmoothRotation(true);
                        break;
                    case "HVH Снап":
                        updateHvHSnapRotation(true);
                        break;
                    case "Плавная":
                        updateSmoothRotation(true);
                        break;
                }
            }

            if ((selectedEntity == null || selectedEntity != currentTarget) && !mc.player.isElytraFlying()) {
                return;
            }
        } else {
            selectedEntity = MouseUtil.getMouseOver(currentTarget, mc.player.rotationYaw, mc.player.rotationPitch, attackRange.get());

            if ((selectedEntity == null || selectedEntity != currentTarget) && !mc.player.isElytraFlying()) {
                return;
            }
        }

        if (mc.player.isBlocking() && advancedOptions.getValueByName("Отжимать щиты").get()) {
            mc.playerController.onStoppedUsingItem(mc.player);
        }

        // Выполнение атаки
        try {
            mc.playerController.attackEntity(mc.player, currentTarget);
            mc.player.swingArm(Hand.MAIN_HAND);

            if (currentTarget instanceof PlayerEntity player && advancedOptions.getValueByName("Ломать щиты").get()) {
                performShieldBreak(player);
            }
        } catch (Exception e) {
            // Игнорирование ошибок атаки
        }
    }

    private boolean isUsingItem() {
        if (mc.player == null) return false;

        return mc.player.isHandActive() && mc.player.getActiveItemStack() != null &&
                (mc.player.getActiveItemStack().getItem().isFood() ||
                        mc.player.getActiveItemStack().getItem().isDrinkable());
    }

    private boolean canAttack() {
        // Проверка паузы при использовании предметов
        if (advancedOptions.getValueByName("Пауза при использовании предметов").get() && isUsingItem()) {
            return false;
        }

        if (advancedOptions.getValueByName("Только с критом").get()) {
            return !mc.player.isOnGround() && mc.player.fallDistance > 0;
        }

        return true;
    }

    private boolean isValidTarget(LivingEntity entity) {
        if (entity == null || entity instanceof ClientPlayerEntity) return false;
        if (mc.player == null) return false;

        if (entity.ticksExisted < 3) return false;
        if (mc.player.getDistance(entity) > attackRange.get()) return false;

        if (entity instanceof PlayerEntity p) {
            if (!targetSelection.getValueByName("Друзья").get() && FriendStorage.isFriend(p.getName().getString())) {
                return false;
            }
            if (p.getName().getString().equals(mc.player.getName().getString())) return false;
        }

        if (entity instanceof PlayerEntity) {
            if (!targetSelection.getValueByName("Игроки").get()) return false;
            if (entity.getTotalArmorValue() == 0 && !targetSelection.getValueByName("Без брони").get()) return false;
            if (entity.isInvisible() && entity.getTotalArmorValue() == 0 &&
                    !targetSelection.getValueByName("Невидимые без брони").get()) return false;
            if (entity.isInvisible() && !targetSelection.getValueByName("Невидимые").get()) return false;
        } else if (entity instanceof MonsterEntity && !targetSelection.getValueByName("Враждебные мобы").get()) {
            return false;
        } else if (entity instanceof AnimalEntity && !targetSelection.getValueByName("Мирные мобы").get()) {
            return false;
        }

        return !entity.isInvulnerable() && entity.isAlive() && !(entity instanceof ArmorStandEntity);
    }

    private void performShieldBreak(PlayerEntity targetPlayer) {
        if (!targetPlayer.isBlocking() || mc.playerController == null) return;

        int inventorySlot = InventoryUtil.getInstance().getAxeInInventory(false);
        int hotbarSlot = InventoryUtil.getInstance().getAxeInInventory(true);

        if (hotbarSlot == -1 && inventorySlot != -1) {
            int bestHotbarSlot = InventoryUtil.getInstance().findBestSlotInHotBar();
            if (bestHotbarSlot == -1) return;

            try {
                mc.playerController.windowClick(0, inventorySlot, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(0, bestHotbarSlot + 36, 0, ClickType.PICKUP, mc.player);

                mc.player.connection.sendPacket(new CHeldItemChangePacket(bestHotbarSlot));
                mc.playerController.attackEntity(mc.player, targetPlayer);
                mc.player.swingArm(Hand.MAIN_HAND);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(mc.player.inventory.currentItem));

                mc.playerController.windowClick(0, bestHotbarSlot + 36, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(0, inventorySlot, 0, ClickType.PICKUP, mc.player);
            } catch (Exception e) {
                // Игнорирование ошибок
            }
        }

        if (hotbarSlot != -1) {
            try {
                mc.player.connection.sendPacket(new CHeldItemChangePacket(hotbarSlot));
                mc.playerController.attackEntity(mc.player, targetPlayer);
                mc.player.swingArm(Hand.MAIN_HAND);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(mc.player.inventory.currentItem));
            } catch (Exception e) {
                // Игнорирование ошибок
            }
        }
    }

    private void resetAll() {
        if (mc.player != null) {
            if (advancedOptions.getValueByName("Корректировка движения").get()) {
                mc.player.rotationYawOffset = Integer.MIN_VALUE;
            }
            rotationVector = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
        }
        randomDeviation = 0f;
        randomDeviationTimer = 0;
        attackTimer = 0;
        canPerformAttack = true;
        currentTarget = null;
        selectedEntity = null;
        isRotating = false;
        rotationTicks = 0;

        // Сброс данных снап ротации
        lastSnapYaw = 0;
        lastSnapPitch = 0;
        snapDelay = 0;
        wasSnapping = false;
        snapCounter = 0;
        snapHistory = new float[10];
        snapHistoryIndex = 0;
        antiAimOffset = 0f;
    }

    @Override
    public void onEnable() {
        super.onEnable();
        resetAll();
    }

    @Override
    public void onDisable() {
        super.onDisable();
        resetAll();
    }

    // Методы для расчета характеристик цели
    private double calculateArmorValue(PlayerEntity player) {
        double armorTotal = 0.0;
        for (int i = 0; i < 4; ++i) {
            ItemStack armorPiece = player.inventory.armorInventory.get(i);
            if (!(armorPiece.getItem() instanceof ArmorItem)) continue;
            armorTotal += getArmorProtectionValue(armorPiece);
        }
        return armorTotal;
    }

    private double getArmorProtectionValue(ItemStack armorStack) {
        if (armorStack.getItem() instanceof ArmorItem armorItem) {
            double baseProtection = armorItem.getDamageReduceAmount();
            if (armorStack.isEnchanted()) {
                baseProtection += (double) EnchantmentHelper.getEnchantmentLevel(Enchantments.PROTECTION, armorStack) * 0.25;
            }
            return baseProtection;
        }
        return 0;
    }

    private double calculateEffectiveHealth(LivingEntity entity) {
        if (entity instanceof PlayerEntity player) {
            return (double) (player.getHealth() + player.getAbsorptionAmount()) * (calculateArmorValue(player) / 20.0);
        }
        return entity.getHealth() + entity.getAbsorptionAmount();
    }

    public LivingEntity getTarget() {
        return null;
    }
}
ну и дерьмо, а тебя искренне жаль если ты дружишь с нейросетью
 
новая селфкод килка для топовых пастеров нафик кто понил тот понял спасиба маему кинту Хз М. за что что предоставил свою топовую килку
вот код
Код:
Expand Collapse Copy
package im.expensive.functions.impl.combat;

import com.google.common.eventbus.Subscribe;
import im.expensive.command.friends.FriendStorage;
import im.expensive.events.EventInput;
import im.expensive.events.EventMotion;
import im.expensive.events.EventUpdate;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.functions.settings.impl.BooleanSetting;
import im.expensive.functions.settings.impl.ModeListSetting;
import im.expensive.functions.settings.impl.ModeSetting;
import im.expensive.functions.settings.impl.SliderSetting;
import im.expensive.utils.math.SensUtils;
import im.expensive.utils.player.InventoryUtil;
import im.expensive.utils.player.MouseUtil;
import im.expensive.utils.player.MoveUtils;
import lombok.Getter;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ArmorStandEntity;
import net.minecraft.entity.monster.MonsterEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.ClickType;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.CHeldItemChangePacket;
import net.minecraft.util.Hand;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Random;

import static java.lang.Math.hypot;
import static net.minecraft.util.math.MathHelper.clamp;
import static net.minecraft.util.math.MathHelper.wrapDegrees;

@FunctionRegister(name = "KillAura", type = Category.Combat)
public class KillAura extends Function {
    @Getter
    private final ModeSetting rotationType = new ModeSetting("Тип ротации", "Выключена", "Выключена", "Плавная", "Снап", "HVH Плавная", "HVH Снап");

    // Основные настройки
    private final SliderSetting attackRange = new SliderSetting("Дальность атаки", 3.2f, 3f, 6f, 0.1f);
    private final SliderSetting fov = new SliderSetting("Поле зрения", 180f, 30f, 360f, 1f);

    // Настройки для снап ротации (мгновенная)
    private final SliderSetting snapAccuracy = new SliderSetting("Точность снапа", 1.0f, 0.5f, 5f, 0.1f);
    private final BooleanSetting snapPrediction = new BooleanSetting("Предсказание траектории", true);
    private final SliderSetting predictionStrength = new SliderSetting("Сила предсказания", 1.5f, 0.5f, 3f, 0.1f);
    private final BooleanSetting snapSilent = new BooleanSetting("Скрытный снап", false);
    private final BooleanSetting snapAntiAim = new BooleanSetting("Противоаим", false);
    private final SliderSetting snapAntiAimAmount = new SliderSetting("Сила противоаима", 5f, 1f, 15f, 0.5f);

    // Настройки для HVH ротаций
    private final SliderSetting hvhRotationSpeed = new SliderSetting("Скорость плавного поворота", 60f, 10f, 360f, 1f);
    private final SliderSetting hvhPitchSpeed = new SliderSetting("Скорость плавного наклона", 40f, 10f, 180f, 1f);
    private final BooleanSetting silentAim = new BooleanSetting("Скрытное наведение", false);
    private final BooleanSetting randomization = new BooleanSetting("Случайные отклонения", false);

    final ModeListSetting targetSelection = new ModeListSetting("Выбор целей",
            new BooleanSetting("Игроки", true),
            new BooleanSetting("Без брони", true),
            new BooleanSetting("Враждебные мобы", false),
            new BooleanSetting("Мирные мобы", false),
            new BooleanSetting("Друзья", false),
            new BooleanSetting("Невидимые без брони", true),
            new BooleanSetting("Невидимые", true));

    @Getter
    final ModeListSetting advancedOptions = new ModeListSetting("Дополнительно",
            new BooleanSetting("Только с критом", false),
            new BooleanSetting("Ломать щиты", true),
            new BooleanSetting("Отжимать щиты", true),
            new BooleanSetting("Ускорять при атаке", true),
            new BooleanSetting("Синхронизация с TPS", false),
            new BooleanSetting("Фиксировать цель", true),
            new BooleanSetting("Корректировка движения", true),
            new BooleanSetting("Пауза при использовании предметов", true),
            new BooleanSetting("Снап при атаке", true));

    final ModeSetting movementCorrection = new ModeSetting("Стиль коррекции", "Плавный", "Плавный", "Агрессивный");

    private Vector2f rotationVector = new Vector2f(0, 0);
    @Getter
    private LivingEntity currentTarget;
    private Entity selectedEntity;

    private int rotationTicks = 0;
    private boolean isRotating;

    // Для снап ротации
    private float lastSnapYaw = 0;
    private float lastSnapPitch = 0;
    private int snapDelay = 0;
    private boolean wasSnapping = false;
    private int snapCounter = 0;
    private float[] snapHistory = new float[10];
    private int snapHistoryIndex = 0;
    private float antiAimOffset = 0f;

    // Для случайных отклонений в HVH
    private float randomDeviation = 0f;
    private int randomDeviationTimer = 0;

    // Таймеры для атаки
    private int attackTimer = 0;
    private boolean canPerformAttack = true;

    private final Random randomGenerator = new Random();
    private final Random snapRandom = new Random();

    public KillAura(AutoPotion autopotion) {
        addSettings(rotationType, attackRange, fov, targetSelection, advancedOptions, movementCorrection);
        addSettings(snapAccuracy, snapPrediction, predictionStrength, snapSilent, snapAntiAim, snapAntiAimAmount);
        addSettings(hvhRotationSpeed, hvhPitchSpeed, silentAim, randomization);
    }

    @Subscribe
    public void onInput(EventInput eventInput) {
        if (!isState() || currentTarget == null || mc.player == null) return;

        if (advancedOptions.getValueByName("Корректировка движения").get() && movementCorrection.is("Плавный")) {
            MoveUtils.fixMovement(eventInput, rotationVector.x);
        }
    }

    @Subscribe
    public void onUpdate(EventUpdate e) {
        if (!isState() || mc.player == null) return;

        // Обновление таймера атаки
        if (attackTimer > 0) {
            attackTimer--;
        } else {
            canPerformAttack = true;
        }

        // Обновление задержки снапа
        if (snapDelay > 0) {
            snapDelay--;
        }

        // Поиск новой цели
        if (advancedOptions.getValueByName("Фиксировать цель").get() && (currentTarget == null || !isValidTarget(currentTarget)) ||
                !advancedOptions.getValueByName("Фиксировать цель").get()) {
            findNewTarget();
        }

        // Обновление случайных отклонений
        if (randomDeviationTimer > 0) {
            randomDeviationTimer--;
        } else if (randomization.get() && (rotationType.is("HVH Плавная") || rotationType.is("HVH Снап"))) {
            randomDeviation = (float) ((randomGenerator.nextFloat() - 0.5) * 10f);
            randomDeviationTimer = 20 + randomGenerator.nextInt(20);
        }

        // Обновление противоаима для снапа
        if (snapAntiAim.get() && rotationType.is("Снап")) {
            antiAimOffset = (float) Math.sin(System.currentTimeMillis() / 200.0) * snapAntiAimAmount.get();
        } else {
            antiAimOffset = 0f;
        }

        if (currentTarget != null) {
            isRotating = false;

            // Обновление ротации в зависимости от выбранного типа
            if (!rotationType.is("Выключена")) {
                String currentRotationType = rotationType.get();
                switch (currentRotationType) {
                    case "Снап":
                        updateSnapRotation();
                        break;
                    case "HVH Плавная":
                        updateHvHSmoothRotation(false);
                        break;
                    case "HVH Снап":
                        updateHvHSnapRotation(false);
                        break;
                    case "Плавная":
                        if (!isRotating) {
                            updateSmoothRotation(false);
                        }
                        break;
                }
            }

            // Проверка условий для атаки
            if (canAttack() && canPerformAttack) {
                performAttack();
                rotationTicks = 2;
                attackTimer = 10;
                canPerformAttack = false;
            }
        } else {
            resetAll();
        }

        // Сохранение истории снапа
        if (rotationType.is("Снап")) {
            snapHistory[snapHistoryIndex] = rotationVector.x;
            snapHistoryIndex = (snapHistoryIndex + 1) % snapHistory.length;
        }
    }

    @Subscribe
    private void onWalking(EventMotion e) {
        if (!isState() || currentTarget == null) return;

        // Для скрытного наведения в HVH режимах и снап ротации
        boolean shouldBeSilent = (rotationType.is("HVH Плавная") || rotationType.is("HVH Снап")) && silentAim.get() ||
                rotationType.is("Снап") && snapSilent.get();

        if (shouldBeSilent) {
            return;
        }

        // Применение ротации
        if (!rotationType.is("Выключена")) {
            float yaw = rotationVector.x;
            float pitch = rotationVector.y;

            // Добавляем противоаим
            if (snapAntiAim.get() && rotationType.is("Снап")) {
                yaw += antiAimOffset;
            }

            e.setYaw(yaw);
            e.setPitch(pitch);
            mc.player.rotationYawHead = yaw;
            mc.player.renderYawOffset = yaw;
            mc.player.rotationPitchHead = pitch;
        }
    }

    private void findNewTarget() {
        if (mc.player == null || mc.world == null) return;

        List<LivingEntity> potentialTargets = new ArrayList<>();

        for (Entity entity : mc.world.getAllEntities()) {
            if (entity instanceof LivingEntity living && isValidTarget(living)) {
                if (isWithinFieldOfView(living)) {
                    potentialTargets.add(living);
                }
            }
        }

        if (potentialTargets.isEmpty()) {
            currentTarget = null;
            return;
        }

        // Сортировка по расстоянию
        potentialTargets.sort(Comparator.comparingDouble(entity -> mc.player.getDistance(entity)));

        currentTarget = potentialTargets.get(0);
    }

    private boolean isWithinFieldOfView(LivingEntity entity) {
        if (fov.get() >= 360f) return true;
        if (mc.player == null) return false;

        Vector3d directionVector = entity.getBoundingBox().getCenter()
                .subtract(mc.player.getEyePosition(1.0F));

        float targetYaw = (float) MathHelper.wrapDegrees(Math.toDegrees(Math.atan2(directionVector.z, directionVector.x)) - 90);
        float targetPitch = (float) (-Math.toDegrees(Math.atan2(directionVector.y, hypot(directionVector.x, directionVector.z))));

        float yawDifference = Math.abs(wrapDegrees(targetYaw - mc.player.rotationYaw));
        float pitchDifference = Math.abs(wrapDegrees(targetPitch - mc.player.rotationPitch));

        return yawDifference <= fov.get() / 2 && pitchDifference <= fov.get() / 2;
    }

    private Vector3d calculatePredictedPosition(LivingEntity target) {
        if (!snapPrediction.get() || target == null) {
            return target.getBoundingBox().getCenter();
        }

        Vector3d currentPos = target.getBoundingBox().getCenter();

        // Получаем вектор движения цели
        Vector3d motion = new Vector3d(
                target.getPosX() - target.prevPosX,
                target.getPosY() - target.prevPosY,
                target.getPosZ() - target.prevPosZ
        );

        // Рассчитываем время полета удара
        double distance = mc.player.getDistance(target);
        double timeToTarget = distance / 8.0; // Примерная скорость удара

        // Усиливаем предсказание
        timeToTarget *= predictionStrength.get();

        // Учитываем вертикальное движение
        if (!target.isOnGround()) {
            motion = motion.add(0, motion.y * 0.5, 0);
        }

        // Предсказанная позиция
        Vector3d predictedPos = currentPos.add(motion.scale(timeToTarget));

        // Минимальная коррекция для стоящих целей
        if (motion.length() < 0.05) {
            predictedPos = currentPos;
        }

        return predictedPos;
    }

    private Vector2f calculateSnapAngles(Vector3d targetPos) {
        if (mc.player == null) return new Vector2f(0, 0);

        Vector3d eyePos = mc.player.getEyePosition(1.0F);
        Vector3d diff = targetPos.subtract(eyePos);

        double diffX = diff.x;
        double diffY = diff.y;
        double diffZ = diff.z;
        double dist = Math.sqrt(diffX * diffX + diffZ * diffZ);

        float yaw = (float) Math.toDegrees(Math.atan2(diffZ, diffX)) - 90.0F;
        float pitch = (float) (-Math.toDegrees(Math.atan2(diffY, dist)));

        // Выбираем кратчайший путь поворота
        float currentYaw = rotationVector.x;
        float deltaYaw = wrapDegrees(yaw - currentYaw);

        if (Math.abs(deltaYaw) > 180) {
            deltaYaw = deltaYaw - Math.copySign(360, deltaYaw);
        }

        yaw = currentYaw + deltaYaw;

        // Ограничиваем угол наклона
        pitch = clamp(pitch, -89, 89);

        // Добавляем точность (случайное отклонение для натуральности)
        float accuracyFactor = 1.0f / snapAccuracy.get();
        if (accuracyFactor > 0.1f) {
            float randomYawOffset = (snapRandom.nextFloat() - 0.5f) * 2f * accuracyFactor;
            float randomPitchOffset = (snapRandom.nextFloat() - 0.5f) * accuracyFactor;

            yaw += randomYawOffset;
            pitch += randomPitchOffset;
        }

        return new Vector2f(wrapDegrees(yaw), pitch);
    }

    private void updateSnapRotation() {
        if (currentTarget == null || mc.player == null || snapDelay > 0) return;

        isRotating = true;

        // Получаем предсказанную позицию
        Vector3d targetPos = calculatePredictedPosition(currentTarget);

        // Рассчитываем углы снапа
        Vector2f snapAngles = calculateSnapAngles(targetPos);
        float targetYaw = snapAngles.x;
        float targetPitch = snapAngles.y;

        // Проверяем, нужно ли делать снап (слишком большой угол или опция "Снап при атаке")
        boolean shouldSnap = shouldPerformSnap(targetYaw, targetPitch);

        if (shouldSnap) {
            // Мгновенный снап
            performInstantSnap(targetYaw, targetPitch);
            snapCounter++;

            // Случайная задержка между снапами для натуральности
            if (snapCounter > 3) {
                snapDelay = 1 + snapRandom.nextInt(2);
                snapCounter = 0;
            }
        } else {
            // Плавный переход к цели
            performSmoothTransition(targetYaw, targetPitch);
        }

        // Корректировка движения
        if (advancedOptions.getValueByName("Корректировка движения").get() && !snapSilent.get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }

        // Сохраняем последние углы
        lastSnapYaw = targetYaw;
        lastSnapPitch = targetPitch;
        wasSnapping = shouldSnap;
    }

    private boolean shouldPerformSnap(float targetYaw, float targetPitch) {
        // Всегда делаем снап при атаке, если опция включена
        if (advancedOptions.getValueByName("Снап при атаке").get() &&
                advancedOptions.getValueByName("Ускорять при атаке").get() &&
                canPerformAttack) {
            return true;
        }

        // Проверяем угол отклонения
        float yawDiff = Math.abs(wrapDegrees(targetYaw - rotationVector.x));
        float pitchDiff = Math.abs(wrapDegrees(targetPitch - rotationVector.y));

        // Делаем снап при большом отклонении
        return yawDiff > 15f || pitchDiff > 8f;
    }

    private void performInstantSnap(float targetYaw, float targetPitch) {
        // Мгновенный снап с учетом GCD
        float newYaw = targetYaw;
        float newPitch = targetPitch;

        // Применяем коррекцию чувствительности
        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            float deltaYaw = newYaw - rotationVector.x;
            float deltaPitch = newPitch - rotationVector.y;

            deltaYaw -= deltaYaw % gcd;
            deltaPitch -= deltaPitch % gcd;

            newYaw = rotationVector.x + deltaYaw;
            newPitch = rotationVector.y + deltaPitch;
        }

        // Ограничиваем угол наклона
        newPitch = clamp(newPitch, -89, 89);

        rotationVector = new Vector2f(newYaw, newPitch);
    }

    private void performSmoothTransition(float targetYaw, float targetPitch) {
        // Плавный переход для небольших корректировок
        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // Медленная корректировка
        float yawStep = yawDiff * 0.3f;
        float pitchStep = pitchDiff * 0.2f;

        float newYaw = rotationVector.x + yawStep;
        float newPitch = clamp(rotationVector.y + pitchStep, -89, 89);

        // GCD коррекция
        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);
    }

    private void updateSmoothRotation(boolean isAttacking) {
        if (currentTarget == null || mc.player == null) return;

        isRotating = true;

        Vector3d targetPos = calculatePredictedPosition(currentTarget);
        Vector2f targetAngles = calculateSnapAngles(targetPos);

        float targetYaw = targetAngles.x;
        float targetPitch = clamp(targetAngles.y, -89, 89);

        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // Плавная интерполяция
        float smoothFactor = isAttacking ? 0.8f : 0.3f;
        float newYaw = rotationVector.x + yawDiff * smoothFactor;
        float newPitch = clamp(rotationVector.y + pitchDiff * smoothFactor, -89, 89);

        // Коррекция чувствительности
        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);

        if (advancedOptions.getValueByName("Корректировка движения").get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }
    }

    private void updateHvHSmoothRotation(boolean isAttacking) {
        if (currentTarget == null || mc.player == null) return;

        Vector3d targetPos = calculatePredictedPosition(currentTarget);
        Vector2f targetAngles = calculateSnapAngles(targetPos);

        float targetYaw = targetAngles.x;
        float targetPitch = clamp(targetAngles.y, -89, 89);

        // Добавление случайных отклонений
        if (randomization.get()) {
            targetYaw += randomDeviation;
            targetPitch += randomDeviation * 0.5f;
        }

        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // Плавная ротация с настройками HVH
        float yawStep = Math.min(Math.max(Math.abs(yawDiff), 1.0f), hvhRotationSpeed.get());
        float pitchStep = Math.min(Math.max(Math.abs(pitchDiff), 1.0f), hvhPitchSpeed.get());

        if (isAttacking && advancedOptions.getValueByName("Ускорять при атаке").get()) {
            yawStep *= 1.5f;
            pitchStep *= 1.5f;
        }

        float newYaw = rotationVector.x + (yawDiff > 0 ? yawStep : -yawStep);
        float newPitch = clamp(rotationVector.y + (pitchDiff > 0 ? pitchStep : -pitchStep), -89.0F, 89.0F);

        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);

        if (advancedOptions.getValueByName("Корректировка движения").get() && !silentAim.get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }
    }

    private void updateHvHSnapRotation(boolean isAttacking) {
        if (currentTarget == null || mc.player == null) return;

        Vector3d targetPos = calculatePredictedPosition(currentTarget);
        Vector2f targetAngles = calculateSnapAngles(targetPos);

        float targetYaw = targetAngles.x;
        float targetPitch = clamp(targetAngles.y, -89, 89);

        if (randomization.get()) {
            targetYaw += randomDeviation;
            targetPitch += randomDeviation * 0.5f;
        }

        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // HVH снап - быстрый но не мгновенный
        float maxYawChange = hvhRotationSpeed.get() * 3f;
        float maxPitchChange = hvhPitchSpeed.get() * 2f;

        float yawChange = Math.copySign(Math.min(Math.abs(yawDiff), maxYawChange), yawDiff);
        float pitchChange = Math.copySign(Math.min(Math.abs(pitchDiff), maxPitchChange), pitchDiff);

        // Ускорение при атаке
        if (isAttacking && advancedOptions.getValueByName("Ускорять при атаке").get()) {
            yawChange *= 1.8f;
            pitchChange *= 1.5f;
        }

        float newYaw = rotationVector.x + yawChange;
        float newPitch = clamp(rotationVector.y + pitchChange, -89.0F, 89.0F);

        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);

        if (advancedOptions.getValueByName("Корректировка движения").get() && !silentAim.get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }
    }

    private void performAttack() {
        if (currentTarget == null || mc.playerController == null || mc.player == null) return;

        // Проверка паузы при использовании предметов
        if (advancedOptions.getValueByName("Пауза при использовании предметов").get() && isUsingItem()) {
            return;
        }

        // Проверка наведения для ротации
        if (!rotationType.is("Выключена")) {
            selectedEntity = MouseUtil.getMouseOver(currentTarget, rotationVector.x, rotationVector.y, attackRange.get());

            if (advancedOptions.getValueByName("Ускорять при атаке").get()) {
                String currentRotationType = rotationType.get();
                switch (currentRotationType) {
                    case "Снап":
                        // Для снапа просто обновляем (уже мгновенный)
                        break;
                    case "HVH Плавная":
                        updateHvHSmoothRotation(true);
                        break;
                    case "HVH Снап":
                        updateHvHSnapRotation(true);
                        break;
                    case "Плавная":
                        updateSmoothRotation(true);
                        break;
                }
            }

            if ((selectedEntity == null || selectedEntity != currentTarget) && !mc.player.isElytraFlying()) {
                return;
            }
        } else {
            selectedEntity = MouseUtil.getMouseOver(currentTarget, mc.player.rotationYaw, mc.player.rotationPitch, attackRange.get());

            if ((selectedEntity == null || selectedEntity != currentTarget) && !mc.player.isElytraFlying()) {
                return;
            }
        }

        if (mc.player.isBlocking() && advancedOptions.getValueByName("Отжимать щиты").get()) {
            mc.playerController.onStoppedUsingItem(mc.player);
        }

        // Выполнение атаки
        try {
            mc.playerController.attackEntity(mc.player, currentTarget);
            mc.player.swingArm(Hand.MAIN_HAND);

            if (currentTarget instanceof PlayerEntity player && advancedOptions.getValueByName("Ломать щиты").get()) {
                performShieldBreak(player);
            }
        } catch (Exception e) {
            // Игнорирование ошибок атаки
        }
    }

    private boolean isUsingItem() {
        if (mc.player == null) return false;

        return mc.player.isHandActive() && mc.player.getActiveItemStack() != null &&
                (mc.player.getActiveItemStack().getItem().isFood() ||
                        mc.player.getActiveItemStack().getItem().isDrinkable());
    }

    private boolean canAttack() {
        // Проверка паузы при использовании предметов
        if (advancedOptions.getValueByName("Пауза при использовании предметов").get() && isUsingItem()) {
            return false;
        }

        if (advancedOptions.getValueByName("Только с критом").get()) {
            return !mc.player.isOnGround() && mc.player.fallDistance > 0;
        }

        return true;
    }

    private boolean isValidTarget(LivingEntity entity) {
        if (entity == null || entity instanceof ClientPlayerEntity) return false;
        if (mc.player == null) return false;

        if (entity.ticksExisted < 3) return false;
        if (mc.player.getDistance(entity) > attackRange.get()) return false;

        if (entity instanceof PlayerEntity p) {
            if (!targetSelection.getValueByName("Друзья").get() && FriendStorage.isFriend(p.getName().getString())) {
                return false;
            }
            if (p.getName().getString().equals(mc.player.getName().getString())) return false;
        }

        if (entity instanceof PlayerEntity) {
            if (!targetSelection.getValueByName("Игроки").get()) return false;
            if (entity.getTotalArmorValue() == 0 && !targetSelection.getValueByName("Без брони").get()) return false;
            if (entity.isInvisible() && entity.getTotalArmorValue() == 0 &&
                    !targetSelection.getValueByName("Невидимые без брони").get()) return false;
            if (entity.isInvisible() && !targetSelection.getValueByName("Невидимые").get()) return false;
        } else if (entity instanceof MonsterEntity && !targetSelection.getValueByName("Враждебные мобы").get()) {
            return false;
        } else if (entity instanceof AnimalEntity && !targetSelection.getValueByName("Мирные мобы").get()) {
            return false;
        }

        return !entity.isInvulnerable() && entity.isAlive() && !(entity instanceof ArmorStandEntity);
    }

    private void performShieldBreak(PlayerEntity targetPlayer) {
        if (!targetPlayer.isBlocking() || mc.playerController == null) return;

        int inventorySlot = InventoryUtil.getInstance().getAxeInInventory(false);
        int hotbarSlot = InventoryUtil.getInstance().getAxeInInventory(true);

        if (hotbarSlot == -1 && inventorySlot != -1) {
            int bestHotbarSlot = InventoryUtil.getInstance().findBestSlotInHotBar();
            if (bestHotbarSlot == -1) return;

            try {
                mc.playerController.windowClick(0, inventorySlot, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(0, bestHotbarSlot + 36, 0, ClickType.PICKUP, mc.player);

                mc.player.connection.sendPacket(new CHeldItemChangePacket(bestHotbarSlot));
                mc.playerController.attackEntity(mc.player, targetPlayer);
                mc.player.swingArm(Hand.MAIN_HAND);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(mc.player.inventory.currentItem));

                mc.playerController.windowClick(0, bestHotbarSlot + 36, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(0, inventorySlot, 0, ClickType.PICKUP, mc.player);
            } catch (Exception e) {
                // Игнорирование ошибок
            }
        }

        if (hotbarSlot != -1) {
            try {
                mc.player.connection.sendPacket(new CHeldItemChangePacket(hotbarSlot));
                mc.playerController.attackEntity(mc.player, targetPlayer);
                mc.player.swingArm(Hand.MAIN_HAND);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(mc.player.inventory.currentItem));
            } catch (Exception e) {
                // Игнорирование ошибок
            }
        }
    }

    private void resetAll() {
        if (mc.player != null) {
            if (advancedOptions.getValueByName("Корректировка движения").get()) {
                mc.player.rotationYawOffset = Integer.MIN_VALUE;
            }
            rotationVector = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
        }
        randomDeviation = 0f;
        randomDeviationTimer = 0;
        attackTimer = 0;
        canPerformAttack = true;
        currentTarget = null;
        selectedEntity = null;
        isRotating = false;
        rotationTicks = 0;

        // Сброс данных снап ротации
        lastSnapYaw = 0;
        lastSnapPitch = 0;
        snapDelay = 0;
        wasSnapping = false;
        snapCounter = 0;
        snapHistory = new float[10];
        snapHistoryIndex = 0;
        antiAimOffset = 0f;
    }

    @Override
    public void onEnable() {
        super.onEnable();
        resetAll();
    }

    @Override
    public void onDisable() {
        super.onDisable();
        resetAll();
    }

    // Методы для расчета характеристик цели
    private double calculateArmorValue(PlayerEntity player) {
        double armorTotal = 0.0;
        for (int i = 0; i < 4; ++i) {
            ItemStack armorPiece = player.inventory.armorInventory.get(i);
            if (!(armorPiece.getItem() instanceof ArmorItem)) continue;
            armorTotal += getArmorProtectionValue(armorPiece);
        }
        return armorTotal;
    }

    private double getArmorProtectionValue(ItemStack armorStack) {
        if (armorStack.getItem() instanceof ArmorItem armorItem) {
            double baseProtection = armorItem.getDamageReduceAmount();
            if (armorStack.isEnchanted()) {
                baseProtection += (double) EnchantmentHelper.getEnchantmentLevel(Enchantments.PROTECTION, armorStack) * 0.25;
            }
            return baseProtection;
        }
        return 0;
    }

    private double calculateEffectiveHealth(LivingEntity entity) {
        if (entity instanceof PlayerEntity player) {
            return (double) (player.getHealth() + player.getAbsorptionAmount()) * (calculateArmorValue(player) / 20.0);
        }
        return entity.getHealth() + entity.getAbsorptionAmount();
    }

    public LivingEntity getTarget() {
        return null;
    }
}
1:
Expand Collapse Copy
"Выключена", "Выключена",
это че такое нахуй
 
новая селфкод килка для топовых пастеров нафик кто понил тот понял спасиба маему кинту Хз М. за что что предоставил свою топовую килку
вот код
Код:
Expand Collapse Copy
package im.expensive.functions.impl.combat;

import com.google.common.eventbus.Subscribe;
import im.expensive.command.friends.FriendStorage;
import im.expensive.events.EventInput;
import im.expensive.events.EventMotion;
import im.expensive.events.EventUpdate;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.functions.settings.impl.BooleanSetting;
import im.expensive.functions.settings.impl.ModeListSetting;
import im.expensive.functions.settings.impl.ModeSetting;
import im.expensive.functions.settings.impl.SliderSetting;
import im.expensive.utils.math.SensUtils;
import im.expensive.utils.player.InventoryUtil;
import im.expensive.utils.player.MouseUtil;
import im.expensive.utils.player.MoveUtils;
import lombok.Getter;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ArmorStandEntity;
import net.minecraft.entity.monster.MonsterEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.ClickType;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.CHeldItemChangePacket;
import net.minecraft.util.Hand;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Random;

import static java.lang.Math.hypot;
import static net.minecraft.util.math.MathHelper.clamp;
import static net.minecraft.util.math.MathHelper.wrapDegrees;

@FunctionRegister(name = "KillAura", type = Category.Combat)
public class KillAura extends Function {
    @Getter
    private final ModeSetting rotationType = new ModeSetting("Тип ротации", "Выключена", "Выключена", "Плавная", "Снап", "HVH Плавная", "HVH Снап");

    // Основные настройки
    private final SliderSetting attackRange = new SliderSetting("Дальность атаки", 3.2f, 3f, 6f, 0.1f);
    private final SliderSetting fov = new SliderSetting("Поле зрения", 180f, 30f, 360f, 1f);

    // Настройки для снап ротации (мгновенная)
    private final SliderSetting snapAccuracy = new SliderSetting("Точность снапа", 1.0f, 0.5f, 5f, 0.1f);
    private final BooleanSetting snapPrediction = new BooleanSetting("Предсказание траектории", true);
    private final SliderSetting predictionStrength = new SliderSetting("Сила предсказания", 1.5f, 0.5f, 3f, 0.1f);
    private final BooleanSetting snapSilent = new BooleanSetting("Скрытный снап", false);
    private final BooleanSetting snapAntiAim = new BooleanSetting("Противоаим", false);
    private final SliderSetting snapAntiAimAmount = new SliderSetting("Сила противоаима", 5f, 1f, 15f, 0.5f);

    // Настройки для HVH ротаций
    private final SliderSetting hvhRotationSpeed = new SliderSetting("Скорость плавного поворота", 60f, 10f, 360f, 1f);
    private final SliderSetting hvhPitchSpeed = new SliderSetting("Скорость плавного наклона", 40f, 10f, 180f, 1f);
    private final BooleanSetting silentAim = new BooleanSetting("Скрытное наведение", false);
    private final BooleanSetting randomization = new BooleanSetting("Случайные отклонения", false);

    final ModeListSetting targetSelection = new ModeListSetting("Выбор целей",
            new BooleanSetting("Игроки", true),
            new BooleanSetting("Без брони", true),
            new BooleanSetting("Враждебные мобы", false),
            new BooleanSetting("Мирные мобы", false),
            new BooleanSetting("Друзья", false),
            new BooleanSetting("Невидимые без брони", true),
            new BooleanSetting("Невидимые", true));

    @Getter
    final ModeListSetting advancedOptions = new ModeListSetting("Дополнительно",
            new BooleanSetting("Только с критом", false),
            new BooleanSetting("Ломать щиты", true),
            new BooleanSetting("Отжимать щиты", true),
            new BooleanSetting("Ускорять при атаке", true),
            new BooleanSetting("Синхронизация с TPS", false),
            new BooleanSetting("Фиксировать цель", true),
            new BooleanSetting("Корректировка движения", true),
            new BooleanSetting("Пауза при использовании предметов", true),
            new BooleanSetting("Снап при атаке", true));

    final ModeSetting movementCorrection = new ModeSetting("Стиль коррекции", "Плавный", "Плавный", "Агрессивный");

    private Vector2f rotationVector = new Vector2f(0, 0);
    @Getter
    private LivingEntity currentTarget;
    private Entity selectedEntity;

    private int rotationTicks = 0;
    private boolean isRotating;

    // Для снап ротации
    private float lastSnapYaw = 0;
    private float lastSnapPitch = 0;
    private int snapDelay = 0;
    private boolean wasSnapping = false;
    private int snapCounter = 0;
    private float[] snapHistory = new float[10];
    private int snapHistoryIndex = 0;
    private float antiAimOffset = 0f;

    // Для случайных отклонений в HVH
    private float randomDeviation = 0f;
    private int randomDeviationTimer = 0;

    // Таймеры для атаки
    private int attackTimer = 0;
    private boolean canPerformAttack = true;

    private final Random randomGenerator = new Random();
    private final Random snapRandom = new Random();

    public KillAura(AutoPotion autopotion) {
        addSettings(rotationType, attackRange, fov, targetSelection, advancedOptions, movementCorrection);
        addSettings(snapAccuracy, snapPrediction, predictionStrength, snapSilent, snapAntiAim, snapAntiAimAmount);
        addSettings(hvhRotationSpeed, hvhPitchSpeed, silentAim, randomization);
    }

    @Subscribe
    public void onInput(EventInput eventInput) {
        if (!isState() || currentTarget == null || mc.player == null) return;

        if (advancedOptions.getValueByName("Корректировка движения").get() && movementCorrection.is("Плавный")) {
            MoveUtils.fixMovement(eventInput, rotationVector.x);
        }
    }

    @Subscribe
    public void onUpdate(EventUpdate e) {
        if (!isState() || mc.player == null) return;

        // Обновление таймера атаки
        if (attackTimer > 0) {
            attackTimer--;
        } else {
            canPerformAttack = true;
        }

        // Обновление задержки снапа
        if (snapDelay > 0) {
            snapDelay--;
        }

        // Поиск новой цели
        if (advancedOptions.getValueByName("Фиксировать цель").get() && (currentTarget == null || !isValidTarget(currentTarget)) ||
                !advancedOptions.getValueByName("Фиксировать цель").get()) {
            findNewTarget();
        }

        // Обновление случайных отклонений
        if (randomDeviationTimer > 0) {
            randomDeviationTimer--;
        } else if (randomization.get() && (rotationType.is("HVH Плавная") || rotationType.is("HVH Снап"))) {
            randomDeviation = (float) ((randomGenerator.nextFloat() - 0.5) * 10f);
            randomDeviationTimer = 20 + randomGenerator.nextInt(20);
        }

        // Обновление противоаима для снапа
        if (snapAntiAim.get() && rotationType.is("Снап")) {
            antiAimOffset = (float) Math.sin(System.currentTimeMillis() / 200.0) * snapAntiAimAmount.get();
        } else {
            antiAimOffset = 0f;
        }

        if (currentTarget != null) {
            isRotating = false;

            // Обновление ротации в зависимости от выбранного типа
            if (!rotationType.is("Выключена")) {
                String currentRotationType = rotationType.get();
                switch (currentRotationType) {
                    case "Снап":
                        updateSnapRotation();
                        break;
                    case "HVH Плавная":
                        updateHvHSmoothRotation(false);
                        break;
                    case "HVH Снап":
                        updateHvHSnapRotation(false);
                        break;
                    case "Плавная":
                        if (!isRotating) {
                            updateSmoothRotation(false);
                        }
                        break;
                }
            }

            // Проверка условий для атаки
            if (canAttack() && canPerformAttack) {
                performAttack();
                rotationTicks = 2;
                attackTimer = 10;
                canPerformAttack = false;
            }
        } else {
            resetAll();
        }

        // Сохранение истории снапа
        if (rotationType.is("Снап")) {
            snapHistory[snapHistoryIndex] = rotationVector.x;
            snapHistoryIndex = (snapHistoryIndex + 1) % snapHistory.length;
        }
    }

    @Subscribe
    private void onWalking(EventMotion e) {
        if (!isState() || currentTarget == null) return;

        // Для скрытного наведения в HVH режимах и снап ротации
        boolean shouldBeSilent = (rotationType.is("HVH Плавная") || rotationType.is("HVH Снап")) && silentAim.get() ||
                rotationType.is("Снап") && snapSilent.get();

        if (shouldBeSilent) {
            return;
        }

        // Применение ротации
        if (!rotationType.is("Выключена")) {
            float yaw = rotationVector.x;
            float pitch = rotationVector.y;

            // Добавляем противоаим
            if (snapAntiAim.get() && rotationType.is("Снап")) {
                yaw += antiAimOffset;
            }

            e.setYaw(yaw);
            e.setPitch(pitch);
            mc.player.rotationYawHead = yaw;
            mc.player.renderYawOffset = yaw;
            mc.player.rotationPitchHead = pitch;
        }
    }

    private void findNewTarget() {
        if (mc.player == null || mc.world == null) return;

        List<LivingEntity> potentialTargets = new ArrayList<>();

        for (Entity entity : mc.world.getAllEntities()) {
            if (entity instanceof LivingEntity living && isValidTarget(living)) {
                if (isWithinFieldOfView(living)) {
                    potentialTargets.add(living);
                }
            }
        }

        if (potentialTargets.isEmpty()) {
            currentTarget = null;
            return;
        }

        // Сортировка по расстоянию
        potentialTargets.sort(Comparator.comparingDouble(entity -> mc.player.getDistance(entity)));

        currentTarget = potentialTargets.get(0);
    }

    private boolean isWithinFieldOfView(LivingEntity entity) {
        if (fov.get() >= 360f) return true;
        if (mc.player == null) return false;

        Vector3d directionVector = entity.getBoundingBox().getCenter()
                .subtract(mc.player.getEyePosition(1.0F));

        float targetYaw = (float) MathHelper.wrapDegrees(Math.toDegrees(Math.atan2(directionVector.z, directionVector.x)) - 90);
        float targetPitch = (float) (-Math.toDegrees(Math.atan2(directionVector.y, hypot(directionVector.x, directionVector.z))));

        float yawDifference = Math.abs(wrapDegrees(targetYaw - mc.player.rotationYaw));
        float pitchDifference = Math.abs(wrapDegrees(targetPitch - mc.player.rotationPitch));

        return yawDifference <= fov.get() / 2 && pitchDifference <= fov.get() / 2;
    }

    private Vector3d calculatePredictedPosition(LivingEntity target) {
        if (!snapPrediction.get() || target == null) {
            return target.getBoundingBox().getCenter();
        }

        Vector3d currentPos = target.getBoundingBox().getCenter();

        // Получаем вектор движения цели
        Vector3d motion = new Vector3d(
                target.getPosX() - target.prevPosX,
                target.getPosY() - target.prevPosY,
                target.getPosZ() - target.prevPosZ
        );

        // Рассчитываем время полета удара
        double distance = mc.player.getDistance(target);
        double timeToTarget = distance / 8.0; // Примерная скорость удара

        // Усиливаем предсказание
        timeToTarget *= predictionStrength.get();

        // Учитываем вертикальное движение
        if (!target.isOnGround()) {
            motion = motion.add(0, motion.y * 0.5, 0);
        }

        // Предсказанная позиция
        Vector3d predictedPos = currentPos.add(motion.scale(timeToTarget));

        // Минимальная коррекция для стоящих целей
        if (motion.length() < 0.05) {
            predictedPos = currentPos;
        }

        return predictedPos;
    }

    private Vector2f calculateSnapAngles(Vector3d targetPos) {
        if (mc.player == null) return new Vector2f(0, 0);

        Vector3d eyePos = mc.player.getEyePosition(1.0F);
        Vector3d diff = targetPos.subtract(eyePos);

        double diffX = diff.x;
        double diffY = diff.y;
        double diffZ = diff.z;
        double dist = Math.sqrt(diffX * diffX + diffZ * diffZ);

        float yaw = (float) Math.toDegrees(Math.atan2(diffZ, diffX)) - 90.0F;
        float pitch = (float) (-Math.toDegrees(Math.atan2(diffY, dist)));

        // Выбираем кратчайший путь поворота
        float currentYaw = rotationVector.x;
        float deltaYaw = wrapDegrees(yaw - currentYaw);

        if (Math.abs(deltaYaw) > 180) {
            deltaYaw = deltaYaw - Math.copySign(360, deltaYaw);
        }

        yaw = currentYaw + deltaYaw;

        // Ограничиваем угол наклона
        pitch = clamp(pitch, -89, 89);

        // Добавляем точность (случайное отклонение для натуральности)
        float accuracyFactor = 1.0f / snapAccuracy.get();
        if (accuracyFactor > 0.1f) {
            float randomYawOffset = (snapRandom.nextFloat() - 0.5f) * 2f * accuracyFactor;
            float randomPitchOffset = (snapRandom.nextFloat() - 0.5f) * accuracyFactor;

            yaw += randomYawOffset;
            pitch += randomPitchOffset;
        }

        return new Vector2f(wrapDegrees(yaw), pitch);
    }

    private void updateSnapRotation() {
        if (currentTarget == null || mc.player == null || snapDelay > 0) return;

        isRotating = true;

        // Получаем предсказанную позицию
        Vector3d targetPos = calculatePredictedPosition(currentTarget);

        // Рассчитываем углы снапа
        Vector2f snapAngles = calculateSnapAngles(targetPos);
        float targetYaw = snapAngles.x;
        float targetPitch = snapAngles.y;

        // Проверяем, нужно ли делать снап (слишком большой угол или опция "Снап при атаке")
        boolean shouldSnap = shouldPerformSnap(targetYaw, targetPitch);

        if (shouldSnap) {
            // Мгновенный снап
            performInstantSnap(targetYaw, targetPitch);
            snapCounter++;

            // Случайная задержка между снапами для натуральности
            if (snapCounter > 3) {
                snapDelay = 1 + snapRandom.nextInt(2);
                snapCounter = 0;
            }
        } else {
            // Плавный переход к цели
            performSmoothTransition(targetYaw, targetPitch);
        }

        // Корректировка движения
        if (advancedOptions.getValueByName("Корректировка движения").get() && !snapSilent.get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }

        // Сохраняем последние углы
        lastSnapYaw = targetYaw;
        lastSnapPitch = targetPitch;
        wasSnapping = shouldSnap;
    }

    private boolean shouldPerformSnap(float targetYaw, float targetPitch) {
        // Всегда делаем снап при атаке, если опция включена
        if (advancedOptions.getValueByName("Снап при атаке").get() &&
                advancedOptions.getValueByName("Ускорять при атаке").get() &&
                canPerformAttack) {
            return true;
        }

        // Проверяем угол отклонения
        float yawDiff = Math.abs(wrapDegrees(targetYaw - rotationVector.x));
        float pitchDiff = Math.abs(wrapDegrees(targetPitch - rotationVector.y));

        // Делаем снап при большом отклонении
        return yawDiff > 15f || pitchDiff > 8f;
    }

    private void performInstantSnap(float targetYaw, float targetPitch) {
        // Мгновенный снап с учетом GCD
        float newYaw = targetYaw;
        float newPitch = targetPitch;

        // Применяем коррекцию чувствительности
        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            float deltaYaw = newYaw - rotationVector.x;
            float deltaPitch = newPitch - rotationVector.y;

            deltaYaw -= deltaYaw % gcd;
            deltaPitch -= deltaPitch % gcd;

            newYaw = rotationVector.x + deltaYaw;
            newPitch = rotationVector.y + deltaPitch;
        }

        // Ограничиваем угол наклона
        newPitch = clamp(newPitch, -89, 89);

        rotationVector = new Vector2f(newYaw, newPitch);
    }

    private void performSmoothTransition(float targetYaw, float targetPitch) {
        // Плавный переход для небольших корректировок
        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // Медленная корректировка
        float yawStep = yawDiff * 0.3f;
        float pitchStep = pitchDiff * 0.2f;

        float newYaw = rotationVector.x + yawStep;
        float newPitch = clamp(rotationVector.y + pitchStep, -89, 89);

        // GCD коррекция
        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);
    }

    private void updateSmoothRotation(boolean isAttacking) {
        if (currentTarget == null || mc.player == null) return;

        isRotating = true;

        Vector3d targetPos = calculatePredictedPosition(currentTarget);
        Vector2f targetAngles = calculateSnapAngles(targetPos);

        float targetYaw = targetAngles.x;
        float targetPitch = clamp(targetAngles.y, -89, 89);

        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // Плавная интерполяция
        float smoothFactor = isAttacking ? 0.8f : 0.3f;
        float newYaw = rotationVector.x + yawDiff * smoothFactor;
        float newPitch = clamp(rotationVector.y + pitchDiff * smoothFactor, -89, 89);

        // Коррекция чувствительности
        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);

        if (advancedOptions.getValueByName("Корректировка движения").get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }
    }

    private void updateHvHSmoothRotation(boolean isAttacking) {
        if (currentTarget == null || mc.player == null) return;

        Vector3d targetPos = calculatePredictedPosition(currentTarget);
        Vector2f targetAngles = calculateSnapAngles(targetPos);

        float targetYaw = targetAngles.x;
        float targetPitch = clamp(targetAngles.y, -89, 89);

        // Добавление случайных отклонений
        if (randomization.get()) {
            targetYaw += randomDeviation;
            targetPitch += randomDeviation * 0.5f;
        }

        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // Плавная ротация с настройками HVH
        float yawStep = Math.min(Math.max(Math.abs(yawDiff), 1.0f), hvhRotationSpeed.get());
        float pitchStep = Math.min(Math.max(Math.abs(pitchDiff), 1.0f), hvhPitchSpeed.get());

        if (isAttacking && advancedOptions.getValueByName("Ускорять при атаке").get()) {
            yawStep *= 1.5f;
            pitchStep *= 1.5f;
        }

        float newYaw = rotationVector.x + (yawDiff > 0 ? yawStep : -yawStep);
        float newPitch = clamp(rotationVector.y + (pitchDiff > 0 ? pitchStep : -pitchStep), -89.0F, 89.0F);

        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);

        if (advancedOptions.getValueByName("Корректировка движения").get() && !silentAim.get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }
    }

    private void updateHvHSnapRotation(boolean isAttacking) {
        if (currentTarget == null || mc.player == null) return;

        Vector3d targetPos = calculatePredictedPosition(currentTarget);
        Vector2f targetAngles = calculateSnapAngles(targetPos);

        float targetYaw = targetAngles.x;
        float targetPitch = clamp(targetAngles.y, -89, 89);

        if (randomization.get()) {
            targetYaw += randomDeviation;
            targetPitch += randomDeviation * 0.5f;
        }

        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // HVH снап - быстрый но не мгновенный
        float maxYawChange = hvhRotationSpeed.get() * 3f;
        float maxPitchChange = hvhPitchSpeed.get() * 2f;

        float yawChange = Math.copySign(Math.min(Math.abs(yawDiff), maxYawChange), yawDiff);
        float pitchChange = Math.copySign(Math.min(Math.abs(pitchDiff), maxPitchChange), pitchDiff);

        // Ускорение при атаке
        if (isAttacking && advancedOptions.getValueByName("Ускорять при атаке").get()) {
            yawChange *= 1.8f;
            pitchChange *= 1.5f;
        }

        float newYaw = rotationVector.x + yawChange;
        float newPitch = clamp(rotationVector.y + pitchChange, -89.0F, 89.0F);

        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);

        if (advancedOptions.getValueByName("Корректировка движения").get() && !silentAim.get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }
    }

    private void performAttack() {
        if (currentTarget == null || mc.playerController == null || mc.player == null) return;

        // Проверка паузы при использовании предметов
        if (advancedOptions.getValueByName("Пауза при использовании предметов").get() && isUsingItem()) {
            return;
        }

        // Проверка наведения для ротации
        if (!rotationType.is("Выключена")) {
            selectedEntity = MouseUtil.getMouseOver(currentTarget, rotationVector.x, rotationVector.y, attackRange.get());

            if (advancedOptions.getValueByName("Ускорять при атаке").get()) {
                String currentRotationType = rotationType.get();
                switch (currentRotationType) {
                    case "Снап":
                        // Для снапа просто обновляем (уже мгновенный)
                        break;
                    case "HVH Плавная":
                        updateHvHSmoothRotation(true);
                        break;
                    case "HVH Снап":
                        updateHvHSnapRotation(true);
                        break;
                    case "Плавная":
                        updateSmoothRotation(true);
                        break;
                }
            }

            if ((selectedEntity == null || selectedEntity != currentTarget) && !mc.player.isElytraFlying()) {
                return;
            }
        } else {
            selectedEntity = MouseUtil.getMouseOver(currentTarget, mc.player.rotationYaw, mc.player.rotationPitch, attackRange.get());

            if ((selectedEntity == null || selectedEntity != currentTarget) && !mc.player.isElytraFlying()) {
                return;
            }
        }

        if (mc.player.isBlocking() && advancedOptions.getValueByName("Отжимать щиты").get()) {
            mc.playerController.onStoppedUsingItem(mc.player);
        }

        // Выполнение атаки
        try {
            mc.playerController.attackEntity(mc.player, currentTarget);
            mc.player.swingArm(Hand.MAIN_HAND);

            if (currentTarget instanceof PlayerEntity player && advancedOptions.getValueByName("Ломать щиты").get()) {
                performShieldBreak(player);
            }
        } catch (Exception e) {
            // Игнорирование ошибок атаки
        }
    }

    private boolean isUsingItem() {
        if (mc.player == null) return false;

        return mc.player.isHandActive() && mc.player.getActiveItemStack() != null &&
                (mc.player.getActiveItemStack().getItem().isFood() ||
                        mc.player.getActiveItemStack().getItem().isDrinkable());
    }

    private boolean canAttack() {
        // Проверка паузы при использовании предметов
        if (advancedOptions.getValueByName("Пауза при использовании предметов").get() && isUsingItem()) {
            return false;
        }

        if (advancedOptions.getValueByName("Только с критом").get()) {
            return !mc.player.isOnGround() && mc.player.fallDistance > 0;
        }

        return true;
    }

    private boolean isValidTarget(LivingEntity entity) {
        if (entity == null || entity instanceof ClientPlayerEntity) return false;
        if (mc.player == null) return false;

        if (entity.ticksExisted < 3) return false;
        if (mc.player.getDistance(entity) > attackRange.get()) return false;

        if (entity instanceof PlayerEntity p) {
            if (!targetSelection.getValueByName("Друзья").get() && FriendStorage.isFriend(p.getName().getString())) {
                return false;
            }
            if (p.getName().getString().equals(mc.player.getName().getString())) return false;
        }

        if (entity instanceof PlayerEntity) {
            if (!targetSelection.getValueByName("Игроки").get()) return false;
            if (entity.getTotalArmorValue() == 0 && !targetSelection.getValueByName("Без брони").get()) return false;
            if (entity.isInvisible() && entity.getTotalArmorValue() == 0 &&
                    !targetSelection.getValueByName("Невидимые без брони").get()) return false;
            if (entity.isInvisible() && !targetSelection.getValueByName("Невидимые").get()) return false;
        } else if (entity instanceof MonsterEntity && !targetSelection.getValueByName("Враждебные мобы").get()) {
            return false;
        } else if (entity instanceof AnimalEntity && !targetSelection.getValueByName("Мирные мобы").get()) {
            return false;
        }

        return !entity.isInvulnerable() && entity.isAlive() && !(entity instanceof ArmorStandEntity);
    }

    private void performShieldBreak(PlayerEntity targetPlayer) {
        if (!targetPlayer.isBlocking() || mc.playerController == null) return;

        int inventorySlot = InventoryUtil.getInstance().getAxeInInventory(false);
        int hotbarSlot = InventoryUtil.getInstance().getAxeInInventory(true);

        if (hotbarSlot == -1 && inventorySlot != -1) {
            int bestHotbarSlot = InventoryUtil.getInstance().findBestSlotInHotBar();
            if (bestHotbarSlot == -1) return;

            try {
                mc.playerController.windowClick(0, inventorySlot, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(0, bestHotbarSlot + 36, 0, ClickType.PICKUP, mc.player);

                mc.player.connection.sendPacket(new CHeldItemChangePacket(bestHotbarSlot));
                mc.playerController.attackEntity(mc.player, targetPlayer);
                mc.player.swingArm(Hand.MAIN_HAND);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(mc.player.inventory.currentItem));

                mc.playerController.windowClick(0, bestHotbarSlot + 36, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(0, inventorySlot, 0, ClickType.PICKUP, mc.player);
            } catch (Exception e) {
                // Игнорирование ошибок
            }
        }

        if (hotbarSlot != -1) {
            try {
                mc.player.connection.sendPacket(new CHeldItemChangePacket(hotbarSlot));
                mc.playerController.attackEntity(mc.player, targetPlayer);
                mc.player.swingArm(Hand.MAIN_HAND);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(mc.player.inventory.currentItem));
            } catch (Exception e) {
                // Игнорирование ошибок
            }
        }
    }

    private void resetAll() {
        if (mc.player != null) {
            if (advancedOptions.getValueByName("Корректировка движения").get()) {
                mc.player.rotationYawOffset = Integer.MIN_VALUE;
            }
            rotationVector = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
        }
        randomDeviation = 0f;
        randomDeviationTimer = 0;
        attackTimer = 0;
        canPerformAttack = true;
        currentTarget = null;
        selectedEntity = null;
        isRotating = false;
        rotationTicks = 0;

        // Сброс данных снап ротации
        lastSnapYaw = 0;
        lastSnapPitch = 0;
        snapDelay = 0;
        wasSnapping = false;
        snapCounter = 0;
        snapHistory = new float[10];
        snapHistoryIndex = 0;
        antiAimOffset = 0f;
    }

    @Override
    public void onEnable() {
        super.onEnable();
        resetAll();
    }

    @Override
    public void onDisable() {
        super.onDisable();
        resetAll();
    }

    // Методы для расчета характеристик цели
    private double calculateArmorValue(PlayerEntity player) {
        double armorTotal = 0.0;
        for (int i = 0; i < 4; ++i) {
            ItemStack armorPiece = player.inventory.armorInventory.get(i);
            if (!(armorPiece.getItem() instanceof ArmorItem)) continue;
            armorTotal += getArmorProtectionValue(armorPiece);
        }
        return armorTotal;
    }

    private double getArmorProtectionValue(ItemStack armorStack) {
        if (armorStack.getItem() instanceof ArmorItem armorItem) {
            double baseProtection = armorItem.getDamageReduceAmount();
            if (armorStack.isEnchanted()) {
                baseProtection += (double) EnchantmentHelper.getEnchantmentLevel(Enchantments.PROTECTION, armorStack) * 0.25;
            }
            return baseProtection;
        }
        return 0;
    }

    private double calculateEffectiveHealth(LivingEntity entity) {
        if (entity instanceof PlayerEntity player) {
            return (double) (player.getHealth() + player.getAbsorptionAmount()) * (calculateArmorValue(player) / 20.0);
        }
        return entity.getHealth() + entity.getAbsorptionAmount();
    }

    public LivingEntity getTarget() {
        return null;
    }
}
ебанный пиздец /del
 
новая селфкод килка для топовых пастеров нафик кто понил тот понял спасиба маему кинту Хз М. за что что предоставил свою топовую килку
вот код
Код:
Expand Collapse Copy
package im.expensive.functions.impl.combat;

import com.google.common.eventbus.Subscribe;
import im.expensive.command.friends.FriendStorage;
import im.expensive.events.EventInput;
import im.expensive.events.EventMotion;
import im.expensive.events.EventUpdate;
import im.expensive.functions.api.Category;
import im.expensive.functions.api.Function;
import im.expensive.functions.api.FunctionRegister;
import im.expensive.functions.settings.impl.BooleanSetting;
import im.expensive.functions.settings.impl.ModeListSetting;
import im.expensive.functions.settings.impl.ModeSetting;
import im.expensive.functions.settings.impl.SliderSetting;
import im.expensive.utils.math.SensUtils;
import im.expensive.utils.player.InventoryUtil;
import im.expensive.utils.player.MouseUtil;
import im.expensive.utils.player.MoveUtils;
import lombok.Getter;
import net.minecraft.client.entity.player.ClientPlayerEntity;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.item.ArmorStandEntity;
import net.minecraft.entity.monster.MonsterEntity;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.container.ClickType;
import net.minecraft.item.ArmorItem;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.CHeldItemChangePacket;
import net.minecraft.util.Hand;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector2f;
import net.minecraft.util.math.vector.Vector3d;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Random;

import static java.lang.Math.hypot;
import static net.minecraft.util.math.MathHelper.clamp;
import static net.minecraft.util.math.MathHelper.wrapDegrees;

@FunctionRegister(name = "KillAura", type = Category.Combat)
public class KillAura extends Function {
    @Getter
    private final ModeSetting rotationType = new ModeSetting("Тип ротации", "Выключена", "Выключена", "Плавная", "Снап", "HVH Плавная", "HVH Снап");

    // Основные настройки
    private final SliderSetting attackRange = new SliderSetting("Дальность атаки", 3.2f, 3f, 6f, 0.1f);
    private final SliderSetting fov = new SliderSetting("Поле зрения", 180f, 30f, 360f, 1f);

    // Настройки для снап ротации (мгновенная)
    private final SliderSetting snapAccuracy = new SliderSetting("Точность снапа", 1.0f, 0.5f, 5f, 0.1f);
    private final BooleanSetting snapPrediction = new BooleanSetting("Предсказание траектории", true);
    private final SliderSetting predictionStrength = new SliderSetting("Сила предсказания", 1.5f, 0.5f, 3f, 0.1f);
    private final BooleanSetting snapSilent = new BooleanSetting("Скрытный снап", false);
    private final BooleanSetting snapAntiAim = new BooleanSetting("Противоаим", false);
    private final SliderSetting snapAntiAimAmount = new SliderSetting("Сила противоаима", 5f, 1f, 15f, 0.5f);

    // Настройки для HVH ротаций
    private final SliderSetting hvhRotationSpeed = new SliderSetting("Скорость плавного поворота", 60f, 10f, 360f, 1f);
    private final SliderSetting hvhPitchSpeed = new SliderSetting("Скорость плавного наклона", 40f, 10f, 180f, 1f);
    private final BooleanSetting silentAim = new BooleanSetting("Скрытное наведение", false);
    private final BooleanSetting randomization = new BooleanSetting("Случайные отклонения", false);

    final ModeListSetting targetSelection = new ModeListSetting("Выбор целей",
            new BooleanSetting("Игроки", true),
            new BooleanSetting("Без брони", true),
            new BooleanSetting("Враждебные мобы", false),
            new BooleanSetting("Мирные мобы", false),
            new BooleanSetting("Друзья", false),
            new BooleanSetting("Невидимые без брони", true),
            new BooleanSetting("Невидимые", true));

    @Getter
    final ModeListSetting advancedOptions = new ModeListSetting("Дополнительно",
            new BooleanSetting("Только с критом", false),
            new BooleanSetting("Ломать щиты", true),
            new BooleanSetting("Отжимать щиты", true),
            new BooleanSetting("Ускорять при атаке", true),
            new BooleanSetting("Синхронизация с TPS", false),
            new BooleanSetting("Фиксировать цель", true),
            new BooleanSetting("Корректировка движения", true),
            new BooleanSetting("Пауза при использовании предметов", true),
            new BooleanSetting("Снап при атаке", true));

    final ModeSetting movementCorrection = new ModeSetting("Стиль коррекции", "Плавный", "Плавный", "Агрессивный");

    private Vector2f rotationVector = new Vector2f(0, 0);
    @Getter
    private LivingEntity currentTarget;
    private Entity selectedEntity;

    private int rotationTicks = 0;
    private boolean isRotating;

    // Для снап ротации
    private float lastSnapYaw = 0;
    private float lastSnapPitch = 0;
    private int snapDelay = 0;
    private boolean wasSnapping = false;
    private int snapCounter = 0;
    private float[] snapHistory = new float[10];
    private int snapHistoryIndex = 0;
    private float antiAimOffset = 0f;

    // Для случайных отклонений в HVH
    private float randomDeviation = 0f;
    private int randomDeviationTimer = 0;

    // Таймеры для атаки
    private int attackTimer = 0;
    private boolean canPerformAttack = true;

    private final Random randomGenerator = new Random();
    private final Random snapRandom = new Random();

    public KillAura(AutoPotion autopotion) {
        addSettings(rotationType, attackRange, fov, targetSelection, advancedOptions, movementCorrection);
        addSettings(snapAccuracy, snapPrediction, predictionStrength, snapSilent, snapAntiAim, snapAntiAimAmount);
        addSettings(hvhRotationSpeed, hvhPitchSpeed, silentAim, randomization);
    }

    @Subscribe
    public void onInput(EventInput eventInput) {
        if (!isState() || currentTarget == null || mc.player == null) return;

        if (advancedOptions.getValueByName("Корректировка движения").get() && movementCorrection.is("Плавный")) {
            MoveUtils.fixMovement(eventInput, rotationVector.x);
        }
    }

    @Subscribe
    public void onUpdate(EventUpdate e) {
        if (!isState() || mc.player == null) return;

        // Обновление таймера атаки
        if (attackTimer > 0) {
            attackTimer--;
        } else {
            canPerformAttack = true;
        }

        // Обновление задержки снапа
        if (snapDelay > 0) {
            snapDelay--;
        }

        // Поиск новой цели
        if (advancedOptions.getValueByName("Фиксировать цель").get() && (currentTarget == null || !isValidTarget(currentTarget)) ||
                !advancedOptions.getValueByName("Фиксировать цель").get()) {
            findNewTarget();
        }

        // Обновление случайных отклонений
        if (randomDeviationTimer > 0) {
            randomDeviationTimer--;
        } else if (randomization.get() && (rotationType.is("HVH Плавная") || rotationType.is("HVH Снап"))) {
            randomDeviation = (float) ((randomGenerator.nextFloat() - 0.5) * 10f);
            randomDeviationTimer = 20 + randomGenerator.nextInt(20);
        }

        // Обновление противоаима для снапа
        if (snapAntiAim.get() && rotationType.is("Снап")) {
            antiAimOffset = (float) Math.sin(System.currentTimeMillis() / 200.0) * snapAntiAimAmount.get();
        } else {
            antiAimOffset = 0f;
        }

        if (currentTarget != null) {
            isRotating = false;

            // Обновление ротации в зависимости от выбранного типа
            if (!rotationType.is("Выключена")) {
                String currentRotationType = rotationType.get();
                switch (currentRotationType) {
                    case "Снап":
                        updateSnapRotation();
                        break;
                    case "HVH Плавная":
                        updateHvHSmoothRotation(false);
                        break;
                    case "HVH Снап":
                        updateHvHSnapRotation(false);
                        break;
                    case "Плавная":
                        if (!isRotating) {
                            updateSmoothRotation(false);
                        }
                        break;
                }
            }

            // Проверка условий для атаки
            if (canAttack() && canPerformAttack) {
                performAttack();
                rotationTicks = 2;
                attackTimer = 10;
                canPerformAttack = false;
            }
        } else {
            resetAll();
        }

        // Сохранение истории снапа
        if (rotationType.is("Снап")) {
            snapHistory[snapHistoryIndex] = rotationVector.x;
            snapHistoryIndex = (snapHistoryIndex + 1) % snapHistory.length;
        }
    }

    @Subscribe
    private void onWalking(EventMotion e) {
        if (!isState() || currentTarget == null) return;

        // Для скрытного наведения в HVH режимах и снап ротации
        boolean shouldBeSilent = (rotationType.is("HVH Плавная") || rotationType.is("HVH Снап")) && silentAim.get() ||
                rotationType.is("Снап") && snapSilent.get();

        if (shouldBeSilent) {
            return;
        }

        // Применение ротации
        if (!rotationType.is("Выключена")) {
            float yaw = rotationVector.x;
            float pitch = rotationVector.y;

            // Добавляем противоаим
            if (snapAntiAim.get() && rotationType.is("Снап")) {
                yaw += antiAimOffset;
            }

            e.setYaw(yaw);
            e.setPitch(pitch);
            mc.player.rotationYawHead = yaw;
            mc.player.renderYawOffset = yaw;
            mc.player.rotationPitchHead = pitch;
        }
    }

    private void findNewTarget() {
        if (mc.player == null || mc.world == null) return;

        List<LivingEntity> potentialTargets = new ArrayList<>();

        for (Entity entity : mc.world.getAllEntities()) {
            if (entity instanceof LivingEntity living && isValidTarget(living)) {
                if (isWithinFieldOfView(living)) {
                    potentialTargets.add(living);
                }
            }
        }

        if (potentialTargets.isEmpty()) {
            currentTarget = null;
            return;
        }

        // Сортировка по расстоянию
        potentialTargets.sort(Comparator.comparingDouble(entity -> mc.player.getDistance(entity)));

        currentTarget = potentialTargets.get(0);
    }

    private boolean isWithinFieldOfView(LivingEntity entity) {
        if (fov.get() >= 360f) return true;
        if (mc.player == null) return false;

        Vector3d directionVector = entity.getBoundingBox().getCenter()
                .subtract(mc.player.getEyePosition(1.0F));

        float targetYaw = (float) MathHelper.wrapDegrees(Math.toDegrees(Math.atan2(directionVector.z, directionVector.x)) - 90);
        float targetPitch = (float) (-Math.toDegrees(Math.atan2(directionVector.y, hypot(directionVector.x, directionVector.z))));

        float yawDifference = Math.abs(wrapDegrees(targetYaw - mc.player.rotationYaw));
        float pitchDifference = Math.abs(wrapDegrees(targetPitch - mc.player.rotationPitch));

        return yawDifference <= fov.get() / 2 && pitchDifference <= fov.get() / 2;
    }

    private Vector3d calculatePredictedPosition(LivingEntity target) {
        if (!snapPrediction.get() || target == null) {
            return target.getBoundingBox().getCenter();
        }

        Vector3d currentPos = target.getBoundingBox().getCenter();

        // Получаем вектор движения цели
        Vector3d motion = new Vector3d(
                target.getPosX() - target.prevPosX,
                target.getPosY() - target.prevPosY,
                target.getPosZ() - target.prevPosZ
        );

        // Рассчитываем время полета удара
        double distance = mc.player.getDistance(target);
        double timeToTarget = distance / 8.0; // Примерная скорость удара

        // Усиливаем предсказание
        timeToTarget *= predictionStrength.get();

        // Учитываем вертикальное движение
        if (!target.isOnGround()) {
            motion = motion.add(0, motion.y * 0.5, 0);
        }

        // Предсказанная позиция
        Vector3d predictedPos = currentPos.add(motion.scale(timeToTarget));

        // Минимальная коррекция для стоящих целей
        if (motion.length() < 0.05) {
            predictedPos = currentPos;
        }

        return predictedPos;
    }

    private Vector2f calculateSnapAngles(Vector3d targetPos) {
        if (mc.player == null) return new Vector2f(0, 0);

        Vector3d eyePos = mc.player.getEyePosition(1.0F);
        Vector3d diff = targetPos.subtract(eyePos);

        double diffX = diff.x;
        double diffY = diff.y;
        double diffZ = diff.z;
        double dist = Math.sqrt(diffX * diffX + diffZ * diffZ);

        float yaw = (float) Math.toDegrees(Math.atan2(diffZ, diffX)) - 90.0F;
        float pitch = (float) (-Math.toDegrees(Math.atan2(diffY, dist)));

        // Выбираем кратчайший путь поворота
        float currentYaw = rotationVector.x;
        float deltaYaw = wrapDegrees(yaw - currentYaw);

        if (Math.abs(deltaYaw) > 180) {
            deltaYaw = deltaYaw - Math.copySign(360, deltaYaw);
        }

        yaw = currentYaw + deltaYaw;

        // Ограничиваем угол наклона
        pitch = clamp(pitch, -89, 89);

        // Добавляем точность (случайное отклонение для натуральности)
        float accuracyFactor = 1.0f / snapAccuracy.get();
        if (accuracyFactor > 0.1f) {
            float randomYawOffset = (snapRandom.nextFloat() - 0.5f) * 2f * accuracyFactor;
            float randomPitchOffset = (snapRandom.nextFloat() - 0.5f) * accuracyFactor;

            yaw += randomYawOffset;
            pitch += randomPitchOffset;
        }

        return new Vector2f(wrapDegrees(yaw), pitch);
    }

    private void updateSnapRotation() {
        if (currentTarget == null || mc.player == null || snapDelay > 0) return;

        isRotating = true;

        // Получаем предсказанную позицию
        Vector3d targetPos = calculatePredictedPosition(currentTarget);

        // Рассчитываем углы снапа
        Vector2f snapAngles = calculateSnapAngles(targetPos);
        float targetYaw = snapAngles.x;
        float targetPitch = snapAngles.y;

        // Проверяем, нужно ли делать снап (слишком большой угол или опция "Снап при атаке")
        boolean shouldSnap = shouldPerformSnap(targetYaw, targetPitch);

        if (shouldSnap) {
            // Мгновенный снап
            performInstantSnap(targetYaw, targetPitch);
            snapCounter++;

            // Случайная задержка между снапами для натуральности
            if (snapCounter > 3) {
                snapDelay = 1 + snapRandom.nextInt(2);
                snapCounter = 0;
            }
        } else {
            // Плавный переход к цели
            performSmoothTransition(targetYaw, targetPitch);
        }

        // Корректировка движения
        if (advancedOptions.getValueByName("Корректировка движения").get() && !snapSilent.get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }

        // Сохраняем последние углы
        lastSnapYaw = targetYaw;
        lastSnapPitch = targetPitch;
        wasSnapping = shouldSnap;
    }

    private boolean shouldPerformSnap(float targetYaw, float targetPitch) {
        // Всегда делаем снап при атаке, если опция включена
        if (advancedOptions.getValueByName("Снап при атаке").get() &&
                advancedOptions.getValueByName("Ускорять при атаке").get() &&
                canPerformAttack) {
            return true;
        }

        // Проверяем угол отклонения
        float yawDiff = Math.abs(wrapDegrees(targetYaw - rotationVector.x));
        float pitchDiff = Math.abs(wrapDegrees(targetPitch - rotationVector.y));

        // Делаем снап при большом отклонении
        return yawDiff > 15f || pitchDiff > 8f;
    }

    private void performInstantSnap(float targetYaw, float targetPitch) {
        // Мгновенный снап с учетом GCD
        float newYaw = targetYaw;
        float newPitch = targetPitch;

        // Применяем коррекцию чувствительности
        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            float deltaYaw = newYaw - rotationVector.x;
            float deltaPitch = newPitch - rotationVector.y;

            deltaYaw -= deltaYaw % gcd;
            deltaPitch -= deltaPitch % gcd;

            newYaw = rotationVector.x + deltaYaw;
            newPitch = rotationVector.y + deltaPitch;
        }

        // Ограничиваем угол наклона
        newPitch = clamp(newPitch, -89, 89);

        rotationVector = new Vector2f(newYaw, newPitch);
    }

    private void performSmoothTransition(float targetYaw, float targetPitch) {
        // Плавный переход для небольших корректировок
        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // Медленная корректировка
        float yawStep = yawDiff * 0.3f;
        float pitchStep = pitchDiff * 0.2f;

        float newYaw = rotationVector.x + yawStep;
        float newPitch = clamp(rotationVector.y + pitchStep, -89, 89);

        // GCD коррекция
        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);
    }

    private void updateSmoothRotation(boolean isAttacking) {
        if (currentTarget == null || mc.player == null) return;

        isRotating = true;

        Vector3d targetPos = calculatePredictedPosition(currentTarget);
        Vector2f targetAngles = calculateSnapAngles(targetPos);

        float targetYaw = targetAngles.x;
        float targetPitch = clamp(targetAngles.y, -89, 89);

        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // Плавная интерполяция
        float smoothFactor = isAttacking ? 0.8f : 0.3f;
        float newYaw = rotationVector.x + yawDiff * smoothFactor;
        float newPitch = clamp(rotationVector.y + pitchDiff * smoothFactor, -89, 89);

        // Коррекция чувствительности
        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);

        if (advancedOptions.getValueByName("Корректировка движения").get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }
    }

    private void updateHvHSmoothRotation(boolean isAttacking) {
        if (currentTarget == null || mc.player == null) return;

        Vector3d targetPos = calculatePredictedPosition(currentTarget);
        Vector2f targetAngles = calculateSnapAngles(targetPos);

        float targetYaw = targetAngles.x;
        float targetPitch = clamp(targetAngles.y, -89, 89);

        // Добавление случайных отклонений
        if (randomization.get()) {
            targetYaw += randomDeviation;
            targetPitch += randomDeviation * 0.5f;
        }

        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // Плавная ротация с настройками HVH
        float yawStep = Math.min(Math.max(Math.abs(yawDiff), 1.0f), hvhRotationSpeed.get());
        float pitchStep = Math.min(Math.max(Math.abs(pitchDiff), 1.0f), hvhPitchSpeed.get());

        if (isAttacking && advancedOptions.getValueByName("Ускорять при атаке").get()) {
            yawStep *= 1.5f;
            pitchStep *= 1.5f;
        }

        float newYaw = rotationVector.x + (yawDiff > 0 ? yawStep : -yawStep);
        float newPitch = clamp(rotationVector.y + (pitchDiff > 0 ? pitchStep : -pitchStep), -89.0F, 89.0F);

        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);

        if (advancedOptions.getValueByName("Корректировка движения").get() && !silentAim.get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }
    }

    private void updateHvHSnapRotation(boolean isAttacking) {
        if (currentTarget == null || mc.player == null) return;

        Vector3d targetPos = calculatePredictedPosition(currentTarget);
        Vector2f targetAngles = calculateSnapAngles(targetPos);

        float targetYaw = targetAngles.x;
        float targetPitch = clamp(targetAngles.y, -89, 89);

        if (randomization.get()) {
            targetYaw += randomDeviation;
            targetPitch += randomDeviation * 0.5f;
        }

        float yawDiff = wrapDegrees(targetYaw - rotationVector.x);
        float pitchDiff = wrapDegrees(targetPitch - rotationVector.y);

        // HVH снап - быстрый но не мгновенный
        float maxYawChange = hvhRotationSpeed.get() * 3f;
        float maxPitchChange = hvhPitchSpeed.get() * 2f;

        float yawChange = Math.copySign(Math.min(Math.abs(yawDiff), maxYawChange), yawDiff);
        float pitchChange = Math.copySign(Math.min(Math.abs(pitchDiff), maxPitchChange), pitchDiff);

        // Ускорение при атаке
        if (isAttacking && advancedOptions.getValueByName("Ускорять при атаке").get()) {
            yawChange *= 1.8f;
            pitchChange *= 1.5f;
        }

        float newYaw = rotationVector.x + yawChange;
        float newPitch = clamp(rotationVector.y + pitchChange, -89.0F, 89.0F);

        float gcd = SensUtils.getGCDValue();
        if (gcd > 0) {
            newYaw -= (newYaw - rotationVector.x) % gcd;
            newPitch -= (newPitch - rotationVector.y) % gcd;
        }

        rotationVector = new Vector2f(newYaw, newPitch);

        if (advancedOptions.getValueByName("Корректировка движения").get() && !silentAim.get()) {
            mc.player.rotationYawOffset = rotationVector.x;
        }
    }

    private void performAttack() {
        if (currentTarget == null || mc.playerController == null || mc.player == null) return;

        // Проверка паузы при использовании предметов
        if (advancedOptions.getValueByName("Пауза при использовании предметов").get() && isUsingItem()) {
            return;
        }

        // Проверка наведения для ротации
        if (!rotationType.is("Выключена")) {
            selectedEntity = MouseUtil.getMouseOver(currentTarget, rotationVector.x, rotationVector.y, attackRange.get());

            if (advancedOptions.getValueByName("Ускорять при атаке").get()) {
                String currentRotationType = rotationType.get();
                switch (currentRotationType) {
                    case "Снап":
                        // Для снапа просто обновляем (уже мгновенный)
                        break;
                    case "HVH Плавная":
                        updateHvHSmoothRotation(true);
                        break;
                    case "HVH Снап":
                        updateHvHSnapRotation(true);
                        break;
                    case "Плавная":
                        updateSmoothRotation(true);
                        break;
                }
            }

            if ((selectedEntity == null || selectedEntity != currentTarget) && !mc.player.isElytraFlying()) {
                return;
            }
        } else {
            selectedEntity = MouseUtil.getMouseOver(currentTarget, mc.player.rotationYaw, mc.player.rotationPitch, attackRange.get());

            if ((selectedEntity == null || selectedEntity != currentTarget) && !mc.player.isElytraFlying()) {
                return;
            }
        }

        if (mc.player.isBlocking() && advancedOptions.getValueByName("Отжимать щиты").get()) {
            mc.playerController.onStoppedUsingItem(mc.player);
        }

        // Выполнение атаки
        try {
            mc.playerController.attackEntity(mc.player, currentTarget);
            mc.player.swingArm(Hand.MAIN_HAND);

            if (currentTarget instanceof PlayerEntity player && advancedOptions.getValueByName("Ломать щиты").get()) {
                performShieldBreak(player);
            }
        } catch (Exception e) {
            // Игнорирование ошибок атаки
        }
    }

    private boolean isUsingItem() {
        if (mc.player == null) return false;

        return mc.player.isHandActive() && mc.player.getActiveItemStack() != null &&
                (mc.player.getActiveItemStack().getItem().isFood() ||
                        mc.player.getActiveItemStack().getItem().isDrinkable());
    }

    private boolean canAttack() {
        // Проверка паузы при использовании предметов
        if (advancedOptions.getValueByName("Пауза при использовании предметов").get() && isUsingItem()) {
            return false;
        }

        if (advancedOptions.getValueByName("Только с критом").get()) {
            return !mc.player.isOnGround() && mc.player.fallDistance > 0;
        }

        return true;
    }

    private boolean isValidTarget(LivingEntity entity) {
        if (entity == null || entity instanceof ClientPlayerEntity) return false;
        if (mc.player == null) return false;

        if (entity.ticksExisted < 3) return false;
        if (mc.player.getDistance(entity) > attackRange.get()) return false;

        if (entity instanceof PlayerEntity p) {
            if (!targetSelection.getValueByName("Друзья").get() && FriendStorage.isFriend(p.getName().getString())) {
                return false;
            }
            if (p.getName().getString().equals(mc.player.getName().getString())) return false;
        }

        if (entity instanceof PlayerEntity) {
            if (!targetSelection.getValueByName("Игроки").get()) return false;
            if (entity.getTotalArmorValue() == 0 && !targetSelection.getValueByName("Без брони").get()) return false;
            if (entity.isInvisible() && entity.getTotalArmorValue() == 0 &&
                    !targetSelection.getValueByName("Невидимые без брони").get()) return false;
            if (entity.isInvisible() && !targetSelection.getValueByName("Невидимые").get()) return false;
        } else if (entity instanceof MonsterEntity && !targetSelection.getValueByName("Враждебные мобы").get()) {
            return false;
        } else if (entity instanceof AnimalEntity && !targetSelection.getValueByName("Мирные мобы").get()) {
            return false;
        }

        return !entity.isInvulnerable() && entity.isAlive() && !(entity instanceof ArmorStandEntity);
    }

    private void performShieldBreak(PlayerEntity targetPlayer) {
        if (!targetPlayer.isBlocking() || mc.playerController == null) return;

        int inventorySlot = InventoryUtil.getInstance().getAxeInInventory(false);
        int hotbarSlot = InventoryUtil.getInstance().getAxeInInventory(true);

        if (hotbarSlot == -1 && inventorySlot != -1) {
            int bestHotbarSlot = InventoryUtil.getInstance().findBestSlotInHotBar();
            if (bestHotbarSlot == -1) return;

            try {
                mc.playerController.windowClick(0, inventorySlot, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(0, bestHotbarSlot + 36, 0, ClickType.PICKUP, mc.player);

                mc.player.connection.sendPacket(new CHeldItemChangePacket(bestHotbarSlot));
                mc.playerController.attackEntity(mc.player, targetPlayer);
                mc.player.swingArm(Hand.MAIN_HAND);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(mc.player.inventory.currentItem));

                mc.playerController.windowClick(0, bestHotbarSlot + 36, 0, ClickType.PICKUP, mc.player);
                mc.playerController.windowClick(0, inventorySlot, 0, ClickType.PICKUP, mc.player);
            } catch (Exception e) {
                // Игнорирование ошибок
            }
        }

        if (hotbarSlot != -1) {
            try {
                mc.player.connection.sendPacket(new CHeldItemChangePacket(hotbarSlot));
                mc.playerController.attackEntity(mc.player, targetPlayer);
                mc.player.swingArm(Hand.MAIN_HAND);
                mc.player.connection.sendPacket(new CHeldItemChangePacket(mc.player.inventory.currentItem));
            } catch (Exception e) {
                // Игнорирование ошибок
            }
        }
    }

    private void resetAll() {
        if (mc.player != null) {
            if (advancedOptions.getValueByName("Корректировка движения").get()) {
                mc.player.rotationYawOffset = Integer.MIN_VALUE;
            }
            rotationVector = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
        }
        randomDeviation = 0f;
        randomDeviationTimer = 0;
        attackTimer = 0;
        canPerformAttack = true;
        currentTarget = null;
        selectedEntity = null;
        isRotating = false;
        rotationTicks = 0;

        // Сброс данных снап ротации
        lastSnapYaw = 0;
        lastSnapPitch = 0;
        snapDelay = 0;
        wasSnapping = false;
        snapCounter = 0;
        snapHistory = new float[10];
        snapHistoryIndex = 0;
        antiAimOffset = 0f;
    }

    @Override
    public void onEnable() {
        super.onEnable();
        resetAll();
    }

    @Override
    public void onDisable() {
        super.onDisable();
        resetAll();
    }

    // Методы для расчета характеристик цели
    private double calculateArmorValue(PlayerEntity player) {
        double armorTotal = 0.0;
        for (int i = 0; i < 4; ++i) {
            ItemStack armorPiece = player.inventory.armorInventory.get(i);
            if (!(armorPiece.getItem() instanceof ArmorItem)) continue;
            armorTotal += getArmorProtectionValue(armorPiece);
        }
        return armorTotal;
    }

    private double getArmorProtectionValue(ItemStack armorStack) {
        if (armorStack.getItem() instanceof ArmorItem armorItem) {
            double baseProtection = armorItem.getDamageReduceAmount();
            if (armorStack.isEnchanted()) {
                baseProtection += (double) EnchantmentHelper.getEnchantmentLevel(Enchantments.PROTECTION, armorStack) * 0.25;
            }
            return baseProtection;
        }
        return 0;
    }

    private double calculateEffectiveHealth(LivingEntity entity) {
        if (entity instanceof PlayerEntity player) {
            return (double) (player.getHealth() + player.getAbsorptionAmount()) * (calculateArmorValue(player) / 20.0);
        }
        return entity.getHealth() + entity.getAbsorptionAmount();
    }

    public LivingEntity getTarget() {
        return null;
    }
}
чел курсор тут явно не подходит под слово кент...
 
Назад
Сверху Снизу