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

Вопрос [РЕШЕНО] Флагает килка без удара

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
9 Июн 2024
Сообщения
92
Реакции
0
Написал килку (снапы) на ротацию не смотрите, спастил с 2.0 экспы, но вопрос в другом. Когда я просто включаю килку. Двигаюсь и мотаю головой (и есть таргет) то риллик флагает (хотя бошка не поворачивается серверно проверял, не двигается)

аура:
Expand Collapse Copy
public class Aura extends Module {

    private final ModeSetting mode = add(new ModeSetting(
            "Rotation Mode", "Snap", "Normal", "Snap"
    ));

    private final NumberSetting range = add(new NumberSetting(
            "Range", 3.0f, 3.0f, 6.0f, 0.1f
    ));

    private final NumberSetting preRange = add(new NumberSetting(
            "Pre Range", 0.5f, 0.0f, 3.0f, 0.1f
    ));

    private final MultiSetting targets = add(new MultiSetting(
            "Targets", "Players", "Animals", "Monsters"
    ));

    private final MultiSetting ignore = add(new MultiSetting(
            "Ignore", "Invisible", "Naked", "Bots"
    ));

    private final ModeSetting sort = add(new ModeSetting(
            "Sort", "Distance", "Distance", "Health", "FOV"
    ));

    private final BoolSetting onlyCrits = add(new BoolSetting("Only Crits", true));
    private final BoolSetting moveFix = add(new BoolSetting("Move Fix", true));
    private final BoolSetting unsprint = add(new BoolSetting("Unsprint", true));
    private final BoolSetting breakShield = add(new BoolSetting("Break Shield", true));

    private final Minecraft mc = Minecraft.getInstance();

    private LivingEntity target;
    private float rotYaw, rotPitch;
    private long cpsLimit;
    private int ticks;

    public Aura() {
        super("Aura", "Automatically attacks nearby entities", ModuleCategory.UTIL);
        targets.toggle("Players");
    }


    @EventHandler
    public void onUpdate(TickEvent event) {
        if (mc.player == null || mc.world == null) return;

        target = findTarget();

        if (target == null) {
            reset();
            return;
        }

        switch (mode.get()) {
            case "Normal" -> {
                updateRotation(0.5f);
                if (canAttack()) {
                    attackTarget(target);
                }
            }
            case "Snap" -> {
                if (canAttack()) {
                    updateRotation(1.0f);
                    attackTarget(target);
                    ticks = 2;
                }

                if (ticks > 0) {
                    ticks--;
                } else {
                    rotYaw = mc.player.rotationYaw;
                    rotPitch = mc.player.rotationPitch;
                }
            }
        }
    }

    @EventHandler
    public void onMotion(EventMotion event) {
        if (target == null) return;

        event.setYaw(rotYaw);
        event.setPitch(rotPitch);

        mc.player.rotationYawHead = rotYaw;
        mc.player.renderYawOffset = rotYaw;
        mc.player.rotationPitchHead = rotPitch;
    }

    @EventHandler
    public void onInput(EventInput event) {
        if (target != null && moveFix.get()) {
            MoveUtil.fixMovement(event, rotYaw);
        }
    }

    private LivingEntity findTarget() {
        List<LivingEntity> list = new ArrayList<>();

        for (Entity entity : mc.world.getAllEntities()) {
            if (!(entity instanceof LivingEntity living)) continue;
            if (!isValid(living)) continue;

            double maxRange = range.get() +
                    (mode.get().equals("Normal") ? preRange.get() : 0.0f);

            if (getDistance(living) <= maxRange) {
                list.add(living);
            }
        }

        if (list.isEmpty()) return null;

        Comparator<LivingEntity> comparator = switch (sort.get()) {
            case "Health" -> Comparator.comparingDouble(LivingEntity::getHealth);
            case "FOV" -> Comparator.comparingDouble(this::getDegree);
            default -> Comparator.comparingDouble(this::getDistance);
        };

        return list.stream().min(comparator).orElse(null);
    }

    private boolean isValid(LivingEntity entity) {
        if (entity == mc.player || entity instanceof ArmorStandEntity)
            return false;

        if (ignore.enabled("Invisible") && entity.isInvisible())
            return false;

        if (ignore.enabled("Naked") &&
                entity instanceof PlayerEntity &&
                entity.getTotalArmorValue() == 0)
            return false;

        if (entity instanceof PlayerEntity)
            return targets.enabled("Players");

        if (entity instanceof AnimalEntity || entity instanceof WaterMobEntity)
            return targets.enabled("Animals");

        if (entity instanceof MonsterEntity || entity instanceof SlimeEntity)
            return targets.enabled("Monsters");

        return false;
    }

