Подписывайтесь на наш Telegram и не пропускайте важные новости! Перейти

Вопрос AI aura

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
21 Фев 2024
Сообщения
177
Реакции
1
код:
Expand Collapse Copy
package org.sheluvparis.excellent.client.impl.feature.impl.combat;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.experimental.Accessors;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.AxeItem;
import net.minecraft.item.SwordItem;
import net.minecraft.network.IPacket;
import net.minecraft.network.play.client.CEntityActionPacket;
import net.minecraft.network.play.client.CUseEntityPacket;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.vector.Vector3d;
import org.joml.Vector2f;
import org.sheluvparis.common.animation.Easings;
import org.sheluvparis.common.events.orbit.EventHandler;
import org.sheluvparis.common.script.Script;
import org.sheluvparis.excellent.client.events.other.GameUpdateEvent;
import org.sheluvparis.excellent.client.events.other.PacketEvent;
import org.sheluvparis.excellent.client.events.player.PlayerMoveEvent;
import org.sheluvparis.excellent.client.events.player.UpdateEvent;
import org.sheluvparis.excellent.client.events.world.WorldChangeEvent;
import org.sheluvparis.excellent.client.events.world.WorldLoadEvent;
import org.sheluvparis.excellent.client.impl.component.impl.notification.Notification;
import org.sheluvparis.excellent.client.impl.component.impl.notification.NotificationComponent;
import org.sheluvparis.excellent.client.impl.component.impl.notification.NotificationType;
import org.sheluvparis.excellent.client.impl.component.impl.rotation.Rotation;
import org.sheluvparis.excellent.client.impl.component.impl.rotation.RotationComponent;
import org.sheluvparis.excellent.client.impl.component.impl.target.TargetComponent;
import org.sheluvparis.excellent.client.impl.feature.Category;
import org.sheluvparis.excellent.client.impl.feature.Feature;
import org.sheluvparis.excellent.client.impl.feature.FeatureInfo;
import org.sheluvparis.excellent.client.impl.neuro.AimPredictor;
import org.sheluvparis.excellent.client.impl.neuro.AngleUtil;
import org.sheluvparis.excellent.client.impl.settings.impl.BooleanSetting;
import org.sheluvparis.excellent.client.impl.settings.impl.ListSetting;
import org.sheluvparis.excellent.client.impl.settings.impl.MultiBooleanSetting;
import org.sheluvparis.excellent.client.impl.settings.impl.SliderSetting;
import org.sheluvparis.excellent.client.util.combat.AuraUtil;
import org.sheluvparis.excellent.client.util.combat.RayTraceUtil;
import org.sheluvparis.excellent.client.util.combat.RotationUtil;
import org.sheluvparis.excellent.client.util.math.Lerp;
import org.sheluvparis.excellent.client.util.math.Mathf;
import org.sheluvparis.excellent.client.util.math.Wave;
import org.sheluvparis.excellent.client.util.player.PlayerUtil;
import org.sheluvparis.excellent.client.util.resource.ClientResource;

import java.util.Arrays;
import java.util.List;

@Getter
@Accessors(fluent = true)
@FeatureInfo(name = "Aura", category = Category.COMBAT)
public class FuckAura extends Feature {

    private final AimPredictor predictor = new AimPredictor();
    private final ListSetting<RotationMode> rotationMode = new ListSetting<>("Rotation Mode", RotationMode.values())
            .onAction(() -> {
                if (rotationMode().get().equals(RotationMode.NEURO)) {
                    if (predictor().isLoaded()) {
                        NotificationComponent.register(new Notification(NotificationType.INFO, () -> "Unloading rotation model.", 1500));
                        predictor().close();
                    }
                    loadModel();
                    NotificationComponent.register(new Notification(NotificationType.INFO, () -> "Rotation model is loaded.", 1500));
                }
            });
    private final ListSetting<AttackMode> attackMode = new ListSetting<>("Attack Mode", AttackMode.values());
    private final ListSetting<SprintMode> sprintMode = new ListSetting<>("Sprint Mode", SprintMode.values());
    private final SliderSetting turnSpeed = new SliderSetting("Turn Speed", 90F, 1F, 180F, 1F);
    private final SliderSetting resetSpeed = new SliderSetting("Return Speed", 45F, 1F, 180F, 1F);
    private final SliderSetting attackRange = new SliderSetting("Distance", 3F, 3F, 6F, 0.1F);

