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

Визуальная часть ArrayList - Rich 1.21.11 fabric

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
3 Июн 2025
Сообщения
13
Реакции
0
Выберите загрузчик игры
  1. Fabric
Код:
Expand Collapse Copy
package rich.screens.hud;

import net.minecraft.client.gui.DrawContext;
import rich.client.draggables.AbstractHudElement;
import rich.modules.impl.render.Hud;
import rich.modules.module.ModuleRepository;
import rich.modules.module.ModuleStructure;
import rich.modules.module.category.ModuleCategory;
import rich.util.render.Render2D;
import rich.util.render.font.Fonts;
import rich.Initialization;

import java.awt.*;
import java.util.*;
import java.util.List;

public class ArrayListHud extends AbstractHudElement {
    private final List<Entry> entries = new ArrayList<>();
    private final Set<ModuleStructure> justAdded = new HashSet<>();

    private static final float HEIGHT = 11f;
    private static final float GAP = 1.5f;

    private long lastTimeNs = System.nanoTime();
    private static final float LERP_SPEED = 12f;

    public ArrayListHud() {
        super("ArrayList", 5, 40, 100, 100, true);
        startAnimation();
    }

    @Override
    public void tick() {
        ModuleRepository repo = Initialization.getInstance().getManager().getModuleRepository();
        Hud hud = Hud.getInstance();

        List<ModuleStructure> enabled = repo.modules()
                .stream()
                .filter(ModuleStructure::isState)
                .filter(module -> {

                    if (!hud.showVisualModules.isValue()) { //фильтр
                        return module.getCategory() != ModuleCategory.RENDER;
                    }
                    return true;
                })
                .toList();

        justAdded.clear();

        for (ModuleStructure module : enabled) {
            if (entries.stream().noneMatch(e -> e.module == module)) {
                Entry entry = new Entry(module);
                entries.add(entry);
                justAdded.add(module);
            }
        }
        entries.removeIf(entry -> enabled.stream().noneMatch(m -> m == entry.module));

        entries.sort(Comparator.comparingDouble(
                e -> -Fonts.BOLD.getWidth(e.module.getName(), 6)
        ));

        updateTargets();

        for (Entry entry : entries) {
            if (justAdded.contains(entry.module)) {
                entry.currentY = entry.targetY;
            }
        }
    }

    private void updateTargets() {
        float offset = 0;
        for (Entry entry : entries) {
            entry.targetY = offset;
            offset += HEIGHT + GAP;
        }
        setHeight((int) offset);
    }

    @Override
    public void drawDraggable(DrawContext context, int alpha) {
        float baseX = getX();
        float baseY = getY();
        float maxWidth = 0;

        long now = System.nanoTime();
        float deltaSec = (now - lastTimeNs) / 1_000_000_000f;
        lastTimeNs = now;
        deltaSec = Math.min(deltaSec, 0.05f);

        for (Entry entry : entries) {
            float diff = entry.targetY - entry.currentY;
            entry.currentY += diff * LERP_SPEED * deltaSec;
            if (Math.abs(diff) < 0.05f) {
                entry.currentY = entry.targetY;
            }
        }

        float screenW = mc.getWindow().getScaledWidth();
        boolean leftSide = baseX < screenW / 2f;

        for (Entry entry : entries) {
            ModuleStructure module = entry.module;
            float anim = module.getAnimation().getOutput().floatValue();
            if (anim <= 0.01f) continue;

            String name = module.getName();
            float textWidth = Fonts.BOLD.getWidth(name, 6);
            float width = textWidth + 6;
            maxWidth = Math.max(maxWidth, width);

            float x;
            if (leftSide) {
                x = baseX - width + (width * anim);
            } else {
                x = baseX + 60 - (width * anim);
            }

            float y = baseY + entry.currentY;

            int bgAlpha = (int) (180 * anim);
            int textAlpha = (int) (255 * anim);
            //тут рисуете че хотите и как хотите

            Render2D.outline(x, y, width, 11, 1f, new Color(90, 90, 90, bgAlpha).getRGB(), 3);

            Render2D.gradientRect(
                    x, y, width, HEIGHT,
                    new int[]{
                            new Color(52, 52, 52, bgAlpha).getRGB(),
                            new Color(22, 22, 22, bgAlpha).getRGB(),
                            new Color(52, 52, 52, bgAlpha).getRGB(),
                            new Color(22, 22, 22, bgAlpha).getRGB()
                    },
                    3
            );

            Fonts.BOLD.draw(
                    name,
                    x + 3, y + 2,
                    6,
                    new Color(255, 255, 255, textAlpha).getRGB()
            );
        }

        setWidth((int) maxWidth + 10);
    }