    private void updateRotation(float speed) {
        if (isInHitBox(mc.player, target)) return;

        Vector3d vec = getVector3d(mc.player, target);

        float rawYaw = (float) MathHelper.wrapDegrees(
                Math.toDegrees(Math.atan2(vec.z, vec.x)) - 90.0F
        );
        float rawPitch = (float) MathHelper.wrapDegrees(
                Math.toDegrees(-Math.atan2(vec.y, Math.hypot(vec.x, vec.z)))
        );

        float yawDelta = MathHelper.wrapDegrees(rawYaw - rotYaw);
        float pitchDelta = MathHelper.wrapDegrees(rawPitch - rotPitch);

        float yaw = rotYaw + MathHelper.clamp(yawDelta, -60f * speed, 60f * speed)
                + ThreadLocalRandom.current().nextFloat(-1f, 1f);

        float pitch = rotPitch + MathHelper.clamp(pitchDelta, -40f * speed, 40f * speed)
                + ThreadLocalRandom.current().nextFloat(-1f, 1f);

        rotYaw = applyGCD(yaw);
        rotPitch = applyGCD(MathHelper.clamp(pitch, -89f, 89f));
    }

    private float applyGCD(float angle) {
        float sensitivity = (float) mc.gameSettings.mouseSensitivity;
        float gcd = sensitivity * 0.6F + 0.2F;
        gcd = gcd * gcd * gcd * 8.0F;
        return angle - (angle % gcd);
    }


    private boolean canAttack() {
        if (target == null) return false;
        if (System.currentTimeMillis() < cpsLimit) return false;
        if (getDistance(target) > range.get()) return false;
        if (mc.player.getCooledAttackStrength(1.0f) <= 0.93f) return false;

        if (!onlyCrits.get()) return true;

        if (mc.player.isInWater() && mc.player.areEyesInFluid(FluidTags.WATER))
            return true;

        if (mc.player.isOnLadder() || mc.player.abilities.isFlying ||
                mc.player.isElytraFlying() ||
                mc.player.isPotionActive(Effects.LEVITATION) ||
                mc.player.isPotionActive(Effects.SLOW_FALLING))
            return true;

        return mc.player.fallDistance > 0 && !mc.player.isOnGround();
    }

    private void attackTarget(LivingEntity entity) {
        boolean wasSprinting = mc.player.isSprinting();

        if (unsprint.get() && wasSprinting) {
            mc.player.connection.sendPacket(
                    new CEntityActionPacket(mc.player,
                            CEntityActionPacket.Action.STOP_SPRINTING));
            mc.player.setSprinting(false);
        }

        cpsLimit = System.currentTimeMillis() + 550;

        mc.playerController.attackEntity(mc.player, entity);
        mc.player.swingArm(Hand.MAIN_HAND);

        if (breakShield.get() &&
                entity instanceof PlayerEntity &&
                ((PlayerEntity) entity).isActiveItemStackBlocking()) {

            int axeSlot = InventoryUtil.getAxe(true);
            if (axeSlot != -1) {
                int prev = mc.player.inventory.currentItem;

                mc.player.connection.sendPacket(new CHeldItemChangePacket(axeSlot));
                mc.player.inventory.currentItem = axeSlot;

                mc.playerController.attackEntity(mc.player, entity);
                mc.player.swingArm(Hand.MAIN_HAND);

                mc.player.connection.sendPacket(new CHeldItemChangePacket(prev));
                mc.player.inventory.currentItem = prev;
            }
        }

        if (unsprint.get() && wasSprinting) {
            mc.player.connection.sendPacket(
                    new CEntityActionPacket(mc.player,
                            CEntityActionPacket.Action.START_SPRINTING));
            mc.player.setSprinting(true);
        }
    }


    private Vector3d getVector3d(LivingEntity from, LivingEntity to) {
        double wHalf = to.getWidth() / 2;
        double yExpand = MathHelper.clamp(
                from.getPosYEye() - to.getPosY(),
                0,
                to.getHeight() * (from.getDistance(to) / range.get())
        );

        double xExpand = MathHelper.clamp(
                from.getPosX() - to.getPosX(),
                -wHalf,
                wHalf
        );

        double zExpand = MathHelper.clamp(
                from.getPosZ() - to.getPosZ(),
                -wHalf,
                wHalf
        );

        return new Vector3d(
                to.getPosX() - from.getPosX() + xExpand,
                to.getPosY() - from.getPosYEye() + yExpand,
                to.getPosZ() - from.getPosZ() + zExpand
        );
    }