    private final MultiBooleanSetting checks = new MultiBooleanSetting("Settings",
            BooleanSetting.of("Ray Trace"),
            BooleanSetting.of("Only Weapon"),
            BooleanSetting.of("Disable On Death"),
            BooleanSetting.of("Disable When Eating")
    );

    public LivingEntity target;
    public boolean canCrit;
    private final Script script = new Script();

    private void loadModel() {
        predictor.loadModel(new ClientResource("model/aim_dataset.csv"));
    }

    @Override
    public void toggle() {
        reset();
        super.toggle();
    }

    @Override
    protected void onEnable(){
        if (rotationMode.is("Neuro") && !predictor.isLoaded()) {
            predictor.loadModel(
                    new ClientResource("models/aim_model.cbm")
            );
            loadModel();
            if(!predictor.isLoaded()){
                NotificationComponent.register(new Notification(NotificationType.INFO, () -> "Модель не загрузилась обратилась к WEXTER5", 1500));
                System.out.println("Модель не загрузилась обратилась к WEXTER5");
            }else {
                System.out.println("Модель загрузилась");
            }
            NotificationComponent.register(new Notification(NotificationType.INFO, () -> "Rotation model is loaded.", 1500));
        }
        super.onEnable();
    }

    @Override
    protected void onDisable() {
        if (rotationMode.is("Neuro") && predictor.isLoaded()) {
            NotificationComponent.register(new Notification(NotificationType.INFO, () -> "Unloading rotation model.", 1500));
            predictor.close();
        }
        super.onDisable();
    }

    @EventHandler
    public void onEvent(WorldChangeEvent event) {
        reset();
    }

    @EventHandler
    public void onEvent(WorldLoadEvent event) {
        reset();
    }

    @EventHandler
    public void onEvent(PlayerMoveEvent event) {
        canCrit = !event.isToGround() && event.getFrom().y > event.getTo().y;
    }

    @EventHandler
    public void onEvent(PacketEvent event) {
        if (target == null || checknull()) {
            return;
        }
        final IPacket<?> packet = event.getPacket();
        if (packet instanceof CUseEntityPacket wrapper && !wrapper.getAction().equals(CUseEntityPacket.Action.ATTACK)) {
            event.cancel();
        }
    }

    @EventHandler
    public void onEvent(GameUpdateEvent event) throws Exception {
        if (target == null || checknull()) {
            canCrit = false;
            return;
        }

        if (checkReturn()) return;

        if (rotationMode.get().equals(RotationMode.NEURO) && predictor.isLoaded()) {
            loadModel();
            updateRotation();
        }
    }


    @EventHandler
    public void onEvent(UpdateEvent event) {
        script.update();
        if (checks.enabled("Disable On Death") && !mc.player.isAlive()) {
            toggle();
            return;
        }

        updateTarget();

        if (target == null || checknull()) {
            canCrit = false;
            return;
        }

        if (checkReturn()) return;

        updateAttack();
    }

    private void updateRotation() throws Exception {
        loadModel();
        if (target == null || !predictor.isLoaded()) {
            return;
        }

        float currentYaw = mc.player.rotationYaw;
        float currentPitch = mc.player.rotationPitch;

        Vector2f targetRot = RotationUtil.calculate(target);
        float targetYaw = targetRot.x;
        float targetPitch = targetRot.y;

        float yawDeltaToTarget = AngleUtil.normalizeYaw(targetYaw - currentYaw);
        float pitchDeltaToTarget = AngleUtil.normalizePitch(targetPitch - currentPitch);

        float distance = (float) mc.player.getPositionVec().distanceTo(target.getPositionVec());
        float ticksSinceLastAttack = mc.player.getCooledAttackStrength(1.0F);
        float onGround = mc.player.isOnGround() ? 1.0F : 0.0F;

        Vector3d targetMotion = target.getMotion();
        Vector3d playerMotion = mc.player.getMotion();

        float deltaX = (float) (target.getPosX() - mc.player.getPosX());
        float deltaY = (float) (target.getPosY() - mc.player.getPosY());
        float deltaZ = (float) (target.getPosZ() - mc.player.getPosZ());

        float[] features = new float[]{
                yawDeltaToTarget,
                pitchDeltaToTarget,

                AngleUtil.normalizeYaw(currentYaw),
                AngleUtil.normalizePitch(currentPitch),

                ticksSinceLastAttack,
                distance,
                onGround,

                deltaX,
                deltaY,
                deltaZ,

                (float) targetMotion.x,
                (float) targetMotion.y,
                (float) targetMotion.z,

                (float) playerMotion.x,
                (float) playerMotion.y,
                (float) playerMotion.z
        };

        float[] prediction = predictor.predict(features);

        float deltaYaw = prediction[0];
        float deltaPitch = prediction[1];

        float aimYaw = AngleUtil.normalizeYaw(currentYaw + deltaYaw);
        float aimPitch = MathHelper.clamp(
                currentPitch + deltaPitch,
                -90.0F,
                90.0F
        );

        float yawDiff = MathHelper.wrapDegrees(aimYaw - currentYaw);
        float pitchDiff = aimPitch - currentPitch;

        float maxYawChange = turnSpeed.get() / 3.0F;
        float maxPitchChange = turnSpeed.get() / 3.0F;

        yawDiff = MathHelper.clamp(yawDiff, -maxYawChange, maxYawChange);
        pitchDiff = MathHelper.clamp(pitchDiff, -maxPitchChange, maxPitchChange);

        RotationComponent.update(
                new Rotation(
                        currentYaw + yawDiff,
                        currentPitch + pitchDiff
                ),
                turnSpeed.get(),
                resetSpeed.get(),
                Mathf.random(10, 14),
                Mathf.random(5, 7),
                1,
                5,
                false
        );
        System.out.println(
                "dYaw=" + deltaYaw +
                        " dPitch=" + deltaPitch +
                        " yawDiff=" + yawDiff
        );
    }


