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

Часть функционала Auto Chorus

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
19 Янв 2023
Сообщения
34
Реакции
1
Выберите загрузчик игры
  1. Vanilla
  2. OptiFine
Функция ест хорус если цель в ауре его ест (чтобы из трапки там вылезти)
довольно полезно,

SS ->

ps: база не rock

сам код$$:
Expand Collapse Copy
// поля
    int prevChorus;
    public boolean usingChorus;
    TimerUtil chorusTimer = new TimerUtil();
    TimerUtil chorusWaitTimer = new TimerUtil();
// логика
Aura aura = Modules.get(Aura.class);

            if (e instanceof EventTick event) {
                LivingEntity target = aura.prevTarget;

                if (target != null) {
                    if (mc.player.getDistance(target) < 5) {
                        if (!(target.getActiveItemStack().getItem() instanceof ChorusFruitItem)) {
                            chorusTimer.reset();
                        }

                        if (chorusTimer.elapsed(200) && target.getActiveItemStack().getItem() instanceof ChorusFruitItem) {
                            int slot = Player.findItemNoChanges(44, Items.CHORUS_FRUIT);

                            boolean inHotbar = slot <= 8;
                            if (slot != -1 && !usingChorus) {
                                prevChorus = mc.player.inventory.currentItem;
                                mc.gameSettings.keyBindUseItem.setPressed(true);

                                if (inHotbar) {
                                    mc.player.inventory.currentItem = slot;
                                } else {
                                    mc.playerController.pickItem(slot);
                                }

                                usingChorus = true;
                            }

                            chorusWaitTimer.reset();
                        }
                    }

                    if (usingChorus && chorusWaitTimer.elapsed(1000)) {
                        boolean inHotbar = prevChorus <= 8;

                        mc.gameSettings.keyBindUseItem.setPressed(false);

                        if (inHotbar) {
                            mc.player.inventory.currentItem = prevChorus;
                        } else {
                            mc.playerController.pickItem(prevChorus);
                        }
                        usingChorus = false;
                    }
                }
            }

            if (e instanceof EventReceivePacket event && aura.prevTarget != null) {
                LivingEntity target = aura.prevTarget;

                if (event.packet instanceof SEntityTeleportPacket packet && packet.getEntityId() == target.getEntityId()) {
                    chorusWaitTimer.reset();
                }
            }

            // Не бьем если хаваем
            if (e instanceof EventAttack event && usingChorus) {
                event.cancel();
            }

            if (e instanceof EventFinishEat event && event.entity == mc.player && usingChorus) {
                if (event.item instanceof ChorusFruitItem) {
                    boolean inHotbar = prevChorus <= 8;

                    if (inHotbar) {
                        mc.player.inventory.currentItem = prevChorus;
                    } else {
                        mc.playerController.pickItem(prevChorus);
                    }

                    mc.gameSettings.keyBindUseItem.setPressed(false);
                    usingChorus = false;
                }
            }
 
дядя стен я тебе не верю
могу доказать

вот таргет худ есличто:
тхуд:
Expand Collapse Copy
public class TargetHud extends UIElement {

    CheckBox hpClr = new CheckBox(this, "Цвет от здоровья");

    Mode mode = new Mode(this, "Отображение хп");
    Mode.Element def = new Mode.Element(mode, "Обычно");
    Mode.Element procent = new Mode.Element(mode, "Проценты").set();

    Mode hpMode = new Mode(this, "Отображение здоровья");
    Mode.Element circle = new Mode.Element(hpMode, "Круг");
    Mode.Element line = new Mode.Element(hpMode, "Круг слева");
    Mode.Element bar = new Mode.Element(hpMode, "Полоска");

    CheckBox thickness = new CheckBox(this, "Толстый круг").vis(() -> circle.get());

    CheckBox centre = new CheckBox(this, "Центрировать хп").vis(() -> bar.get());

    CheckBox rayTrace = new CheckBox(this, "Показывать при наводке");


    LivingEntity target, prev;

    Animation size = new Animation().setEasing(Easing.EASE_OUT_BACK).setSpeed(500),
            waiting = new Animation().setEasing(Easing.BOTH_SINE).setSpeed(700),
            prevAnim = new Animation().setEasing(Easing.BOTH_SINE).setSpeed(420),
            colorChange = new Animation().setEasing(Easing.BOTH_SINE).setSpeed(500),
            hurtAnim = new Animation().setEasing(Easing.BOTH_CIRC).setSpeed(200),
            toHide = new Animation().setEasing(Easing.BOTH_CIRC).setSpeed(300);

    InfinityAnimation unitAnim = new InfinityAnimation(),
        healthAnim = new InfinityAnimation(),
        gappleAnim = new InfinityAnimation();

