Вопрос Коррекция в AuraFunction | 3.1 [РЕШЕНО]

Начинающий
Статус
Оффлайн
Регистрация
30 Май 2024
Сообщения
106
Реакции[?]
1
Поинты[?]
1K

Перед прочтением основного контента ниже, пожалуйста, обратите внимание на обновление внутри секции Майна на нашем форуме. У нас появились:

  • бесплатные читы для Майнкрафт — любое использование на свой страх и риск;
  • маркетплейс Майнкрафт — абсолютно любая коммерция, связанная с игрой, за исключением продажи читов (аккаунты, предоставления услуг, поиск кодеров читов и так далее);
  • приватные читы для Minecraft — в этом разделе только платные хаки для игры, покупайте группу "Продавец" и выставляйте на продажу свой софт;
  • обсуждения и гайды — всё тот же раздел с вопросами, но теперь модернизированный: поиск нужных хаков, пати с игроками-читерами и другая полезная информация.

Спасибо!

Перенёс килку с 2.0 на 3.1, но столкнулся с проблемой то, что коррекции как будто нет, хотя я перенёс утилку на неё и подключил.
Вот код:

Java:
@FunctionRegister(name = "AuraFunction", type = Category.Combat)
public class AuraFunction extends Function {
    public static LivingEntity target = null;
    public Vector2f rotate = new Vector2f(0.0F, 0.0F);
    private final ModeSetting rotationMode = new ModeSetting("Мод ротации", "Плавный", new String[]{"Плавный", "Резкий"});
    private final SliderSetting ticksnap = (new SliderSetting("Скорость ротации", 3.0F, 2.0F, 4.0F, 1.0F)).setVisible(() -> {
        return this.rotationMode.getIndex() == 1;
    });
    private final ModeSetting sortMode = new ModeSetting("Сортировать", "По всему", new String[]{"По всему", "По здоровью", "По дистанции"});
    private final ModeListSetting targets = new ModeListSetting("Цели", new BooleanSetting[]{new BooleanSetting("Игроки", true), new BooleanSetting("Друзья", false), new BooleanSetting("Голые", true), new BooleanSetting("Мобы", false)});
    private final BooleanSetting elytraTarget = (new BooleanSetting("Элитра таргет", false)).setVisible(() -> {
        return this.rotationMode.getIndex() == 1;
    });
    private final BooleanSetting targetOnlyElytra = (new BooleanSetting("Таргетить только элитры", false)).setVisible(() -> {
        return this.elytraTarget.get() && this.rotationMode.getIndex() == 1;
    });
    private final SliderSetting distance = new SliderSetting("Дистанция аттаки", 2.99F, 2.0F, 5.8F, 1.0E-4F);
    private final SliderSetting rotateDistance = (new SliderSetting("Дистанция ротации", 1.5F, 0.0F, 30.0F, 0.05F)).setVisible(() -> {
        return this.rotationMode.getIndex() == 0;
    });
    private final SliderSetting elytradistance = (new SliderSetting("Элитра дистанция", 1.5F, 0.0F, 5.0F, 0.05F)).setVisible(() -> {
        return this.rotationMode.getIndex() == 0 || this.rotationMode.getIndex() == 1 && this.elytraTarget.get();
    });
    private final SliderSetting elytrarotate = (new SliderSetting("Элитра ротация", 1.0F, 0.0F, 30.0F, 0.05F)).setVisible(() -> {
        return this.rotationMode.getIndex() == 0 || this.rotationMode.getIndex() == 1 && this.elytraTarget.get();
    });
    private final BooleanSetting FTBypass = (new BooleanSetting("Обход FunTime", false)).setVisible(() -> {
        return this.rotationMode.getIndex() == 0;
    });
    public final ModeListSetting settings = new ModeListSetting("Настройки", new BooleanSetting[]{new BooleanSetting("Только критами", true), new BooleanSetting("Коррекция движения", true), new BooleanSetting("Отжимать щит", true), new BooleanSetting("Ломать щит", true)});
    private final BooleanSetting onlySpaceCritical = (new BooleanSetting("Умные криты", false));
    private final ModeSetting correctionType = (new ModeSetting("Тип коррекции", "Незаметный", new String[]{"Незаметный", "Сфокусированный"}));
    int ticksUntilNextAttack;
    private boolean hasRotated;
    private long cpsLimit = 0L;
    private final TimerUtil timerUtil = new TimerUtil();
    boolean test = false;
    public Vector2f clientRot = null;
    float lastYaw;