    private void updateAttack() {
        double distance = AuraUtil.getStrictDistance(target);
        if (shouldAttack(target) && distance < attackDistance()) {
            if (!checks.enabled("Ray Trace") || rayTrace()) {
                boolean isInLiquid = isInLiquid();
                boolean sprinting = mc.player.isSprinting() || mc.player.isServerSprintState();
                boolean check = !isInLiquid && sprinting;
                if (check) {
                    if (sprintMode.get().equals(SprintMode.ADAPTIVE)) {
                        if (script.isFinished()) {
                            mc.player.connection.sendPacket(new CEntityActionPacket(mc.player, CEntityActionPacket.Action.STOP_SPRINTING));
                            mc.player.setServerSprintState(false);
                            mc.player.setSprinting(false);
                        }
                    } else {
                        mc.player.connection.sendPacket(new CEntityActionPacket(mc.player, CEntityActionPacket.Action.STOP_SPRINTING));
                        mc.player.setServerSprintState(false);
                        mc.player.setSprinting(false);
                    }
                }
                attackEntity(target);

                if (check && !sprintMode.get().equals(SprintMode.PRE)) {
                    if (sprintMode.get().equals(SprintMode.ADAPTIVE)) {
                        if (script.isFinished()) {
                            script.addTickStep(1, () -> {
                                mc.player.setSprinting(true);
                                mc.player.setServerSprintState(true);
                                mc.player.connection.sendPacket(new CEntityActionPacket(mc.player, CEntityActionPacket.Action.START_SPRINTING));
                            });
                        }
                    } else {
                        mc.player.setSprinting(true);
                        mc.player.setServerSprintState(true);
                        mc.player.connection.sendPacket(new CEntityActionPacket(mc.player, CEntityActionPacket.Action.START_SPRINTING));
                    }
                }
                canCrit = false;
            }
        }
    }


    @SuppressWarnings("RedundantIfStatement")
    private boolean checkReturn() {
        if (checks.enabled("Disable When Eating") && mc.player.isHandActive() && mc.player.getActiveItemStack().getItem().getFood() != null) {
            return true;
        }
        if (checks.enabled("Only Weapon") && (!(mc.player.getHeldItemMainhand().getItem() instanceof AxeItem || mc.player.getHeldItemMainhand().getItem() instanceof SwordItem))) {
            return true;
        }
        return false;
    }

    private void attackEntity(Entity entity) {
        mc.playerController.attackEntity(mc.player, entity);
        mc.player.swingArm(Hand.MAIN_HAND);
    }

    private void updateTarget() {
        target = TargetComponent.getTarget(attackRange.get() + 3F);
    }

    private static boolean isInLiquid() {
        return mc.player.isActualySwimming() || mc.player.isSwimming() && mc.player.areEyesInFluid(FluidTags.WATER) || mc.player.areEyesInFluid(FluidTags.LAVA);
    }