    public TargetHud(Interface ui, Select select) {
        super(select, "Таргет", new Rect(200,200,0,0));
    }

    public void event(Event event) {
        if (event instanceof EventRender e)
            renderHud(e.getMS());

        super.event(event);
    }

    private void renderHud(MatrixStack ms) {
        float x = draggable.getX(), y = draggable.getY();
        float width = line.get() ? 106 : 136;

        Aura aura = Modules.get(Aura.class);
        LivingEntity find = null;

        // Обновляем текущий таргет
        if (aura.get()) find = aura.target;

        RayTraceResult traceResult = mc.objectMouseOver;

        if (rayTrace.get() && find == null && traceResult != null && traceResult.getType() == RayTraceResult.Type.ENTITY) {
            Entity entity = ((EntityRayTraceResult) traceResult).getEntity();
            if (!(entity instanceof LivingEntity)) return;

            find = (LivingEntity) entity;
        }

        if (find == null && mc.currentScreen instanceof ChatScreen)
            find = mc.player;

        waiting.setForward(find != null);
        prevAnim.setForward(!waiting.finished(false));
        size.setForward(!prevAnim.finished(false));

        if (find != null)
            prev = find;

        LivingEntity active = prev;

        Rect rect = new Rect(x, y, width, 37);
        FixColor[] colors = Interface.getCircle(showing.get());

        Render.scale(x + width / 2, y + rect.height / 2, size() * size.get());
        Render.rect(null, rect, 4, Theme.getFirst().move(FixColor.WHITE.rgb(), hover()).alpha(showing.get() * size.get()).rgb());

        // Косметика
        Render.outline(rect, showing.get() * size.get());
        Render.glow(rect, 4, showing.get() * size.get());

        if (!size.finished(false)) {
            // Анимация хп
            float max = active.getMaxHealth();
            float unit = Server.forHPFix() ? active.realHealth : active.getHealth()+active.getAbsorptionAmount();
            float health = Math.max(0, Math.min(1, Server.forHPFix() ? active.realHealth / 20F : (active.getHealth()) / max));
            float gapple = Math.max(0, Math.min(1, Server.forHPFix() ? 0 : active.getAbsorptionAmount() / max));

            healthAnim.animate(health * showing.get(), 100);
            gappleAnim.animate(gapple * showing.get(), 100);
            unitAnim.animate(unit * showing.get(), 90);

            float alpha = showing.get() * size.get();

            // Сайзим
            Scissors.start(Render.getScalar(x, y, width, rect.height, size() * size.get()));

            // Рендерим все остальное
            float size = 28;
            float anim = prevAnim.reversed() * rect.height * 1.5f;

            Render.rect(null, new Rect(x + rect.height / 2 - size/2 - anim, y + rect.height / 2 - size/2, size, size), size / 2, Theme.getSecond().alpha(alpha).rgb());

            Scissors.init();
            Render.rect(null, new Rect(x + rect.height / 2 - size/2 - anim, y + rect.height / 2 - size/2, size, size), size / 2, Theme.getSecond().alpha(alpha).rgb());
            Scissors.read(1);

            RenderSystem.disableDepthTest();
            InventoryScreen.drawEntityOnScreen((int) (x + rect.height / 2 - anim), (int) (y + rect.height / 2 + 2 + active.getHeight() * 20 - (Modules.get(Cosmetics.class).getModel(target) == 1 ? 10 : 0)), (int)(25), -20, 10, active);
            RenderSystem.enableDepthTest();

            Scissors.finish();

            // Рендерим хпшки
            FixColor color = hpClr.get() ? (healthAnim.get() > 0.5f ? FixColor.ORANGE.move(FixColor.GREEN.rgb(), (healthAnim.get()-0.5f) * 2) : FixColor.RED.move(FixColor.ORANGE.rgb(), healthAnim.get() * 2)) : colors[0];
            String hp = procent.get() ? String.format("%.0f%%", (unitAnim.get() / max) * 100f) : String.format("%.0f", unitAnim.get());

            if (line.get()) {
                if (hpClr.get())
                    Render.circle(x + rect.height / 2 - anim, y + rect.height - size / 1.55F, size / 2, 1.5f, false, color.alpha(alpha), (int) (360 * healthAnim.get()));
                else
                    Render.circleClient(x + rect.height / 2 - anim, y + rect.height - size / 1.55F, size / 2, 1.5f, alpha, (int) (360 * healthAnim.get()));

                if (gappleAnim.get() > 0.1f && !Server.isFT()) {
                    Render.circle(x + rect.height / 2 - anim, y + rect.height - size / 1.55F, size / 2, 1.5f, false, FixColor.YELLOW.alpha(alpha), (int) (360 * gappleAnim.get()));
                }
            } else if (circle.get()) {
                size = 26;
                float circleX = x + width - rect.height / 2;
                float circleY = y + rect.height - size / 1.5F - 1;
                float radius = size / 2, th = thickness.get() ? 4 : 3;

                Render.circle(circleX, circleY, radius, th, false, Theme.getSecond().alpha(alpha), 360);

                if (hpClr.get())
                    Render.circle(circleX, circleY, radius, th, false, color.alpha(alpha), (int) (360 * healthAnim.get()));
                else
                    Render.circleClient(circleX, circleY, radius, th, alpha, (int) (360 * healthAnim.get()));

                if (gappleAnim.get() > 0.1f && !Server.isFT()) {
                    Render.circle(circleX, circleY, radius, th, false, FixColor.YELLOW.alpha(alpha), (int) (360 * gappleAnim.get()));
                }

                int font = procent.get() ? 14 : 16;
                bold[font].draw(ms, hp, circleX - bold[font].getWidth(hp) / 2, (int)circleY - (procent.get() ? .5f : 1) - .5f, Theme.getText().alpha(alpha).Int());
            } else if (bar.get()) {
                Rect bar = new Rect(x + rect.height, y + rect.height - 16 + hurtAnim.get() / 2 + anim, width - rect.height * 2 + 3, 8 - hurtAnim.get());

                FixColor first = colors[0].alpha(alpha),
                        two = colors[2].alpha(alpha);

                if (hpClr.get()) {
                    first = color.alpha(alpha);
                    two = color.darker(140).alpha(alpha);
                }

                hurtAnim.setForward(active.hurtTime >= 4);

                float width2 = bar.width * gappleAnim.get();
                float width1 = Math.max(0, bar.width * healthAnim.get() - width2);

                if (width1 > 0) {
                    Render.gradient(bar.x, bar.y, width1, bar.height, 1.5f, first.rgb(), first.rgb(), two.rgb(), two.rgb());
                }

                if (gappleAnim.get() > 0.1f && !Server.isFT() && width2 > 0) {
                    FixColor yellow = FixColor.YELLOW.alpha(alpha);

                    Render.gradient(bar.x + width1 + 1, bar.y, width2 - 1, bar.height, 1.5f, yellow.rgb(), yellow.rgb(), yellow.darker(150).rgb(), yellow.darker(150).rgb());
                }

                float textX;

                if (centre.get()) {
                    textX = bar.x + (width1 - bold[10].getWidth(hp)) / 2;
                } else {
                    textX = bar.x + width1 - bold[10].getWidth(hp) - 3;
                }
                textX = Math.max(bar.x, textX);

                colorChange.setForward((first.getBrightness() + two.getBrightness()) / 2f < 0.3f);
                toHide.setForward(width1 < bold[10].getWidth(hp));

                bold[10].drawShadow(ms, hp, textX, bar.y + bar.height / 2 + 0.75f, FixColor.WHITE.move(FixColor.BLACK.rgb(), colorChange.get()).alpha(alpha * toHide.reversed()).Int());
            }

            float width1 = (width - 5) - rect.height;

            // Предметы
            ArrayList<ItemStack> stacks = new ArrayList<>();
            active.getArmorInventoryList().forEach((stack) -> {
                if (!stack.isEmpty()) {
                    stacks.add(stack);
                }
            });

            if (!bar.get()) {
                if (!active.getHeldItemMainhand().isEmpty()) stacks.add(active.getHeldItemMainhand());
                if (!active.getHeldItemOffhand().isEmpty()) stacks.add(active.getHeldItemOffhand());

                Scissors.init();
                Render.rect(null, x + rect.height, y + 19, width1, 16, 0, Theme.getFirst().alpha(alpha).rgb());
                Scissors.read(1);

                float xOff = 0;
                for (ItemStack stack : stacks) {
                    Render.drawStack(stack, x + rect.height + xOff, y + 20 + anim, 0.6F);
                    xOff += 10.5F;
                }

                Scissors.finish();
            } else {
                Scissors.init();
                Render.rect(null, x + 11 + width - rect.height, y + rect.height / 4.5f, 30, 30, 0, Theme.getFirst().alpha(alpha).rgb());
                Scissors.read(1);

                int count = 0;
                float xOff = 0, yOff = 0;
                for (ItemStack stack : stacks) {
                    Render.drawStack(stack, x + 11 + width - rect.height + xOff + anim, y + rect.height / 4.5f + yOff, 0.6F);

                    if (count == 0) {
                        xOff += 9.5F;
                    } else {
                        yOff += 9.5F;
                    }

                    count++;
                    if (count > 1) {
                        xOff = 0;
                        count = 0;
                    }
                }

                // Если нет предметов
                xOff = 0; yOff = 1;
                if (stacks.isEmpty()) {
                    for (int i = 0; i < 4; i++) {
                        Render.rect(ms, x + 11 + width - rect.height + xOff + anim, y + rect.height / 4.5f + yOff, 8.25f, 8.25f, 1.5f, Theme.getSecond().rgb());

                        if (count == 0) {
                            xOff += 10;
                        } else {
                            yOff += 10;
                        }

                        count++;
                        if (count > 1) {
                            xOff = 0;
                            count = 0;
                        }
                    }
                }

                Scissors.finish();
            }

            // Имя
            String name = NameProtect.correct(active.getName().getString());

            if (name.length() > 14)
                name = name.substring(0, 14);

            Scissors.init();
            Render.rect(null, x + rect.height, y - anim, width1 - 5 - (line.get() ? -4 : 25), 18, 0, Theme.getFirst().alpha(alpha).rgb());
            Scissors.read(1);

            bold[17].draw(ms, name, (int)(x + rect.height), (int)(y + 11) - anim, Theme.getText().alpha(alpha).Int());

            FixColor bg = Theme.getFirst().move(FixColor.WHITE.rgb(), hover());
            Render.gradient(x + rect.height + bold[17].getWidth(name) - 10, y + 6.5f - anim, 11, 12, 0, bg.alpha(0).rgb(), bg.alpha(0).rgb(), bg.alpha(alpha).rgb(), bg.alpha(alpha).rgb());

            Scissors.finish();

            Scissors.stop();
        }

        RenderSystem.popMatrix();

        draggable.width(width);
        draggable.height(rect.height);
    }
}
 