    float lastPitch;
    private double prevCircleStep;
    private double circleStep;
    public static boolean elytraboosting = false;
    public FreeCamera player = null;
    public AuraFunction(AutoPotion autoPotion) {
        addSettings(this.rotationMode, this.targets, this.sortMode, this.distance, this.rotateDistance, this.ticksnap, this.elytrarotate, this.elytradistance, this.settings, this.correctionType, this.onlySpaceCritical, this.elytraTarget, this.targetOnlyElytra,FTBypass);
        this.autoPotion = autoPotion;
    }
    FunctionRegistry functionRegistry = Broken.getInstance().getFunctionRegistry();
    final AutoPotion autoPotion;
    @Subscribe
    public void onInput(EventInput eventInput) {
        if (settings.getValueByName("Коррекция движения").get() && this.correctionType.getIndex() == 0 && !mc.player.isInWater()) {
            MoveUtils.fixMovement(eventInput, Minecraft.getInstance().player.rotationYaw );
        }
    }

    @Subscribe
    public void onUpdate(EventUpdate e) {
            if (target == null || !this.isValidTarget(target)) {
                target = this.findTarget();
            }

            if (target == null) {
                this.cpsLimit = System.currentTimeMillis();
                this.rotate = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
                return;
            }

            this.attackAndRotateOnEntity(target);

    }
    @Subscribe
    public void onMotion(EventMotion motionEvent) {
        this.handleMotionEvent(motionEvent);
    }
    private void attackAndRotateOnEntity(LivingEntity target) {
        boolean elytraFly = false;
        if (this.elytraTarget.get() && mc.player.isElytraFlying()) {
            elytraFly = true;
        }
        this.hasRotated = false;
        if (this.rotationMode.getIndex() == 0 || elytraFly) {
            this.hasRotated = false;
            if (this.shouldAttack(target)  && (this.FTBypass.get() && RayTraceUtil.getMouseOver(target, this.rotate.x, this.rotate.y, (double)this.distance.get().floatValue()) == target || !this.FTBypass.get())) {
                this.attackTarget(target);
            }

            if (!this.hasRotated) {
                this.setRotation(target, false);
            }
        }

        if (this.rotationMode.getIndex() == 1 && !elytraFly) {
            if (this.shouldAttack(target)) {
                this.ticksUntilNextAttack = this.ticksnap.get().intValue();
                this.attackTarget(target);
            }

            if (this.ticksUntilNextAttack > 0) {
                this.setRotation(target, false);
                --this.ticksUntilNextAttack;
            } else {
                this.rotate.x = mc.player.rotationYaw;
                this.rotate.y = mc.player.rotationPitch;
            }
        }

    }
    private void attackTarget(LivingEntity targetEntity) {
        if (this.settings.get(2).get() && mc.player.isBlocking()) {
            mc.playerController.onStoppedUsingItem(mc.player);
        }

        boolean sprint = false;
        if (CEntityActionPacket.lastUpdatedSprint && !mc.player.isInWater()) {
            mc.player.connection.sendPacket(new CEntityActionPacket(mc.player, CEntityActionPacket.Action.STOP_SPRINTING));
            sprint = true;
        }

        this.cpsLimit = System.currentTimeMillis() + 550L;
        mc.playerController.attackEntity(mc.player, targetEntity);
        mc.player.swingArm(Hand.MAIN_HAND);
        if (this.settings.get(3).get()) {
            this.breakShieldAndSwapSlot();
        }

        if (sprint) {
            mc.player.connection.sendPacket(new CEntityActionPacket(mc.player, CEntityActionPacket.Action.START_SPRINTING));
        }

    }
    private void setRotation(LivingEntity base, boolean attack) {
        this.hasRotated = true;
        Vector3d vec3d;
        float deltaPitch;
        float limitedYaw;
        float limitedPitch;
        float finalYaw;
        float finalPitch;
        float gcd;

            vec3d = AuraUtil.getVector(base);
            double diffX = vec3d.x;
            double diffY = vec3d.y;
            double diffZ = vec3d.z;
            float[] rotations = new float[]{(float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90.0F, (float)(-Math.toDegrees(Math.atan2(diffY, Math.hypot(diffX, diffZ))))};
            float deltaYaw = MathHelper.wrapDegrees(MathUtil.calculateDelta(rotations[0], this.rotate.x));
            deltaPitch = MathUtil.calculateDelta(rotations[1], this.rotate.y);
            limitedYaw = Math.min(Math.max(Math.abs(deltaYaw), 1.0F), 360.0F);
            limitedPitch = Math.min(Math.max(Math.abs(deltaPitch), 1.0F), 90.0F);
            finalYaw = this.rotate.x + (deltaYaw > 0.0F ? limitedYaw : -limitedYaw) + ThreadLocalRandom.current().nextFloat(-1.0F, 1.0F);
            finalPitch = MathHelper.clamp(this.rotate.y + (deltaPitch > 0.0F ? limitedPitch : -limitedPitch) + ThreadLocalRandom.current().nextFloat(-1.0F, 1.0F), -90.0F, 90.0F);
            gcd = GCDUtil.getGCDValue();
            finalYaw = (float)((double)finalYaw - (double)(finalYaw - this.rotate.x) % (double)gcd);
            finalPitch = (float)((double)finalPitch - (double)(finalPitch - this.rotate.y) % (double)gcd);
            this.rotate.x = finalYaw;
            this.rotate.y = finalPitch;
    }
    private boolean shouldAttack(LivingEntity targetEntity) {
        return this.canAttack() && targetEntity != null && this.cpsLimit <= System.currentTimeMillis();
    }
    public boolean canAttack() {
        boolean onSpace = this.onlySpaceCritical.get() && mc.player.isOnGround() && !mc.gameSettings.keyBindJump.isKeyDown();
        boolean reasonForAttack = mc.player.isPotionActive(Effects.BLINDNESS) || mc.player.isOnLadder() || mc.player.isInWater() && mc.player.areEyesInFluid(FluidTags.WATER) || mc.player.isRidingHorse() || mc.player.abilities.isFlying || mc.player.isElytraFlying() || mc.player.isInLava() && mc.player.areEyesInFluid(FluidTags.LAVA);
        float elytradistance1 = 0.0F;
        if (mc.player.isElytraFlying()) {
            elytradistance1 = this.elytradistance.get().floatValue();
        }

        if (!mc.player.isElytraFlying()) {
            elytradistance1 = 0.0F;
        }

        if (!(this.getDistance(target) >= (double)(this.distance.get().floatValue() - elytradistance1)) && !(mc.player.getCooledAttackStrength(1.5F) < 0.92F)) {
             if (!reasonForAttack && this.settings.get(0).get()) {
                return onSpace || !mc.player.isOnGround() && mc.player.fallDistance > 0.0F;
            } else {
                return true;
            }
        } else {
            return false;
        }
    }

    private boolean isValidTarget(LivingEntity base) {
        if (!base.getShouldBeDead() && base.isAlive() && base != mc.player) {
            if (base instanceof PlayerEntity) {
                String playerName = base.getName().getString();
                if (FriendStorage.isFriend(playerName) && !this.targets.get(1).get() || player != null && playerName.equals(player.getName().getString()) || base.getTotalArmorValue() == 0 && (!this.targets.get(0).get() || !this.targets.get(2).get())) {
                    return false;
                }
            }

            if (AntiBot.isBot(base)) {
                return false;
            } else {
                if (base instanceof PlayerEntity) {
                    boolean nearElytraPlayer = false;
                    Iterator var3 = mc.world.getPlayers().iterator();

                    while(var3.hasNext()) {
                        PlayerEntity entity = (PlayerEntity)var3.next();
                        if (entity != mc.player && !FriendStorage.isFriend(entity.getName().getString()) && ((ItemStack)entity.inventory.armorInventory.get(2)).getItem() == Items.ELYTRA && mc.player.getDistance(entity) < this.elytrarotate.get().floatValue() + this.distance.get().floatValue() - this.elytradistance.get().floatValue()) {
                            nearElytraPlayer = true;
                        }
                    }

                    if (((ItemStack)((PlayerEntity)base).inventory.armorInventory.get(2)).getItem() != Items.ELYTRA && mc.player.isElytraFlying() && this.elytraTarget.get() && this.rotationMode.getIndex() == 1) {
                        if (nearElytraPlayer && !this.targetOnlyElytra.get()) {
                            return false;
                        }

                        if (this.targetOnlyElytra.get()) {
                            return false;
                        }
                    }
                }

                if ((base instanceof MobEntity || base instanceof AnimalEntity) && !this.targets.get(3).get()) {
                    return false;
                } else if (base instanceof PlayerEntity && !this.targets.get(0).get()) {
                    return false;
                } else if (!(base instanceof ArmorStandEntity) && (!(base instanceof PlayerEntity) || !((PlayerEntity)base).isBot)) {
                    float elytrarotate1 = 0.0F;
                    if (mc.player.isElytraFlying()) {
                        elytrarotate1 = this.elytrarotate.get().floatValue();
                    }

                    if (!mc.player.isElytraFlying()) {
                        elytrarotate1 = 0.0F;
                    }

                    return this.getDistance(base) <= (double)(this.distance.get().floatValue() + (this.rotationMode.getIndex() == 0 ? this.rotateDistance.get().floatValue() + elytrarotate1 : 0.0F) + (this.rotationMode.getIndex() == 1 && mc.player.isElytraFlying() && this.elytraTarget.get() ? this.rotateDistance.get().floatValue() + elytrarotate1 : 0.0F));
                } else {
                    return false;
                }
            }
        } else {
            return false;
        }
    }
    private void handleMotionEvent(EventMotion motionEvent) {
        if (target != null ) {
            motionEvent.setYaw(this.rotate.x);
            motionEvent.setPitch(this.rotate.y);
            mc.player.rotationYawHead = this.rotate.x;
            mc.player.renderYawOffset = this.rotate.x;
            mc.player.rotationPitchHead = this.rotate.y;
        }

    }
    private void breakShieldAndSwapSlot() {
        LivingEntity targetEntity = target;
        if (targetEntity instanceof PlayerEntity player) {
            if (target.isActiveItemStackBlocking(2) && !player.isSpectator() && !player.isCreative() && (target.getHeldItemOffhand().getItem() == Items.SHIELD || target.getHeldItemMainhand().getItem() == Items.SHIELD)) {
                int slot = this.breakShield(player);
                if (slot > 8) {
                    mc.playerController.pickItem(slot);
                }
            }
        }

    }
    private LivingEntity findTarget() {
        List<LivingEntity> targets = new ArrayList();
        Iterator var2 = mc.world.getAllEntities().iterator();

        while(var2.hasNext()) {
            Entity entity = (Entity)var2.next();
            if (entity instanceof LivingEntity && this.isValidTarget((LivingEntity)entity)) {
                targets.add((LivingEntity)entity);
            }
        }

        if (targets.isEmpty()) {
            return null;
        } else {
            if (targets.size() > 1) {
                switch (this.sortMode.get()) {
                    case "По всему":
                        targets.sort(Comparator.comparingDouble((target) -> {
                            if (target instanceof PlayerEntity player) {
                                return -this.getEntityArmor(player);
                            } else if (target instanceof LivingEntity livingEntity) {
                                return (double)(-livingEntity.getTotalArmorValue());
                            } else {
                                return 0.0;
                            }
                        }).thenComparing((o, o1) -> {
                            double health = this.getEntityHealth((LivingEntity)o);
                            double health1 = this.getEntityHealth((LivingEntity)o1);
                            return Double.compare(health, health1);
                        }).thenComparing((object, object2) -> {
                            double d2 = this.getDistance((LivingEntity)object);
                            double d3 = this.getDistance((LivingEntity)object2);
                            return Double.compare(d2, d3);
                        }));
                        break;
                    case "По дистанции":
                        AuraFunction auraFunction = functionRegistry.getAuraFunction();
                        Objects.requireNonNull(auraFunction);
                        targets.sort(Comparator.comparingDouble(auraFunction::getDistance).thenComparingDouble(this::getEntityHealth));
                        break;
                    case "По здоровью":
                        Comparator var10001 = Comparator.comparingDouble(this::getEntityHealth);
                        ClientPlayerEntity var10002 = mc.player;
                        Objects.requireNonNull(var10002);
                        //targets.sort(var10001.thenComparingDouble(var10002::getDistance));
                }
            } else {
                this.cpsLimit = System.currentTimeMillis();
            }

            return (LivingEntity)targets.get(0);
        }
    }
    public int breakShield(LivingEntity target) {
        int hotBarSlot = InventoryUtil.getAxe(true);
        if (hotBarSlot != -1) {
            mc.player.connection.sendPacket(new CHeldItemChangePacket(hotBarSlot));
            mc.playerController.attackEntity(mc.player, target);
            mc.player.swingArm(Hand.MAIN_HAND);
            mc.player.connection.sendPacket(new CHeldItemChangePacket(mc.player.inventory.currentItem));
            return hotBarSlot;
        } else {
            int inventorySLot = InventoryUtil.getAxe(false);
            if (inventorySLot != -1) {
                mc.playerController.pickItem(inventorySLot);
                mc.playerController.attackEntity(mc.player, target);
                mc.player.swingArm(Hand.MAIN_HAND);
                return inventorySLot;
            } else {
                return -1;
            }
        }
    }
    private double getDistance(LivingEntity entity) {
        return AuraUtil.getVector(entity).length();
    }

    public double getEntityArmor(PlayerEntity target) {
        double totalArmor = 0.0;
        Iterator var4 = target.inventory.armorInventory.iterator();

        while(var4.hasNext()) {
            ItemStack armorStack = (ItemStack)var4.next();
            if (armorStack != null && armorStack.getItem() instanceof ArmorItem) {
                totalArmor += this.getProtectionLvl(armorStack);
            }
        }

        return totalArmor;
    }

    public double getEntityHealth(Entity ent) {
        if (ent instanceof PlayerEntity player) {
            double armorValue = this.getEntityArmor(player) / 20.0;
            return (double)(player.getHealth() + player.getAbsorptionAmount()) * armorValue;
        } else if (ent instanceof LivingEntity livingEntity) {
            return (double)(livingEntity.getHealth() + livingEntity.getAbsorptionAmount());
        } else {
            return 0.0;
        }
    }

    private double getProtectionLvl(ItemStack stack) {
        ArmorItem armor = (ArmorItem)stack.getItem();
        double damageReduce = (double)armor.getDamageReduceAmount();
        if (stack.isEnchanted()) {
            damageReduce += (double)EnchantmentHelper.getEnchantmentLevel(Enchantments.PROTECTION, stack) * 0.25;
        }

        return damageReduce;
    }
    @Override
    public void onDisable() {
        this.rotate = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
        target = null;
        this.cpsLimit = System.currentTimeMillis();
        super.onDisable();
    }
    public static LivingEntity getTarget() {
        return target;
    }
}
 
Начинающий
Статус
Оффлайн
Регистрация
23 Июн 2023
Сообщения
89
Реакции[?]
0
Поинты[?]
0
Перенёс килку с 2.0 на 3.1, но столкнулся с проблемой то, что коррекции как будто нет, хотя я перенёс утилку на неё и подключил.
Вот код:

Java:
@FunctionRegister(name = "AuraFunction", type = Category.Combat)
public class AuraFunction extends Function {
    public static LivingEntity target = null;
    public Vector2f rotate = new Vector2f(0.0F, 0.0F);
    private final ModeSetting rotationMode = new ModeSetting("Мод ротации", "Плавный", new String[]{"Плавный", "Резкий"});
    private final SliderSetting ticksnap = (new SliderSetting("Скорость ротации", 3.0F, 2.0F, 4.0F, 1.0F)).setVisible(() -> {
        return this.rotationMode.getIndex() == 1;
    });
    private final ModeSetting sortMode = new ModeSetting("Сортировать", "По всему", new String[]{"По всему", "По здоровью", "По дистанции"});
    private final ModeListSetting targets = new ModeListSetting("Цели", new BooleanSetting[]{new BooleanSetting("Игроки", true), new BooleanSetting("Друзья", false), new BooleanSetting("Голые", true), new BooleanSetting("Мобы", false)});
    private final BooleanSetting elytraTarget = (new BooleanSetting("Элитра таргет", false)).setVisible(() -> {
        return this.rotationMode.getIndex() == 1;
    });
    private final BooleanSetting targetOnlyElytra = (new BooleanSetting("Таргетить только элитры", false)).setVisible(() -> {
        return this.elytraTarget.get() && this.rotationMode.getIndex() == 1;
    });
    private final SliderSetting distance = new SliderSetting("Дистанция аттаки", 2.99F, 2.0F, 5.8F, 1.0E-4F);
    private final SliderSetting rotateDistance = (new SliderSetting("Дистанция ротации", 1.5F, 0.0F, 30.0F, 0.05F)).setVisible(() -> {
        return this.rotationMode.getIndex() == 0;
    });
    private final SliderSetting elytradistance = (new SliderSetting("Элитра дистанция", 1.5F, 0.0F, 5.0F, 0.05F)).setVisible(() -> {
        return this.rotationMode.getIndex() == 0 || this.rotationMode.getIndex() == 1 && this.elytraTarget.get();
    });
    private final SliderSetting elytrarotate = (new SliderSetting("Элитра ротация", 1.0F, 0.0F, 30.0F, 0.05F)).setVisible(() -> {
        return this.rotationMode.getIndex() == 0 || this.rotationMode.getIndex() == 1 && this.elytraTarget.get();
    });
    private final BooleanSetting FTBypass = (new BooleanSetting("Обход FunTime", false)).setVisible(() -> {
        return this.rotationMode.getIndex() == 0;
    });
    public final ModeListSetting settings = new ModeListSetting("Настройки", new BooleanSetting[]{new BooleanSetting("Только критами", true), new BooleanSetting("Коррекция движения", true), new BooleanSetting("Отжимать щит", true), new BooleanSetting("Ломать щит", true)});
    private final BooleanSetting onlySpaceCritical = (new BooleanSetting("Умные криты", false));
    private final ModeSetting correctionType = (new ModeSetting("Тип коррекции", "Незаметный", new String[]{"Незаметный", "Сфокусированный"}));
    int ticksUntilNextAttack;
    private boolean hasRotated;
    private long cpsLimit = 0L;
    private final TimerUtil timerUtil = new TimerUtil();
    boolean test = false;
    public Vector2f clientRot = null;
    float lastYaw;