    private boolean shouldAttack(LivingEntity target) {
        if (target.hurtTime != 0) return false;
        if (!cooldownComplete()) return false;
        if (isInLiquid()) return true;

        boolean canDefaultCrit = isCanDefaultCrit();
        boolean canSmartCrit = isCanSmartCrit();
        boolean isYCap = getYCap(2) < 0.1F;

        if (attackMode.get().equals(AttackMode.ONLY_CRIT)) {
            return shouldCritical() && canDefaultCrit || isYCap;
        }
        if (attackMode.get().equals(AttackMode.ADAPTIVE)) {
            return ((shouldCritical() && canDefaultCrit) || canSmartCrit) || isYCap;
        }
        return attackMode.get().equals(AttackMode.ALWAYS);
    }

    private boolean isCanDefaultCrit() {
        return canCrit;
    }

    private boolean isCanSmartCrit() {
        return !mc.player.movementInput.jump && !canCrit && mc.player.isOnGround() && mc.player.onGroundTicks >= 2;
    }

    public static double getYCap(int rangeY) {
        if (checknull()) return 1.0F;

        Vector3d pos = mc.player.getEyePosition(mc.getRenderPartialTicks());
        double minDist = rangeY * 2.0F;
        double maxY = 320;
        double minY = -64;
        double width = mc.player.getWidth() / 2.0F;

        for (Vector3d corner : getCorners(pos, width)) {
            RayTraceResult above = traceRay(corner, rangeY, false);
            RayTraceResult below = traceRay(corner, rangeY, true);

            maxY = Math.min(maxY, above.getHitVec().y);
            minY = Math.max(minY, below.getHitVec().y);

            double dist = maxY - minY;
            if (minDist > dist) minDist = dist;
        }

        return minDist - mc.player.getHeight();
    }

    private static List<Vector3d> getCorners(Vector3d pos, double offset) {
        return Arrays.asList(
                pos.add(-offset, 0.0, -offset),
                pos.add(offset, 0.0, offset),
                pos.add(offset, 0.0, -offset),
                pos.add(-offset, 0.0, offset)
        );
    }

    private static RayTraceResult traceRay(Vector3d pos, int rangeY, boolean isBelow) {
        Vector3d direction = isBelow ? new Vector3d(0.0, -rangeY, 0.0) : new Vector3d(0.0, rangeY, 0.0);
        RayTraceContext context = new RayTraceContext(pos, pos.add(direction), RayTraceContext.BlockMode.VISUAL, RayTraceContext.FluidMode.ANY, mc.player);
        return mc.world.rayTraceBlocks(context);
    }

    private boolean shouldCritical() {
        boolean isInLiquid = isInLiquid();
        boolean isFlying = mc.player.abilities.isFlying || mc.player.isElytraFlying();
        boolean isClimbing = mc.player.isOnLadder();
        boolean isCantJump = mc.player.isPassenger();
        boolean isOnWeb = PlayerUtil.isPlayerInWeb();

        return !(isInLiquid || isFlying || isClimbing || isCantJump || isOnWeb);
    }

    public boolean cooldownComplete() {
        return mc.player.getCooledAttackStrength(Wave.sinWave(1.0F, 1.5F, 50F, Easings.CUBIC_IN_OUT)) >= 0.93F;
    }

    public boolean rayTrace() {
        return RayTraceUtil.rayTraceEntity(mc.player.rotationYaw, mc.player.rotationPitch, attackDistance() + 3F, target);
    }

    public double attackDistance() {
        return Math.max(mc.playerController.extendedReach() ? 6.0D : 3.0D, attackRange.get());
    }

    private void reset() {
        TargetComponent.clearTarget();
        TargetComponent.updateTargetList();
        target = null;
        canCrit = false;
        script.cleanup();
    }


    @Getter
    @AllArgsConstructor
    public enum RotationMode {
        NEURO("Neuro"),
        ;

        private final String mode;

        @Override
        public String toString() {
            return this.mode;
        }
    }

    @Getter
    @AllArgsConstructor
    public enum AttackMode {
        ADAPTIVE("Adaptive"),
        ONLY_CRIT("Only Crit"),
        ALWAYS("Always"),
        ;

        private final String mode;

        @Override
        public String toString() {
            return this.mode;
        }
    }

    @Getter
    @AllArgsConstructor
    public enum SprintMode {
        ADAPTIVE("Adaptive"),
        PRE("Pre"),
        TICK("Tick"),
        ;

        private final String mode;

        @Override
        public String toString() {
            return this.mode;
        }
    }

    private static boolean checknull() {
        return mc.player == null || mc.world == null;
    }
}
что тут не так юзаю catboost проблема в том что не поворочивается
моё предположения что я использую csv и catboost не работает так
 