    private static class Entry {
        ModuleStructure module;
        float currentY;
        float targetY;

        Entry(ModuleStructure module) {
            this.module = module;
            this.currentY = 0;
            this.targetY = 0;
        }
    }
}

SS:
1771495510302.png


Сделал ArrayList приближённым к стилистике самого рича.
Присутствуют анимации, фильтр визуальных функций (render) и отзеркаливание при перемещении по горизонтали.

В модуле hud добавьте:
public BooleanSetting showVisualModules = new BooleanSetting("Show visual modules", "Показывать визуальные модули в ArrayList")
.setValue(true)
.visible(() -> interfaceSettings.isSelected("ArrayList"));

а так же в конструкторе hud (в конце класса) в параметры settings укажите "showVisualModules"


В общем кому нравится пусть использует, кому не нравится пусть отрисовывает сам как ему нравится, над дизайном я особо не старался
 
Код:
Expand Collapse Copy
package rich.screens.hud;

import net.minecraft.client.gui.DrawContext;
import rich.client.draggables.AbstractHudElement;
import rich.modules.impl.render.Hud;
import rich.modules.module.ModuleRepository;
import rich.modules.module.ModuleStructure;
import rich.modules.module.category.ModuleCategory;
import rich.util.render.Render2D;
import rich.util.render.font.Fonts;
import rich.Initialization;

import java.awt.*;
import java.util.*;
import java.util.List;

public class ArrayListHud extends AbstractHudElement {
    private final List<Entry> entries = new ArrayList<>();
    private final Set<ModuleStructure> justAdded = new HashSet<>();

    private static final float HEIGHT = 11f;
    private static final float GAP = 1.5f;

    private long lastTimeNs = System.nanoTime();
    private static final float LERP_SPEED = 12f;

    public ArrayListHud() {
        super("ArrayList", 5, 40, 100, 100, true);
        startAnimation();
    }

    @Override
    public void tick() {
        ModuleRepository repo = Initialization.getInstance().getManager().getModuleRepository();
        Hud hud = Hud.getInstance();

        List<ModuleStructure> enabled = repo.modules()
                .stream()
                .filter(ModuleStructure::isState)
                .filter(module -> {

                    if (!hud.showVisualModules.isValue()) { //фильтр
                        return module.getCategory() != ModuleCategory.RENDER;
                    }
                    return true;
                })
                .toList();

        justAdded.clear();

        for (ModuleStructure module : enabled) {
            if (entries.stream().noneMatch(e -> e.module == module)) {
                Entry entry = new Entry(module);
                entries.add(entry);
                justAdded.add(module);
            }
        }
        entries.removeIf(entry -> enabled.stream().noneMatch(m -> m == entry.module));

        entries.sort(Comparator.comparingDouble(
                e -> -Fonts.BOLD.getWidth(e.module.getName(), 6)
        ));

        updateTargets();

        for (Entry entry : entries) {
            if (justAdded.contains(entry.module)) {
                entry.currentY = entry.targetY;
            }
        }
    }

    private void updateTargets() {
        float offset = 0;
        for (Entry entry : entries) {
            entry.targetY = offset;
            offset += HEIGHT + GAP;
        }
        setHeight((int) offset);
    }