    float lastPitch;
    private double prevCircleStep;
    private double circleStep;
    public static boolean elytraboosting = false;
    public FreeCamera player = null;
    public AuraFunction(AutoPotion autoPotion) {
        addSettings(this.rotationMode, this.targets, this.sortMode, this.distance, this.rotateDistance, this.ticksnap, this.elytrarotate, this.elytradistance, this.settings, this.correctionType, this.onlySpaceCritical, this.elytraTarget, this.targetOnlyElytra,FTBypass);
        this.autoPotion = autoPotion;
    }
    FunctionRegistry functionRegistry = Broken.getInstance().getFunctionRegistry();
    final AutoPotion autoPotion;
    @Subscribe
    public void onInput(EventInput eventInput) {
        if (settings.getValueByName("Коррекция движения").get() && this.correctionType.getIndex() == 0 && !mc.player.isInWater()) {
            MoveUtils.fixMovement(eventInput, Minecraft.getInstance().player.rotationYaw );
        }
    }

    @Subscribe
    public void onUpdate(EventUpdate e) {
            if (target == null || !this.isValidTarget(target)) {
                target = this.findTarget();
            }

            if (target == null) {
                this.cpsLimit = System.currentTimeMillis();
                this.rotate = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
                return;
            }

            this.attackAndRotateOnEntity(target);

    }
    @Subscribe
    public void onMotion(EventMotion motionEvent) {
        this.handleMotionEvent(motionEvent);
    }
    private void attackAndRotateOnEntity(LivingEntity target) {
        boolean elytraFly = false;
        if (this.elytraTarget.get() && mc.player.isElytraFlying()) {
            elytraFly = true;
        }
        this.hasRotated = false;
        if (this.rotationMode.getIndex() == 0 || elytraFly) {
            this.hasRotated = false;
            if (this.shouldAttack(target)  && (this.FTBypass.get() && RayTraceUtil.getMouseOver(target, this.rotate.x, this.rotate.y, (double)this.distance.get().floatValue()) == target || !this.FTBypass.get())) {
                this.attackTarget(target);
            }

            if (!this.hasRotated) {
                this.setRotation(target, false);
            }
        }

        if (this.rotationMode.getIndex() == 1 && !elytraFly) {
            if (this.shouldAttack(target)) {
                this.ticksUntilNextAttack = this.ticksnap.get().intValue();
                this.attackTarget(target);
            }

            if (this.ticksUntilNextAttack > 0) {
                this.setRotation(target, false);
                --this.ticksUntilNextAttack;
            } else {
                this.rotate.x = mc.player.rotationYaw;
                this.rotate.y = mc.player.rotationPitch;
            }
        }

    }
    private void attackTarget(LivingEntity targetEntity) {
        if (this.settings.get(2).get() && mc.player.isBlocking()) {
            mc.playerController.onStoppedUsingItem(mc.player);
        }

        boolean sprint = false;
        if (CEntityActionPacket.lastUpdatedSprint && !mc.player.isInWater()) {
            mc.player.connection.sendPacket(new CEntityActionPacket(mc.player, CEntityActionPacket.Action.STOP_SPRINTING));
            sprint = true;
        }

        this.cpsLimit = System.currentTimeMillis() + 550L;
        mc.playerController.attackEntity(mc.player, targetEntity);
        mc.player.swingArm(Hand.MAIN_HAND);
        if (this.settings.get(3).get()) {
            this.breakShieldAndSwapSlot();
        }

        if (sprint) {
            mc.player.connection.sendPacket(new CEntityActionPacket(mc.player, CEntityActionPacket.Action.START_SPRINTING));
        }

    }
    private void setRotation(LivingEntity base, boolean attack) {
        this.hasRotated = true;
        Vector3d vec3d;
        float deltaPitch;
        float limitedYaw;
        float limitedPitch;
        float finalYaw;
        float finalPitch;
        float gcd;

            vec3d = AuraUtil.getVector(base);
            double diffX = vec3d.x;
            double diffY = vec3d.y;
            double diffZ = vec3d.z;
            float[] rotations = new float[]{(float)Math.toDegrees(Math.atan2(diffZ, diffX)) - 90.0F, (float)(-Math.toDegrees(Math.atan2(diffY, Math.hypot(diffX, diffZ))))};
            float deltaYaw = MathHelper.wrapDegrees(MathUtil.calculateDelta(rotations[0], this.rotate.x));
            deltaPitch = MathUtil.calculateDelta(rotations[1], this.rotate.y);
            limitedYaw = Math.min(Math.max(Math.abs(deltaYaw), 1.0F), 360.0F);
            limitedPitch = Math.min(Math.max(Math.abs(deltaPitch), 1.0F), 90.0F);
            finalYaw = this.rotate.x + (deltaYaw > 0.0F ? limitedYaw : -limitedYaw) + ThreadLocalRandom.current().nextFloat(-1.0F, 1.0F);
            finalPitch = MathHelper.clamp(this.rotate.y + (deltaPitch > 0.0F ? limitedPitch : -limitedPitch) + ThreadLocalRandom.current().nextFloat(-1.0F, 1.0F), -90.0F, 90.0F);
            gcd = GCDUtil.getGCDValue();
            finalYaw = (float)((double)finalYaw - (double)(finalYaw - this.rotate.x) % (double)gcd);
            finalPitch = (float)((double)finalPitch - (double)(finalPitch - this.rotate.y) % (double)gcd);
            this.rotate.x = finalYaw;
            this.rotate.y = finalPitch;
    }
    private boolean shouldAttack(LivingEntity targetEntity) {
        return this.canAttack() && targetEntity != null && this.cpsLimit <= System.currentTimeMillis();
    }
    public boolean canAttack() {
        boolean onSpace = this.onlySpaceCritical.get() && mc.player.isOnGround() && !mc.gameSettings.keyBindJump.isKeyDown();
        boolean reasonForAttack = mc.player.isPotionActive(Effects.BLINDNESS) || mc.player.isOnLadder() || mc.player.isInWater() && mc.player.areEyesInFluid(FluidTags.WATER) || mc.player.isRidingHorse() || mc.player.abilities.isFlying || mc.player.isElytraFlying() || mc.player.isInLava() && mc.player.areEyesInFluid(FluidTags.LAVA);
        float elytradistance1 = 0.0F;
        if (mc.player.isElytraFlying()) {
            elytradistance1 = this.elytradistance.get().floatValue();
        }

        if (!mc.player.isElytraFlying()) {
            elytradistance1 = 0.0F;
        }

        if (!(this.getDistance(target) >= (double)(this.distance.get().floatValue() - elytradistance1)) && !(mc.player.getCooledAttackStrength(1.5F) < 0.92F)) {
             if (!reasonForAttack && this.settings.get(0).get()) {
                return onSpace || !mc.player.isOnGround() && mc.player.fallDistance > 0.0F;
            } else {
                return true;
            }
        } else {
            return false;
        }
    }