код:
Expand Collapse Copy
package org.sheluvparis.excellent.client.impl.feature.impl.combat;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.experimental.Accessors;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.AxeItem;
import net.minecraft.item.SwordItem;
import net.minecraft.network.IPacket;
import net.minecraft.network.play.client.CEntityActionPacket;
import net.minecraft.network.play.client.CUseEntityPacket;
import net.minecraft.tags.FluidTags;
import net.minecraft.util.Hand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceContext;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.vector.Vector3d;
import org.joml.Vector2f;
import org.sheluvparis.common.animation.Easings;
import org.sheluvparis.common.events.orbit.EventHandler;
import org.sheluvparis.common.script.Script;
import org.sheluvparis.excellent.client.events.other.GameUpdateEvent;
import org.sheluvparis.excellent.client.events.other.PacketEvent;
import org.sheluvparis.excellent.client.events.player.PlayerMoveEvent;
import org.sheluvparis.excellent.client.events.player.UpdateEvent;
import org.sheluvparis.excellent.client.events.world.WorldChangeEvent;
import org.sheluvparis.excellent.client.events.world.WorldLoadEvent;
import org.sheluvparis.excellent.client.impl.component.impl.notification.Notification;
import org.sheluvparis.excellent.client.impl.component.impl.notification.NotificationComponent;
import org.sheluvparis.excellent.client.impl.component.impl.notification.NotificationType;
import org.sheluvparis.excellent.client.impl.component.impl.rotation.Rotation;
import org.sheluvparis.excellent.client.impl.component.impl.rotation.RotationComponent;
import org.sheluvparis.excellent.client.impl.component.impl.target.TargetComponent;
import org.sheluvparis.excellent.client.impl.feature.Category;
import org.sheluvparis.excellent.client.impl.feature.Feature;
import org.sheluvparis.excellent.client.impl.feature.FeatureInfo;
import org.sheluvparis.excellent.client.impl.neuro.AimPredictor;
import org.sheluvparis.excellent.client.impl.neuro.AngleUtil;
import org.sheluvparis.excellent.client.impl.settings.impl.BooleanSetting;
import org.sheluvparis.excellent.client.impl.settings.impl.ListSetting;
import org.sheluvparis.excellent.client.impl.settings.impl.MultiBooleanSetting;
import org.sheluvparis.excellent.client.impl.settings.impl.SliderSetting;
import org.sheluvparis.excellent.client.util.combat.AuraUtil;
import org.sheluvparis.excellent.client.util.combat.RayTraceUtil;
import org.sheluvparis.excellent.client.util.combat.RotationUtil;
import org.sheluvparis.excellent.client.util.math.Lerp;
import org.sheluvparis.excellent.client.util.math.Mathf;
import org.sheluvparis.excellent.client.util.math.Wave;
import org.sheluvparis.excellent.client.util.player.PlayerUtil;
import org.sheluvparis.excellent.client.util.resource.ClientResource;

import java.util.Arrays;
import java.util.List;

@Getter
@Accessors(fluent = true)
@FeatureInfo(name = "Aura", category = Category.COMBAT)
public class FuckAura extends Feature {

    private final AimPredictor predictor = new AimPredictor();
    private final ListSetting<RotationMode> rotationMode = new ListSetting<>("Rotation Mode", RotationMode.values())
            .onAction(() -> {
                if (rotationMode().get().equals(RotationMode.NEURO)) {
                    if (predictor().isLoaded()) {
                        NotificationComponent.register(new Notification(NotificationType.INFO, () -> "Unloading rotation model.", 1500));
                        predictor().close();
                    }
                    loadModel();
                    NotificationComponent.register(new Notification(NotificationType.INFO, () -> "Rotation model is loaded.", 1500));
                }
            });
    private final ListSetting<AttackMode> attackMode = new ListSetting<>("Attack Mode", AttackMode.values());
    private final ListSetting<SprintMode> sprintMode = new ListSetting<>("Sprint Mode", SprintMode.values());
    private final SliderSetting turnSpeed = new SliderSetting("Turn Speed", 90F, 1F, 180F, 1F);
    private final SliderSetting resetSpeed = new SliderSetting("Return Speed", 45F, 1F, 180F, 1F);
    private final SliderSetting attackRange = new SliderSetting("Distance", 3F, 3F, 6F, 0.1F);

    private final MultiBooleanSetting checks = new MultiBooleanSetting("Settings",
            BooleanSetting.of("Ray Trace"),
            BooleanSetting.of("Only Weapon"),
            BooleanSetting.of("Disable On Death"),
            BooleanSetting.of("Disable When Eating")
    );