    private boolean isInHitBox(LivingEntity me, LivingEntity to) {
        return getVector3d(me, to).length() == 0;
    }

    private double getDistance(LivingEntity entity) {
        return getVector3d(mc.player, entity).length();
    }

    private double getDegree(LivingEntity entity) {
        Vector3d vec = getVector3d(mc.player, entity);
        double yaw = MathHelper.wrapDegrees(
                Math.toDegrees(Math.atan2(vec.z, vec.x)) - 90
        );
        double delta = MathHelper.wrapDegrees(yaw - mc.player.rotationYaw);
        return Math.abs(delta);
    }

    private void reset() {
        if (mc.player == null) return;
        rotYaw = mc.player.rotationYaw;
        rotPitch = mc.player.rotationPitch;
        target = null;
    }

    @Override
    public void onEnable() {
        reset();
    }

    @Override
    public void onDisable() {
        reset();
    }
}

тут вызов моушена:

моушен евент:
Expand Collapse Copy
    private void onUpdateWalkingPlayer() {
        boolean flag = this.isSprinting();

        if (flag != this.serverSprintState) {
            CEntityActionPacket.Action action = flag
                    ? CEntityActionPacket.Action.START_SPRINTING
                    : CEntityActionPacket.Action.STOP_SPRINTING;
            this.connection.sendPacket(new CEntityActionPacket(this, action));
            this.serverSprintState = flag;
        }

        boolean sneak = this.isSneaking();

        if (sneak != this.clientSneakState) {
            CEntityActionPacket.Action action = sneak
                    ? CEntityActionPacket.Action.PRESS_SHIFT_KEY
                    : CEntityActionPacket.Action.RELEASE_SHIFT_KEY;
            this.connection.sendPacket(new CEntityActionPacket(this, action));
            this.clientSneakState = sneak;
        }

        if (this.isCurrentViewEntity()) {

            EventMotion event = new EventMotion(
                    this.getPosX(),
                    this.getPosY(),
                    this.getPosZ(),
                    this.rotationYaw,
                    this.rotationPitch,
                    this.onGround
            );

            TaiufunClient.get().bus().post(event);

            if (event.isCancelled()) {
                return;
            }

            double dx = event.getX() - this.lastReportedPosX;
            double dy = event.getY() - this.lastReportedPosY;
            double dz = event.getZ() - this.lastReportedPosZ;
            double dyaw = event.getYaw() - this.lastReportedYaw;
            double dpitch = event.getPitch() - this.lastReportedPitch;

            ++this.positionUpdateTicks;

            boolean positionChanged = dx * dx + dy * dy + dz * dz > 9.0E-4D || this.positionUpdateTicks >= 20;
            boolean rotationChanged = dyaw != 0.0D || dpitch != 0.0D;

            if (this.isPassenger()) {
                Vector3d motion = this.getMotion();
                this.connection.sendPacket(new CPlayerPacket.PositionRotationPacket(
                        motion.x,
                        -999.0D,
                        motion.z,
                        event.getYaw(),
                        event.getPitch(),
                        event.isOnGround()
                ));
                positionChanged = false;
            } else if (positionChanged && rotationChanged) {
                this.connection.sendPacket(new CPlayerPacket.PositionRotationPacket(
                        event.getX(),
                        event.getY(),
                        event.getZ(),
                        event.getYaw(),
                        event.getPitch(),
                        event.isOnGround()
                ));
            } else if (positionChanged) {
                this.connection.sendPacket(new CPlayerPacket.PositionPacket(
                        event.getX(),
                        event.getY(),
                        event.getZ(),
                        event.isOnGround()
                ));
            } else if (rotationChanged) {
                this.connection.sendPacket(new CPlayerPacket.RotationPacket(
                        event.getYaw(),
                        event.getPitch(),
                        event.isOnGround()
                ));
            } else if (this.prevOnGround != event.isOnGround()) {
                this.connection.sendPacket(new CPlayerPacket(event.isOnGround()));
            }

            if (positionChanged) {
                this.lastReportedPosX = event.getX();
                this.lastReportedPosY = event.getY();
                this.lastReportedPosZ = event.getZ();
                this.positionUpdateTicks = 0;
            }

            if (rotationChanged) {
                this.lastReportedYaw = event.getYaw();
                this.lastReportedPitch = event.getPitch();
            }

            this.prevOnGround = event.isOnGround();
            this.autoJumpEnabled = this.mc.gameSettings.autoJump;
        }
    }
серверно проверял, не двигается)
вплане двигается нормально
 
Назад
Сверху Снизу