    private boolean isValidTarget(LivingEntity base) {
        if (!base.getShouldBeDead() && base.isAlive() && base != mc.player) {
            if (base instanceof PlayerEntity) {
                String playerName = base.getName().getString();
                if (FriendStorage.isFriend(playerName) && !this.targets.get(1).get() || player != null && playerName.equals(player.getName().getString()) || base.getTotalArmorValue() == 0 && (!this.targets.get(0).get() || !this.targets.get(2).get())) {
                    return false;
                }
            }

            if (AntiBot.isBot(base)) {
                return false;
            } else {
                if (base instanceof PlayerEntity) {
                    boolean nearElytraPlayer = false;
                    Iterator var3 = mc.world.getPlayers().iterator();

                    while(var3.hasNext()) {
                        PlayerEntity entity = (PlayerEntity)var3.next();
                        if (entity != mc.player && !FriendStorage.isFriend(entity.getName().getString()) && ((ItemStack)entity.inventory.armorInventory.get(2)).getItem() == Items.ELYTRA && mc.player.getDistance(entity) < this.elytrarotate.get().floatValue() + this.distance.get().floatValue() - this.elytradistance.get().floatValue()) {
                            nearElytraPlayer = true;
                        }
                    }

                    if (((ItemStack)((PlayerEntity)base).inventory.armorInventory.get(2)).getItem() != Items.ELYTRA && mc.player.isElytraFlying() && this.elytraTarget.get() && this.rotationMode.getIndex() == 1) {
                        if (nearElytraPlayer && !this.targetOnlyElytra.get()) {
                            return false;
                        }

                        if (this.targetOnlyElytra.get()) {
                            return false;
                        }
                    }
                }

                if ((base instanceof MobEntity || base instanceof AnimalEntity) && !this.targets.get(3).get()) {
                    return false;
                } else if (base instanceof PlayerEntity && !this.targets.get(0).get()) {
                    return false;
                } else if (!(base instanceof ArmorStandEntity) && (!(base instanceof PlayerEntity) || !((PlayerEntity)base).isBot)) {
                    float elytrarotate1 = 0.0F;
                    if (mc.player.isElytraFlying()) {
                        elytrarotate1 = this.elytrarotate.get().floatValue();
                    }

                    if (!mc.player.isElytraFlying()) {
                        elytrarotate1 = 0.0F;
                    }

                    return this.getDistance(base) <= (double)(this.distance.get().floatValue() + (this.rotationMode.getIndex() == 0 ? this.rotateDistance.get().floatValue() + elytrarotate1 : 0.0F) + (this.rotationMode.getIndex() == 1 && mc.player.isElytraFlying() && this.elytraTarget.get() ? this.rotateDistance.get().floatValue() + elytrarotate1 : 0.0F));
                } else {
                    return false;
                }
            }
        } else {
            return false;
        }
    }
    private void handleMotionEvent(EventMotion motionEvent) {
        if (target != null ) {
            motionEvent.setYaw(this.rotate.x);
            motionEvent.setPitch(this.rotate.y);
            mc.player.rotationYawHead = this.rotate.x;
            mc.player.renderYawOffset = this.rotate.x;
            mc.player.rotationPitchHead = this.rotate.y;
        }

    }
    private void breakShieldAndSwapSlot() {
        LivingEntity targetEntity = target;
        if (targetEntity instanceof PlayerEntity player) {
            if (target.isActiveItemStackBlocking(2) && !player.isSpectator() && !player.isCreative() && (target.getHeldItemOffhand().getItem() == Items.SHIELD || target.getHeldItemMainhand().getItem() == Items.SHIELD)) {
                int slot = this.breakShield(player);
                if (slot > 8) {
                    mc.playerController.pickItem(slot);
                }
            }
        }

    }
    private LivingEntity findTarget() {
        List<LivingEntity> targets = new ArrayList();
        Iterator var2 = mc.world.getAllEntities().iterator();

        while(var2.hasNext()) {
            Entity entity = (Entity)var2.next();
            if (entity instanceof LivingEntity && this.isValidTarget((LivingEntity)entity)) {
                targets.add((LivingEntity)entity);
            }
        }

        if (targets.isEmpty()) {
            return null;
        } else {
            if (targets.size() > 1) {
                switch (this.sortMode.get()) {
                    case "По всему":
                        targets.sort(Comparator.comparingDouble((target) -> {
                            if (target instanceof PlayerEntity player) {
                                return -this.getEntityArmor(player);
                            } else if (target instanceof LivingEntity livingEntity) {
                                return (double)(-livingEntity.getTotalArmorValue());
                            } else {
                                return 0.0;
                            }
                        }).thenComparing((o, o1) -> {
                            double health = this.getEntityHealth((LivingEntity)o);
                            double health1 = this.getEntityHealth((LivingEntity)o1);
                            return Double.compare(health, health1);
                        }).thenComparing((object, object2) -> {
                            double d2 = this.getDistance((LivingEntity)object);
                            double d3 = this.getDistance((LivingEntity)object2);
                            return Double.compare(d2, d3);
                        }));
                        break;
                    case "По дистанции":
                        AuraFunction auraFunction = functionRegistry.getAuraFunction();
                        Objects.requireNonNull(auraFunction);
                        targets.sort(Comparator.comparingDouble(auraFunction::getDistance).thenComparingDouble(this::getEntityHealth));
                        break;
                    case "По здоровью":
                        Comparator var10001 = Comparator.comparingDouble(this::getEntityHealth);
                        ClientPlayerEntity var10002 = mc.player;
                        Objects.requireNonNull(var10002);
                        //targets.sort(var10001.thenComparingDouble(var10002::getDistance));
                }
            } else {
                this.cpsLimit = System.currentTimeMillis();
            }

            return (LivingEntity)targets.get(0);
        }
    }
    public int breakShield(LivingEntity target) {
        int hotBarSlot = InventoryUtil.getAxe(true);
        if (hotBarSlot != -1) {
            mc.player.connection.sendPacket(new CHeldItemChangePacket(hotBarSlot));
            mc.playerController.attackEntity(mc.player, target);
            mc.player.swingArm(Hand.MAIN_HAND);
            mc.player.connection.sendPacket(new CHeldItemChangePacket(mc.player.inventory.currentItem));
            return hotBarSlot;
        } else {
            int inventorySLot = InventoryUtil.getAxe(false);
            if (inventorySLot != -1) {
                mc.playerController.pickItem(inventorySLot);
                mc.playerController.attackEntity(mc.player, target);
                mc.player.swingArm(Hand.MAIN_HAND);
                return inventorySLot;
            } else {
                return -1;
            }
        }
    }
    private double getDistance(LivingEntity entity) {
        return AuraUtil.getVector(entity).length();
    }