    public LivingEntity target;
    public boolean canCrit;
    private final Script script = new Script();

    private void loadModel() {
        predictor.loadModel(new ClientResource("model/aim_dataset.csv"));
    }

    @Override
    public void toggle() {
        reset();
        super.toggle();
    }

    @Override
    protected void onEnable(){
        if (rotationMode.is("Neuro") && !predictor.isLoaded()) {
            predictor.loadModel(
                    new ClientResource("models/aim_model.cbm")
            );
            loadModel();
            if(!predictor.isLoaded()){
                NotificationComponent.register(new Notification(NotificationType.INFO, () -> "Модель не загрузилась обратилась к WEXTER5", 1500));
                System.out.println("Модель не загрузилась обратилась к WEXTER5");
            }else {
                System.out.println("Модель загрузилась");
            }
            NotificationComponent.register(new Notification(NotificationType.INFO, () -> "Rotation model is loaded.", 1500));
        }
        super.onEnable();
    }

    @Override
    protected void onDisable() {
        if (rotationMode.is("Neuro") && predictor.isLoaded()) {
            NotificationComponent.register(new Notification(NotificationType.INFO, () -> "Unloading rotation model.", 1500));
            predictor.close();
        }
        super.onDisable();
    }

    @EventHandler
    public void onEvent(WorldChangeEvent event) {
        reset();
    }

    @EventHandler
    public void onEvent(WorldLoadEvent event) {
        reset();
    }

    @EventHandler
    public void onEvent(PlayerMoveEvent event) {
        canCrit = !event.isToGround() && event.getFrom().y > event.getTo().y;
    }

    @EventHandler
    public void onEvent(PacketEvent event) {
        if (target == null || checknull()) {
            return;
        }
        final IPacket<?> packet = event.getPacket();
        if (packet instanceof CUseEntityPacket wrapper && !wrapper.getAction().equals(CUseEntityPacket.Action.ATTACK)) {
            event.cancel();
        }
    }

    @EventHandler
    public void onEvent(GameUpdateEvent event) throws Exception {
        if (target == null || checknull()) {
            canCrit = false;
            return;
        }

        if (checkReturn()) return;

        if (rotationMode.get().equals(RotationMode.NEURO) && predictor.isLoaded()) {
            loadModel();
            updateRotation();
        }
    }


    @EventHandler
    public void onEvent(UpdateEvent event) {
        script.update();
        if (checks.enabled("Disable On Death") && !mc.player.isAlive()) {
            toggle();
            return;
        }

        updateTarget();

        if (target == null || checknull()) {
            canCrit = false;
            return;
        }

        if (checkReturn()) return;

        updateAttack();
    }

    private void updateRotation() throws Exception {
        loadModel();
        if (target == null || !predictor.isLoaded()) {
            return;
        }

        float currentYaw = mc.player.rotationYaw;
        float currentPitch = mc.player.rotationPitch;

        Vector2f targetRot = RotationUtil.calculate(target);
        float targetYaw = targetRot.x;
        float targetPitch = targetRot.y;

        float yawDeltaToTarget = AngleUtil.normalizeYaw(targetYaw - currentYaw);
        float pitchDeltaToTarget = AngleUtil.normalizePitch(targetPitch - currentPitch);

        float distance = (float) mc.player.getPositionVec().distanceTo(target.getPositionVec());
        float ticksSinceLastAttack = mc.player.getCooledAttackStrength(1.0F);
        float onGround = mc.player.isOnGround() ? 1.0F : 0.0F;

        Vector3d targetMotion = target.getMotion();
        Vector3d playerMotion = mc.player.getMotion();

        float deltaX = (float) (target.getPosX() - mc.player.getPosX());
        float deltaY = (float) (target.getPosY() - mc.player.getPosY());
        float deltaZ = (float) (target.getPosZ() - mc.player.getPosZ());

        float[] features = new float[]{
                yawDeltaToTarget,
                pitchDeltaToTarget,

                AngleUtil.normalizeYaw(currentYaw),
                AngleUtil.normalizePitch(currentPitch),

                ticksSinceLastAttack,
                distance,
                onGround,

                deltaX,
                deltaY,
                deltaZ,

                (float) targetMotion.x,
                (float) targetMotion.y,
                (float) targetMotion.z,

                (float) playerMotion.x,
                (float) playerMotion.y,
                (float) playerMotion.z
        };

        float[] prediction = predictor.predict(features);

        float deltaYaw = prediction[0];
        float deltaPitch = prediction[1];

        float aimYaw = AngleUtil.normalizeYaw(currentYaw + deltaYaw);
        float aimPitch = MathHelper.clamp(
                currentPitch + deltaPitch,
                -90.0F,
                90.0F
        );

        float yawDiff = MathHelper.wrapDegrees(aimYaw - currentYaw);
        float pitchDiff = aimPitch - currentPitch;

        float maxYawChange = turnSpeed.get() / 3.0F;
        float maxPitchChange = turnSpeed.get() / 3.0F;

        yawDiff = MathHelper.clamp(yawDiff, -maxYawChange, maxYawChange);
        pitchDiff = MathHelper.clamp(pitchDiff, -maxPitchChange, maxPitchChange);

        RotationComponent.update(
                new Rotation(
                        currentYaw + yawDiff,
                        currentPitch + pitchDiff
                ),
                turnSpeed.get(),
                resetSpeed.get(),
                Mathf.random(10, 14),
                Mathf.random(5, 7),
                1,
                5,
                false
        );
        System.out.println(
                "dYaw=" + deltaYaw +
                        " dPitch=" + deltaPitch +
                        " yawDiff=" + yawDiff
        );
    }