    @Override
    public void drawDraggable(DrawContext context, int alpha) {
        float baseX = getX();
        float baseY = getY();
        float maxWidth = 0;

        long now = System.nanoTime();
        float deltaSec = (now - lastTimeNs) / 1_000_000_000f;
        lastTimeNs = now;
        deltaSec = Math.min(deltaSec, 0.05f);

        for (Entry entry : entries) {
            float diff = entry.targetY - entry.currentY;
            entry.currentY += diff * LERP_SPEED * deltaSec;
            if (Math.abs(diff) < 0.05f) {
                entry.currentY = entry.targetY;
            }
        }

        float screenW = mc.getWindow().getScaledWidth();
        boolean leftSide = baseX < screenW / 2f;

        for (Entry entry : entries) {
            ModuleStructure module = entry.module;
            float anim = module.getAnimation().getOutput().floatValue();
            if (anim <= 0.01f) continue;

            String name = module.getName();
            float textWidth = Fonts.BOLD.getWidth(name, 6);
            float width = textWidth + 6;
            maxWidth = Math.max(maxWidth, width);

            float x;
            if (leftSide) {
                x = baseX - width + (width * anim);
            } else {
                x = baseX + 60 - (width * anim);
            }

            float y = baseY + entry.currentY;

            int bgAlpha = (int) (180 * anim);
            int textAlpha = (int) (255 * anim);
            //тут рисуете че хотите и как хотите

            Render2D.outline(x, y, width, 11, 1f, new Color(90, 90, 90, bgAlpha).getRGB(), 3);

            Render2D.gradientRect(
                    x, y, width, HEIGHT,
                    new int[]{
                            new Color(52, 52, 52, bgAlpha).getRGB(),
                            new Color(22, 22, 22, bgAlpha).getRGB(),
                            new Color(52, 52, 52, bgAlpha).getRGB(),
                            new Color(22, 22, 22, bgAlpha).getRGB()
                    },
                    3
            );

            Fonts.BOLD.draw(
                    name,
                    x + 3, y + 2,
                    6,
                    new Color(255, 255, 255, textAlpha).getRGB()
            );
        }

        setWidth((int) maxWidth + 10);
    }

    private static class Entry {
        ModuleStructure module;
        float currentY;
        float targetY;

        Entry(ModuleStructure module) {
            this.module = module;
            this.currentY = 0;
            this.targetY = 0;
        }
    }
}

SS:
Посмотреть вложение 328074

Сделал ArrayList приближённым к стилистике самого рича.
Присутствуют анимации, фильтр визуальных функций (render) и отзеркаливание при перемещении по горизонтали.

В модуле hud добавьте:
public BooleanSetting showVisualModules = new BooleanSetting("Show visual modules", "Показывать визуальные модули в ArrayList")
.setValue(true)
.visible(() -> interfaceSettings.isSelected("ArrayList"));

а так же в конструкторе hud (в конце класса) в параметры settings укажите "showVisualModules"


В общем кому нравится пусть использует, кому не нравится пусть отрисовывает сам как ему нравится, над дизайном я особо не старался
Ну норм
 
Код:
Expand Collapse Copy
package rich.screens.hud;

import net.minecraft.client.gui.DrawContext;
import rich.client.draggables.AbstractHudElement;
import rich.modules.impl.render.Hud;
import rich.modules.module.ModuleRepository;
import rich.modules.module.ModuleStructure;
import rich.modules.module.category.ModuleCategory;
import rich.util.render.Render2D;
import rich.util.render.font.Fonts;
import rich.Initialization;

import java.awt.*;
import java.util.*;
import java.util.List;

public class ArrayListHud extends AbstractHudElement {
    private final List<Entry> entries = new ArrayList<>();
    private final Set<ModuleStructure> justAdded = new HashSet<>();

    private static final float HEIGHT = 11f;
    private static final float GAP = 1.5f;

    private long lastTimeNs = System.nanoTime();
    private static final float LERP_SPEED = 12f;

    public ArrayListHud() {
        super("ArrayList", 5, 40, 100, 100, true);
        startAnimation();
    }