Функция ест хорус если цель в ауре его ест (чтобы из трапки там вылезти)
довольно полезно,

SS ->

ps: база не rock

сам код$$:
Expand Collapse Copy
// поля
    int prevChorus;
    public boolean usingChorus;
    TimerUtil chorusTimer = new TimerUtil();
    TimerUtil chorusWaitTimer = new TimerUtil();
// логика
Aura aura = Modules.get(Aura.class);

            if (e instanceof EventTick event) {
                LivingEntity target = aura.prevTarget;

                if (target != null) {
                    if (mc.player.getDistance(target) < 5) {
                        if (!(target.getActiveItemStack().getItem() instanceof ChorusFruitItem)) {
                            chorusTimer.reset();
                        }

                        if (chorusTimer.elapsed(200) && target.getActiveItemStack().getItem() instanceof ChorusFruitItem) {
                            int slot = Player.findItemNoChanges(44, Items.CHORUS_FRUIT);

                            boolean inHotbar = slot <= 8;
                            if (slot != -1 && !usingChorus) {
                                prevChorus = mc.player.inventory.currentItem;
                                mc.gameSettings.keyBindUseItem.setPressed(true);

                                if (inHotbar) {
                                    mc.player.inventory.currentItem = slot;
                                } else {
                                    mc.playerController.pickItem(slot);
                                }

                                usingChorus = true;
                            }

                            chorusWaitTimer.reset();
                        }
                    }

                    if (usingChorus && chorusWaitTimer.elapsed(1000)) {
                        boolean inHotbar = prevChorus <= 8;

                        mc.gameSettings.keyBindUseItem.setPressed(false);

                        if (inHotbar) {
                            mc.player.inventory.currentItem = prevChorus;
                        } else {
                            mc.playerController.pickItem(prevChorus);
                        }
                        usingChorus = false;
                    }
                }
            }

            if (e instanceof EventReceivePacket event && aura.prevTarget != null) {
                LivingEntity target = aura.prevTarget;

                if (event.packet instanceof SEntityTeleportPacket packet && packet.getEntityId() == target.getEntityId()) {
                    chorusWaitTimer.reset();
                }
            }

            // Не бьем если хаваем
            if (e instanceof EventAttack event && usingChorus) {
                event.cancel();
            }

            if (e instanceof EventFinishEat event && event.entity == mc.player && usingChorus) {
                if (event.item instanceof ChorusFruitItem) {
                    boolean inHotbar = prevChorus <= 8;

                    if (inHotbar) {
                        mc.player.inventory.currentItem = prevChorus;
                    } else {
                        mc.playerController.pickItem(prevChorus);
                    }

                    mc.gameSettings.keyBindUseItem.setPressed(false);
                    usingChorus = false;
                }
            }
так сложно поиск хоруса в инве сделать поедание его,
так же проверку если таргет ест, и у него в руке хорус?
 
Назад
Сверху Снизу