    private void updateAttack() {
        double distance = AuraUtil.getStrictDistance(target);
        if (shouldAttack(target) && distance < attackDistance()) {
            if (!checks.enabled("Ray Trace") || rayTrace()) {
                boolean isInLiquid = isInLiquid();
                boolean sprinting = mc.player.isSprinting() || mc.player.isServerSprintState();
                boolean check = !isInLiquid && sprinting;
                if (check) {
                    if (sprintMode.get().equals(SprintMode.ADAPTIVE)) {
                        if (script.isFinished()) {
                            mc.player.connection.sendPacket(new CEntityActionPacket(mc.player, CEntityActionPacket.Action.STOP_SPRINTING));
                            mc.player.setServerSprintState(false);
                            mc.player.setSprinting(false);
                        }
                    } else {
                        mc.player.connection.sendPacket(new CEntityActionPacket(mc.player, CEntityActionPacket.Action.STOP_SPRINTING));
                        mc.player.setServerSprintState(false);
                        mc.player.setSprinting(false);
                    }
                }
                attackEntity(target);

                if (check && !sprintMode.get().equals(SprintMode.PRE)) {
                    if (sprintMode.get().equals(SprintMode.ADAPTIVE)) {
                        if (script.isFinished()) {
                            script.addTickStep(1, () -> {
                                mc.player.setSprinting(true);
                                mc.player.setServerSprintState(true);
                                mc.player.connection.sendPacket(new CEntityActionPacket(mc.player, CEntityActionPacket.Action.START_SPRINTING));
                            });
                        }
                    } else {
                        mc.player.setSprinting(true);
                        mc.player.setServerSprintState(true);
                        mc.player.connection.sendPacket(new CEntityActionPacket(mc.player, CEntityActionPacket.Action.START_SPRINTING));
                    }
                }
                canCrit = false;
            }
        }
    }


    @SuppressWarnings("RedundantIfStatement")
    private boolean checkReturn() {
        if (checks.enabled("Disable When Eating") && mc.player.isHandActive() && mc.player.getActiveItemStack().getItem().getFood() != null) {
            return true;
        }
        if (checks.enabled("Only Weapon") && (!(mc.player.getHeldItemMainhand().getItem() instanceof AxeItem || mc.player.getHeldItemMainhand().getItem() instanceof SwordItem))) {
            return true;
        }
        return false;
    }

    private void attackEntity(Entity entity) {
        mc.playerController.attackEntity(mc.player, entity);
        mc.player.swingArm(Hand.MAIN_HAND);
    }

    private void updateTarget() {
        target = TargetComponent.getTarget(attackRange.get() + 3F);
    }

    private static boolean isInLiquid() {
        return mc.player.isActualySwimming() || mc.player.isSwimming() && mc.player.areEyesInFluid(FluidTags.WATER) || mc.player.areEyesInFluid(FluidTags.LAVA);
    }

    private boolean shouldAttack(LivingEntity target) {
        if (target.hurtTime != 0) return false;
        if (!cooldownComplete()) return false;
        if (isInLiquid()) return true;

        boolean canDefaultCrit = isCanDefaultCrit();
        boolean canSmartCrit = isCanSmartCrit();
        boolean isYCap = getYCap(2) < 0.1F;

        if (attackMode.get().equals(AttackMode.ONLY_CRIT)) {
            return shouldCritical() && canDefaultCrit || isYCap;
        }
        if (attackMode.get().equals(AttackMode.ADAPTIVE)) {
            return ((shouldCritical() && canDefaultCrit) || canSmartCrit) || isYCap;
        }
        return attackMode.get().equals(AttackMode.ALWAYS);
    }