    public double getEntityArmor(PlayerEntity target) {
        double totalArmor = 0.0;
        Iterator var4 = target.inventory.armorInventory.iterator();

        while(var4.hasNext()) {
            ItemStack armorStack = (ItemStack)var4.next();
            if (armorStack != null && armorStack.getItem() instanceof ArmorItem) {
                totalArmor += this.getProtectionLvl(armorStack);
            }
        }

        return totalArmor;
    }

    public double getEntityHealth(Entity ent) {
        if (ent instanceof PlayerEntity player) {
            double armorValue = this.getEntityArmor(player) / 20.0;
            return (double)(player.getHealth() + player.getAbsorptionAmount()) * armorValue;
        } else if (ent instanceof LivingEntity livingEntity) {
            return (double)(livingEntity.getHealth() + livingEntity.getAbsorptionAmount());
        } else {
            return 0.0;
        }
    }

    private double getProtectionLvl(ItemStack stack) {
        ArmorItem armor = (ArmorItem)stack.getItem();
        double damageReduce = (double)armor.getDamageReduceAmount();
        if (stack.isEnchanted()) {
            damageReduce += (double)EnchantmentHelper.getEnchantmentLevel(Enchantments.PROTECTION, stack) * 0.25;
        }

        return damageReduce;
    }
    @Override
    public void onDisable() {
        this.rotate = new Vector2f(mc.player.rotationYaw, mc.player.rotationPitch);
        target = null;
        this.cpsLimit = System.currentTimeMillis();
        super.onDisable();
    }
    public static LivingEntity getTarget() {
        return target;
    }
}
пошли в дс
crankycranky
 
Сверху Снизу