    @Override
    public void tick() {
        ModuleRepository repo = Initialization.getInstance().getManager().getModuleRepository();
        Hud hud = Hud.getInstance();

        List<ModuleStructure> enabled = repo.modules()
                .stream()
                .filter(ModuleStructure::isState)
                .filter(module -> {

                    if (!hud.showVisualModules.isValue()) { //фильтр
                        return module.getCategory() != ModuleCategory.RENDER;
                    }
                    return true;
                })
                .toList();

        justAdded.clear();

        for (ModuleStructure module : enabled) {
            if (entries.stream().noneMatch(e -> e.module == module)) {
                Entry entry = new Entry(module);
                entries.add(entry);
                justAdded.add(module);
            }
        }
        entries.removeIf(entry -> enabled.stream().noneMatch(m -> m == entry.module));

        entries.sort(Comparator.comparingDouble(
                e -> -Fonts.BOLD.getWidth(e.module.getName(), 6)
        ));

        updateTargets();

        for (Entry entry : entries) {
            if (justAdded.contains(entry.module)) {
                entry.currentY = entry.targetY;
            }
        }
    }

    private void updateTargets() {
        float offset = 0;
        for (Entry entry : entries) {
            entry.targetY = offset;
            offset += HEIGHT + GAP;
        }
        setHeight((int) offset);
    }

    @Override
    public void drawDraggable(DrawContext context, int alpha) {
        float baseX = getX();
        float baseY = getY();
        float maxWidth = 0;

        long now = System.nanoTime();
        float deltaSec = (now - lastTimeNs) / 1_000_000_000f;
        lastTimeNs = now;
        deltaSec = Math.min(deltaSec, 0.05f);

        for (Entry entry : entries) {
            float diff = entry.targetY - entry.currentY;
            entry.currentY += diff * LERP_SPEED * deltaSec;
            if (Math.abs(diff) < 0.05f) {
                entry.currentY = entry.targetY;
            }
        }

        float screenW = mc.getWindow().getScaledWidth();
        boolean leftSide = baseX < screenW / 2f;

        for (Entry entry : entries) {
            ModuleStructure module = entry.module;
            float anim = module.getAnimation().getOutput().floatValue();
            if (anim <= 0.01f) continue;

            String name = module.getName();
            float textWidth = Fonts.BOLD.getWidth(name, 6);
            float width = textWidth + 6;
            maxWidth = Math.max(maxWidth, width);

            float x;
            if (leftSide) {
                x = baseX - width + (width * anim);
            } else {
                x = baseX + 60 - (width * anim);
            }

            float y = baseY + entry.currentY;

            int bgAlpha = (int) (180 * anim);
            int textAlpha = (int) (255 * anim);
            //тут рисуете че хотите и как хотите

            Render2D.outline(x, y, width, 11, 1f, new Color(90, 90, 90, bgAlpha).getRGB(), 3);

            Render2D.gradientRect(
                    x, y, width, HEIGHT,
                    new int[]{
                            new Color(52, 52, 52, bgAlpha).getRGB(),
                            new Color(22, 22, 22, bgAlpha).getRGB(),
                            new Color(52, 52, 52, bgAlpha).getRGB(),
                            new Color(22, 22, 22, bgAlpha).getRGB()
                    },
                    3
            );

            Fonts.BOLD.draw(
                    name,
                    x + 3, y + 2,
                    6,
                    new Color(255, 255, 255, textAlpha).getRGB()
            );
        }

        setWidth((int) maxWidth + 10);
    }

    private static class Entry {
        ModuleStructure module;
        float currentY;
        float targetY;

        Entry(ModuleStructure module) {
            this.module = module;
            this.currentY = 0;
            this.targetY = 0;
        }
    }
}

SS:
Посмотреть вложение 328074

Сделал ArrayList приближённым к стилистике самого рича.
Присутствуют анимации, фильтр визуальных функций (render) и отзеркаливание при перемещении по горизонтали.

В модуле hud добавьте:
public BooleanSetting showVisualModules = new BooleanSetting("Show visual modules", "Показывать визуальные модули в ArrayList")
.setValue(true)
.visible(() -> interfaceSettings.isSelected("ArrayList"));

а так же в конструкторе hud (в конце класса) в параметры settings укажите "showVisualModules"


В общем кому нравится пусть использует, кому не нравится пусть отрисовывает сам как ему нравится, над дизайном я особо не старался
ну почти не нужно а так ну хз подходит по дизайну
 
Назад
Сверху Снизу