    private boolean isCanDefaultCrit() {
        return canCrit;
    }

    private boolean isCanSmartCrit() {
        return !mc.player.movementInput.jump && !canCrit && mc.player.isOnGround() && mc.player.onGroundTicks >= 2;
    }

    public static double getYCap(int rangeY) {
        if (checknull()) return 1.0F;

        Vector3d pos = mc.player.getEyePosition(mc.getRenderPartialTicks());
        double minDist = rangeY * 2.0F;
        double maxY = 320;
        double minY = -64;
        double width = mc.player.getWidth() / 2.0F;

        for (Vector3d corner : getCorners(pos, width)) {
            RayTraceResult above = traceRay(corner, rangeY, false);
            RayTraceResult below = traceRay(corner, rangeY, true);

            maxY = Math.min(maxY, above.getHitVec().y);
            minY = Math.max(minY, below.getHitVec().y);

            double dist = maxY - minY;
            if (minDist > dist) minDist = dist;
        }

        return minDist - mc.player.getHeight();
    }

    private static List<Vector3d> getCorners(Vector3d pos, double offset) {
        return Arrays.asList(
                pos.add(-offset, 0.0, -offset),
                pos.add(offset, 0.0, offset),
                pos.add(offset, 0.0, -offset),
                pos.add(-offset, 0.0, offset)
        );
    }

    private static RayTraceResult traceRay(Vector3d pos, int rangeY, boolean isBelow) {
        Vector3d direction = isBelow ? new Vector3d(0.0, -rangeY, 0.0) : new Vector3d(0.0, rangeY, 0.0);
        RayTraceContext context = new RayTraceContext(pos, pos.add(direction), RayTraceContext.BlockMode.VISUAL, RayTraceContext.FluidMode.ANY, mc.player);
        return mc.world.rayTraceBlocks(context);
    }

    private boolean shouldCritical() {
        boolean isInLiquid = isInLiquid();
        boolean isFlying = mc.player.abilities.isFlying || mc.player.isElytraFlying();
        boolean isClimbing = mc.player.isOnLadder();
        boolean isCantJump = mc.player.isPassenger();
        boolean isOnWeb = PlayerUtil.isPlayerInWeb();

        return !(isInLiquid || isFlying || isClimbing || isCantJump || isOnWeb);
    }

    public boolean cooldownComplete() {
        return mc.player.getCooledAttackStrength(Wave.sinWave(1.0F, 1.5F, 50F, Easings.CUBIC_IN_OUT)) >= 0.93F;
    }

    public boolean rayTrace() {
        return RayTraceUtil.rayTraceEntity(mc.player.rotationYaw, mc.player.rotationPitch, attackDistance() + 3F, target);
    }

    public double attackDistance() {
        return Math.max(mc.playerController.extendedReach() ? 6.0D : 3.0D, attackRange.get());
    }

    private void reset() {
        TargetComponent.clearTarget();
        TargetComponent.updateTargetList();
        target = null;
        canCrit = false;
        script.cleanup();
    }


    @Getter
    @AllArgsConstructor
    public enum RotationMode {
        NEURO("Neuro"),
        ;

        private final String mode;

        @Override
        public String toString() {
            return this.mode;
        }
    }

    @Getter
    @AllArgsConstructor
    public enum AttackMode {
        ADAPTIVE("Adaptive"),
        ONLY_CRIT("Only Crit"),
        ALWAYS("Always"),
        ;

        private final String mode;

        @Override
        public String toString() {
            return this.mode;
        }
    }

    @Getter
    @AllArgsConstructor
    public enum SprintMode {
        ADAPTIVE("Adaptive"),
        PRE("Pre"),
        TICK("Tick"),
        ;

        private final String mode;

        @Override
        public String toString() {
            return this.mode;
        }
    }

    private static boolean checknull() {
        return mc.player == null || mc.world == null;
    }
}
что тут не так юзаю catboost проблема в том что не поворочивается
моё предположения что я использую csv и catboost не работает так
Ты пишешь что используешь csv но при включении он загружает cbm модель

predictor.loadModel(<br> new ClientResource("models/aim_model.cbm")<br> );

возможно именно из-за этого
 
Назад
Сверху Снизу