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

Часть функционала Rich 1.21.11 KeyBinds + Info

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
12 Мар 2026
Сообщения
57
Реакции
0
Выберите загрузчик игры
  1. Fabric
Пожалуйста, авторизуйтесь для просмотра ссылки.



WexHudCoords.java:
Expand Collapse Copy
package ARTheryx.screens.hud.wex;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.util.math.Vec3d;
import ARTheryx.client.draggables.AbstractHudElement;
import ARTheryx.modules.impl.render.Hud;
import ARTheryx.util.render.Render2D;
import ARTheryx.util.render.font.Fonts;

import java.awt.*;

public class WexHudCoords extends AbstractHudElement {

    private static final float FONT_SIZE = 6.0f;
    private static final float TITLE_SIZE = 6.5f;
    private static final float MIN_WIDTH = 110.0f;
    private static final float MIN_HEIGHT = 25.0f;
    private static final float ROW_HEIGHT = 12.0f;
    private static final float ANIMATION_SPEED = 6.0f;

    private float animatedWidth = MIN_WIDTH;
    private float animatedHeight = MIN_HEIGHT;
    private long lastUpdateTime = System.currentTimeMillis();

    public WexHudCoords() {
        super("Coords", 2, 100, 110, 25, true);
        stopAnimation();
    }

    @Override
    public boolean visible() {
        Hud h = Hud.getInstance();
        return h != null && h.isState() && h.isHudPartEnabled("Coords") && mc.player != null;
    }

    @Override
    public void tick() {
        if (mc.player == null) {
            stopAnimation();
            return;
        }
        startAnimation();
    }

    private float lerp(float current, float target, float deltaTime) {
        float factor = (float) (1.0 - Math.pow(0.0001, deltaTime * ANIMATION_SPEED));
        return current + (target - current) * factor;
    }

    @Override
    public void drawDraggable(DrawContext context, int alpha) {
        if (mc.player == null || alpha <= 0) return;

        float x = getX();
        float y = getY();
        float alphaFactor = alpha / 255.0f;

        long now = System.currentTimeMillis();
        float deltaTime = (now - lastUpdateTime) / 1000.0f;
        lastUpdateTime = now;
        deltaTime = Math.min(deltaTime, 0.1f);

       
        Vec3d vel = mc.player.getVelocity();
        double speed = Math.hypot(vel.x, vel.z) * 20.0;
        var pos = mc.player.getBlockPos();

        String speedValue = String.format("%.1f", speed);
        String speedLabel = "b/s";

        String xValue = String.valueOf(pos.getX());
        String yValue = String.valueOf(pos.getY());
        String zValue = String.valueOf(pos.getZ());


        float speedLabelW = Fonts.mntsb.getWidth("Speed", FONT_SIZE);
        float speedValueW = Fonts.mntsb.getWidth(speedValue, FONT_SIZE);
        float speedUnitW = Fonts.mntsb.getWidth(speedLabel, FONT_SIZE);
        float speedBoxW = speedValueW + speedUnitW + 8;
        float row1Width = speedLabelW + speedBoxW + 18;

       
        float labelW = Fonts.mntsb.getWidth("X", FONT_SIZE);
        float xValueW = Fonts.mntsb.getWidth(xValue, FONT_SIZE);
        float yValueW = Fonts.mntsb.getWidth(yValue, FONT_SIZE);
        float zValueW = Fonts.mntsb.getWidth(zValue, FONT_SIZE);

        float xBoxW = labelW + xValueW + 8;
        float yBoxW = labelW + yValueW + 8;
        float zBoxW = labelW + zValueW + 8;

        float row2Width = xBoxW + yBoxW + zBoxW + 8 + 14;

        float targetWidth = Math.max(MIN_WIDTH, Math.max(row1Width, row2Width));
        float targetHeight = MIN_HEIGHT + ROW_HEIGHT * 2 + 4;

        animatedWidth = lerp(animatedWidth, targetWidth, deltaTime);
        animatedHeight = lerp(animatedHeight, targetHeight, deltaTime);

        if (Math.abs(animatedWidth - targetWidth) < 0.3f) animatedWidth = targetWidth;
        if (Math.abs(animatedHeight - targetHeight) < 0.3f) animatedHeight = targetHeight;

        setWidth((int) Math.ceil(animatedWidth));
        setHeight((int) Math.ceil(animatedHeight));

        float w = getWidth();
        float h = getHeight();

       
        Render2D.gradientRect(x, y, w, h,
                new int[]{
                        new Color(18, 18, 18, (int) (230 * alphaFactor)).getRGB(),
                        new Color(12, 12, 12, (int) (230 * alphaFactor)).getRGB(),
                        new Color(18, 18, 18, (int) (230 * alphaFactor)).getRGB(),
                        new Color(12, 12, 12, (int) (230 * alphaFactor)).getRGB()
                },
                5);

        Render2D.outline(x, y, w, h, 0.3f,
                new Color(60, 60, 60, (int) (150 * alphaFactor)).getRGB(), 5);

       
        float titleW = Fonts.mntsb.getWidth("Coords", TITLE_SIZE);
        Fonts.mntsb.draw("Coords", x + (w - titleW) / 2f, y + 7, TITLE_SIZE,
                new Color(200, 200, 200, alpha).getRGB());

        Render2D.rect(x + 6, y + MIN_HEIGHT - 4, w - 12, 0.4f,
                new Color(50, 50, 50, (int) (180 * alphaFactor)).getRGB(), 0);
        float rowY = y + MIN_HEIGHT;
        drawSpeedRow(x, rowY, w, speedLabelW, speedValue, speedValueW, speedLabel, speedUnitW, speedBoxW, alphaFactor, alpha);

        rowY += ROW_HEIGHT;
        drawCoordsRow(x, rowY, w, xValue, yValue, zValue, xBoxW, yBoxW, zBoxW, labelW, xValueW, yValueW, zValueW, alphaFactor, alpha);
    }

    private void drawSpeedRow(float x, float y, float width, float labelW, String value, float valueW,
                              String unit, float unitW, float boxW, float alphaFactor, int alpha) {
       
        float totalW = labelW + 8 + boxW;
        float startX = x + (width - totalW) / 2f;

       
        Fonts.mntsb.draw("Speed", startX, y - 0.5f, FONT_SIZE,
                new Color(190, 190, 190, alpha).getRGB());

        // Бокс справа от Speed
        float boxX = startX + labelW + 8;

        Render2D.gradientRect(boxX, y - 1.5f, boxW, 10,
                new int[]{
                        new Color(28, 28, 28, alpha).getRGB(),
                        new Color(20, 20, 20, alpha).getRGB(),
                        new Color(28, 28, 28, alpha).getRGB(),
                        new Color(20, 20, 20, alpha).getRGB()
                },
                3);

        Render2D.outline(boxX, y - 1.5f, boxW, 10, 0.25f,
                new Color(55, 55, 55, (int) (130 * alphaFactor)).getRGB(), 3);

       
        float boxContentW = valueW + 3 + unitW;
        float boxContentX = boxX + (boxW - boxContentW) / 2f;

        Fonts.mntsb.draw(value, boxContentX, y, FONT_SIZE,
                new Color(190, 190, 190, alpha).getRGB());

        Fonts.mntsb.draw(unit, boxContentX + valueW + 3, y, FONT_SIZE,
                new Color(100, 100, 100, alpha).getRGB());
    }

    private void drawCoordsRow(float x, float y, float width, String xVal, String yVal, String zVal,
                               float xBoxW, float yBoxW, float zBoxW,
                               float labelW, float xValueW, float yValueW, float zValueW,
                               float alphaFactor, int alpha) {
        float gap = 4;
        float totalW = xBoxW + gap + yBoxW + gap + zBoxW;
        float startX = x + (width - totalW) / 2f;

       
        drawCoordBox(startX, y, "X", xVal, labelW, xValueW, xBoxW, alphaFactor, alpha);
        startX += xBoxW + gap;

        // Y
        drawCoordBox(startX, y, "Y", yVal, labelW, yValueW, yBoxW, alphaFactor, alpha);
        startX += yBoxW + gap;

       
        drawCoordBox(startX, y, "Z", zVal, labelW, zValueW, zBoxW, alphaFactor, alpha);
    }

    private void drawCoordBox(float x, float y, String label, String value,
                              float labelWidth, float valueWidth, float boxWidth,
                              float alphaFactor, int alpha) {
        Render2D.gradientRect(x, y - 1.5f, boxWidth, 10,
                new int[]{
                        new Color(28, 28, 28, alpha).getRGB(),
                        new Color(20, 20, 20, alpha).getRGB(),
                        new Color(28, 28, 28, alpha).getRGB(),
                        new Color(20, 20, 20, alpha).getRGB()
                },
                3);

        Render2D.outline(x, y - 1.5f, boxWidth, 10, 0.25f,
                new Color(55, 55, 55, (int) (130 * alphaFactor)).getRGB(), 3);

       
        float contentW = labelWidth + 3 + valueWidth;
        float contentX = x + (boxWidth - contentW) / 2f;

       
        Fonts.mntsb.draw(label, contentX, y, FONT_SIZE,
                new Color(100, 100, 100, alpha).getRGB());

        Fonts.mntsb.draw(value, contentX + labelWidth + 3, y, FONT_SIZE,
                new Color(190, 190, 190, alpha).getRGB());
    }
}

KeyBinds.Java:
Expand Collapse Copy
package ARTheryx.screens.hud.wex;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ChatScreen;
import org.lwjgl.glfw.GLFW;
import ARTheryx.Initialization;
import ARTheryx.client.draggables.AbstractHudElement;
import ARTheryx.modules.impl.render.Hud;
import ARTheryx.modules.module.ModuleStructure;
import ARTheryx.util.render.Render2D;
import ARTheryx.util.render.font.Fonts;

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

public class WexHudKeyBinds extends AbstractHudElement {

    private final Random random = new Random();

    private List<ModuleStructure> keysList = new ArrayList<>();
    private long lastKeyChange = 0L;
    private String currentRandomKey = "NONE";

    private float animatedWidth = 90.0f;
    private float animatedHeight = 25.0f;
    private long lastUpdateTime = System.currentTimeMillis();

    private static final float FONT_SIZE = 6.0f;
    private static final float TITLE_SIZE = 6.5f;
    private static final float MIN_WIDTH = 90.0f;
    private static final float MIN_HEIGHT = 25.0f;
    private static final float ROW_HEIGHT = 12.0f;
    private static final float ANIMATION_SPEED = 6.0f;

    public WexHudKeyBinds() {
        super("KeyBinds", 300, 40, 90, 25, true);
        stopAnimation();
    }

    @Override
    public boolean visible() {
        Hud h = Hud.getInstance();
        return h != null && h.isState() && h.isHudPartEnabled("KeyBinds") && mc.player != null;
    }

    @Override
    public void tick() {
        if (mc.player == null) {
            keysList = new ArrayList<>();
            stopAnimation();
            return;
        }

        if (Initialization.getInstance() == null
                || Initialization.getInstance().getManager() == null
                || Initialization.getInstance().getManager().getModuleRepository() == null) {
            keysList = new ArrayList<>();
            stopAnimation();
            return;



        }

        keysList = Initialization.getInstance().getManager().getModuleRepository().allModules().stream()
                .filter(module -> module.isState() && module.getKey() != GLFW.GLFW_KEY_UNKNOWN)
                .toList();

        boolean hasActiveKeys = !keysList.isEmpty();
        boolean inChat = mc.currentScreen instanceof ChatScreen;

        if (hasActiveKeys || inChat) {
            startAnimation();
        } else {
            stopAnimation();
        }

        if (!hasActiveKeys && inChat) {
            long now = System.currentTimeMillis();
            if (now - lastKeyChange >= 1000L) {
                List<String> demoKeys = List.of("A", "B", "C", "D", "E", "R", "V");
                currentRandomKey = demoKeys.get(random.nextInt(demoKeys.size()));
                lastKeyChange = now;
            }
        }
    }

    private float lerp(float current, float target, float deltaTime) {
        float factor = (float) (1.0 - Math.pow(0.0001, deltaTime * ANIMATION_SPEED));
        return current + (target - current) * factor;
    }

    @Override
    public void drawDraggable(DrawContext context, int alpha) {
        if (mc.player == null || alpha <= 0) return;

        float x = getX();
        float y = getY();


        float alphaFactor = alpha / 255.0f;

        long now = System.currentTimeMillis();
        float deltaTime = (now - lastUpdateTime) / 1000.0f;
        lastUpdateTime = now;
        deltaTime = Math.min(deltaTime, 0.1f);

        boolean hasActiveKeys = !keysList.isEmpty();
        boolean showExample = !hasActiveKeys && mc.currentScreen instanceof ChatScreen;

        int rows = showExample ? 1 : keysList.size();
        int activeCount = showExample ? 1 : keysList.size();

        float targetWidth = MIN_WIDTH;
        if (showExample) {
            String name = "Example Module";
            String bind = currentRandomKey;
            float nameWidth = Fonts.mntsb.getWidth(name, FONT_SIZE);
            float bindWidth = Fonts.mntsb.getWidth(bind, FONT_SIZE);
            targetWidth = Math.max(targetWidth, nameWidth + bindWidth + 38.0f);
        } else {
            for (ModuleStructure module : keysList) {
                String bind = getKeyName(module.getKey());
                float nameWidth = Fonts.mntsb.getWidth(module.getName(), FONT_SIZE);
                float bindWidth = Fonts.mntsb.getWidth(bind, FONT_SIZE);
                targetWidth = Math.max(targetWidth, nameWidth + bindWidth + 38.0f);
            }
        }

        float targetHeight = MIN_HEIGHT + rows * ROW_HEIGHT + 2;

        animatedWidth = lerp(animatedWidth, targetWidth, deltaTime);
        animatedHeight = lerp(animatedHeight, targetHeight, deltaTime);

        if (Math.abs(animatedWidth - targetWidth) < 0.3f) animatedWidth = targetWidth;
        if (Math.abs(animatedHeight - targetHeight) < 0.3f) animatedHeight = targetHeight;

        setWidth((int) Math.ceil(animatedWidth));
        setHeight((int) Math.ceil(animatedHeight));




        Render2D.gradientRect(x, y, getWidth(), getHeight(),
                new int[]{
                        new Color(18, 18, 18, (int) (230 * alphaFactor)).getRGB(),
                        new Color(12, 12, 12, (int) (230 * alphaFactor)).getRGB(),
                        new Color(18, 18, 18, (int) (230 * alphaFactor)).getRGB(),
                        new Color(12, 12, 12, (int) (230 * alphaFactor)).getRGB()
                },
                5);


        Render2D.outline(x, y, getWidth(), getHeight(), 0.3f,
                new Color(60, 60, 60, (int) (150 * alphaFactor)).getRGB(), 5);


        String title = "Binds";
        Fonts.mntsb.draw(title, x + 8, y + 7, TITLE_SIZE,
                new Color(200, 200, 200, alpha).getRGB());


        String romanCount = toRoman(activeCount);
        float romanWidth = Fonts.mntsb.getWidth(romanCount, FONT_SIZE);
        float badgeX = x + getWidth() - romanWidth - 10;

        Render2D.gradientRect(badgeX - 3, y + 5, romanWidth + 6, 10,
                new int[]{
                        new Color(30, 30, 30, alpha).getRGB(),
                        new Color(22, 22, 22, alpha).getRGB(),
                        new Color(30, 30, 30, alpha).getRGB(),
                        new Color(22, 22, 22, alpha).getRGB()
                },
                4);

        Render2D.outline(badgeX - 3, y + 5, romanWidth + 6, 10, 0.3f,
                new Color(70, 70, 70, (int) (140 * alphaFactor)).getRGB(), 4);

        Fonts.mntsb.draw(romanCount, badgeX, y + 6.5f, FONT_SIZE,
                new Color(180, 180, 180, alpha).getRGB());


        Render2D.rect(x + 6, y + MIN_HEIGHT - 4, getWidth() - 12, 0.4f,
                new Color(50, 50, 50, (int) (180 * alphaFactor)).getRGB(), 0);


        float rowY = y + MIN_HEIGHT;

        if (showExample) {
            drawBindRow(x, rowY, getWidth(), "Example Module", currentRandomKey, alphaFactor, alpha);
        } else {
            for (ModuleStructure module : keysList) {
                drawBindRow(x, rowY, getWidth(), module.getName(), getKeyName(module.getKey()), alphaFactor, alpha);
                rowY += ROW_HEIGHT;
            }
        }
    }

    private void drawBindRow(float x, float y, float width, String name, String bind, float alphaFactor, int alpha) {
        float bindWidth = Fonts.mntsb.getWidth(bind, FONT_SIZE);
        float bindBoxX = x + width - bindWidth - 10.0f;


        Render2D.gradientRect(bindBoxX - 3, y - 1.5f, bindWidth + 6, 10,
                new int[]{
                        new Color(28, 28, 28, alpha).getRGB(),
                        new Color(20, 20, 20, alpha).getRGB(),
                        new Color(28, 28, 28, alpha).getRGB(),
                        new Color(20, 20, 20, alpha).getRGB()
                },
                3);

        Render2D.outline(bindBoxX - 3, y - 1.5f, bindWidth + 6, 10, 0.25f,
                new Color(55, 55, 55, (int) (130 * alphaFactor)).getRGB(), 3);


        Render2D.rect(x + 7, y, 1.0f, 7.0f,
                new Color(130, 130, 130, (int) (200 * alphaFactor)).getRGB(), 1);


        Fonts.mntsb.draw(name, x + 12, y - 0.5f, FONT_SIZE,
                new Color(190, 190, 190, alpha).getRGB());


        Fonts.mntsb.draw(bind, bindBoxX, y, FONT_SIZE,
                new Color(140, 140, 140, alpha).getRGB());
    }


    private String toRoman(int number) {
        if (number <= 0) return "0";
        if (number > 3999) return String.valueOf(number);

        String[] thousands = {"", "M", "MM", "MMM"};
        String[] hundreds = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};
        String[] tens = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};
        String[] ones = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};

        return thousands[number / 1000]
                + hundreds[(number % 1000) / 100]
                + tens[(number % 100) / 10]
                + ones[number % 10];
    }

    private String getKeyName(int key) {
        return switch (key) {
            case GLFW.GLFW_KEY_UNKNOWN -> "NONE";
            case GLFW.GLFW_KEY_SPACE -> "SPACE";
            case GLFW.GLFW_KEY_ENTER -> "ENTER";
            case GLFW.GLFW_KEY_TAB -> "TAB";
            case GLFW.GLFW_KEY_BACKSPACE -> "BACK";
            case GLFW.GLFW_KEY_DELETE -> "DEL";
            case GLFW.GLFW_KEY_INSERT -> "INS";
            case GLFW.GLFW_KEY_HOME -> "HOME";
            case GLFW.GLFW_KEY_END -> "END";
            case GLFW.GLFW_KEY_PAGE_UP -> "PGUP";
            case GLFW.GLFW_KEY_PAGE_DOWN -> "PGDN";
            case GLFW.GLFW_KEY_LEFT_SHIFT, GLFW.GLFW_KEY_RIGHT_SHIFT -> "SHIFT";
            case GLFW.GLFW_KEY_LEFT_CONTROL, GLFW.GLFW_KEY_RIGHT_CONTROL -> "CTRL";
            case GLFW.GLFW_KEY_LEFT_ALT, GLFW.GLFW_KEY_RIGHT_ALT -> "ALT";
            case GLFW.GLFW_KEY_ESCAPE -> "ESC";
            case GLFW.GLFW_KEY_UP -> "UP";
            case GLFW.GLFW_KEY_DOWN -> "DOWN";
            case GLFW.GLFW_KEY_LEFT -> "LEFT";
            case GLFW.GLFW_KEY_RIGHT -> "RIGHT";
            default -> {
                if (key >= GLFW.GLFW_KEY_F1 && key <= GLFW.GLFW_KEY_F12) {
                    yield "F" + (key - GLFW.GLFW_KEY_F1 + 1);
                } else if (key >= GLFW.GLFW_KEY_A && key <= GLFW.GLFW_KEY_Z) {
                    yield String.valueOf((char) (key - GLFW.GLFW_KEY_A + 'A'));
                } else if (key >= GLFW.GLFW_KEY_0 && key <= GLFW.GLFW_KEY_9) {
                    yield String.valueOf((char) (key - GLFW.GLFW_KEY_0 + '0'));
                } else if (key >= GLFW.GLFW_KEY_KP_0 && key <= GLFW.GLFW_KEY_KP_9) {
                    yield "NUM" + (key - GLFW.GLFW_KEY_KP_0);
                } else {
                    yield "KEY" + key;
                }
            }
        };
    }
}
Мб кому то надо как так что кому то не понятно как конвертировать лотинские в римские
 
Последнее редактирование:
Пожалуйста, авторизуйтесь для просмотра ссылки.



WexHudCoords.java:
Expand Collapse Copy
package ARTheryx.screens.hud.wex;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.util.math.Vec3d;
import ARTheryx.client.draggables.AbstractHudElement;
import ARTheryx.modules.impl.render.Hud;
import ARTheryx.util.render.Render2D;
import ARTheryx.util.render.font.Fonts;

import java.awt.*;

public class WexHudCoords extends AbstractHudElement {

    private static final float FONT_SIZE = 6.0f;
    private static final float TITLE_SIZE = 6.5f;
    private static final float MIN_WIDTH = 110.0f;
    private static final float MIN_HEIGHT = 25.0f;
    private static final float ROW_HEIGHT = 12.0f;
    private static final float ANIMATION_SPEED = 6.0f;

    private float animatedWidth = MIN_WIDTH;
    private float animatedHeight = MIN_HEIGHT;
    private long lastUpdateTime = System.currentTimeMillis();

    public WexHudCoords() {
        super("Coords", 2, 100, 110, 25, true);
        stopAnimation();
    }

    @Override
    public boolean visible() {
        Hud h = Hud.getInstance();
        return h != null && h.isState() && h.isHudPartEnabled("Coords") && mc.player != null;
    }

    @Override
    public void tick() {
        if (mc.player == null) {
            stopAnimation();
            return;
        }
        startAnimation();
    }

    private float lerp(float current, float target, float deltaTime) {
        float factor = (float) (1.0 - Math.pow(0.0001, deltaTime * ANIMATION_SPEED));
        return current + (target - current) * factor;
    }

    @Override
    public void drawDraggable(DrawContext context, int alpha) {
        if (mc.player == null || alpha <= 0) return;

        float x = getX();
        float y = getY();
        float alphaFactor = alpha / 255.0f;

        long now = System.currentTimeMillis();
        float deltaTime = (now - lastUpdateTime) / 1000.0f;
        lastUpdateTime = now;
        deltaTime = Math.min(deltaTime, 0.1f);

      
        Vec3d vel = mc.player.getVelocity();
        double speed = Math.hypot(vel.x, vel.z) * 20.0;
        var pos = mc.player.getBlockPos();

        String speedValue = String.format("%.1f", speed);
        String speedLabel = "b/s";

        String xValue = String.valueOf(pos.getX());
        String yValue = String.valueOf(pos.getY());
        String zValue = String.valueOf(pos.getZ());


        float speedLabelW = Fonts.mntsb.getWidth("Speed", FONT_SIZE);
        float speedValueW = Fonts.mntsb.getWidth(speedValue, FONT_SIZE);
        float speedUnitW = Fonts.mntsb.getWidth(speedLabel, FONT_SIZE);
        float speedBoxW = speedValueW + speedUnitW + 8;
        float row1Width = speedLabelW + speedBoxW + 18;

      
        float labelW = Fonts.mntsb.getWidth("X", FONT_SIZE);
        float xValueW = Fonts.mntsb.getWidth(xValue, FONT_SIZE);
        float yValueW = Fonts.mntsb.getWidth(yValue, FONT_SIZE);
        float zValueW = Fonts.mntsb.getWidth(zValue, FONT_SIZE);

        float xBoxW = labelW + xValueW + 8;
        float yBoxW = labelW + yValueW + 8;
        float zBoxW = labelW + zValueW + 8;

        float row2Width = xBoxW + yBoxW + zBoxW + 8 + 14;

        float targetWidth = Math.max(MIN_WIDTH, Math.max(row1Width, row2Width));
        float targetHeight = MIN_HEIGHT + ROW_HEIGHT * 2 + 4;

        animatedWidth = lerp(animatedWidth, targetWidth, deltaTime);
        animatedHeight = lerp(animatedHeight, targetHeight, deltaTime);

        if (Math.abs(animatedWidth - targetWidth) < 0.3f) animatedWidth = targetWidth;
        if (Math.abs(animatedHeight - targetHeight) < 0.3f) animatedHeight = targetHeight;

        setWidth((int) Math.ceil(animatedWidth));
        setHeight((int) Math.ceil(animatedHeight));

        float w = getWidth();
        float h = getHeight();

      
        Render2D.gradientRect(x, y, w, h,
                new int[]{
                        new Color(18, 18, 18, (int) (230 * alphaFactor)).getRGB(),
                        new Color(12, 12, 12, (int) (230 * alphaFactor)).getRGB(),
                        new Color(18, 18, 18, (int) (230 * alphaFactor)).getRGB(),
                        new Color(12, 12, 12, (int) (230 * alphaFactor)).getRGB()
                },
                5);

        Render2D.outline(x, y, w, h, 0.3f,
                new Color(60, 60, 60, (int) (150 * alphaFactor)).getRGB(), 5);

      
        float titleW = Fonts.mntsb.getWidth("Coords", TITLE_SIZE);
        Fonts.mntsb.draw("Coords", x + (w - titleW) / 2f, y + 7, TITLE_SIZE,
                new Color(200, 200, 200, alpha).getRGB());

        Render2D.rect(x + 6, y + MIN_HEIGHT - 4, w - 12, 0.4f,
                new Color(50, 50, 50, (int) (180 * alphaFactor)).getRGB(), 0);
        float rowY = y + MIN_HEIGHT;
        drawSpeedRow(x, rowY, w, speedLabelW, speedValue, speedValueW, speedLabel, speedUnitW, speedBoxW, alphaFactor, alpha);

        rowY += ROW_HEIGHT;
        drawCoordsRow(x, rowY, w, xValue, yValue, zValue, xBoxW, yBoxW, zBoxW, labelW, xValueW, yValueW, zValueW, alphaFactor, alpha);
    }

    private void drawSpeedRow(float x, float y, float width, float labelW, String value, float valueW,
                              String unit, float unitW, float boxW, float alphaFactor, int alpha) {
      
        float totalW = labelW + 8 + boxW;
        float startX = x + (width - totalW) / 2f;

      
        Fonts.mntsb.draw("Speed", startX, y - 0.5f, FONT_SIZE,
                new Color(190, 190, 190, alpha).getRGB());

        // Бокс справа от Speed
        float boxX = startX + labelW + 8;

        Render2D.gradientRect(boxX, y - 1.5f, boxW, 10,
                new int[]{
                        new Color(28, 28, 28, alpha).getRGB(),
                        new Color(20, 20, 20, alpha).getRGB(),
                        new Color(28, 28, 28, alpha).getRGB(),
                        new Color(20, 20, 20, alpha).getRGB()
                },
                3);

        Render2D.outline(boxX, y - 1.5f, boxW, 10, 0.25f,
                new Color(55, 55, 55, (int) (130 * alphaFactor)).getRGB(), 3);

      
        float boxContentW = valueW + 3 + unitW;
        float boxContentX = boxX + (boxW - boxContentW) / 2f;

        Fonts.mntsb.draw(value, boxContentX, y, FONT_SIZE,
                new Color(190, 190, 190, alpha).getRGB());

        Fonts.mntsb.draw(unit, boxContentX + valueW + 3, y, FONT_SIZE,
                new Color(100, 100, 100, alpha).getRGB());
    }

    private void drawCoordsRow(float x, float y, float width, String xVal, String yVal, String zVal,
                               float xBoxW, float yBoxW, float zBoxW,
                               float labelW, float xValueW, float yValueW, float zValueW,
                               float alphaFactor, int alpha) {
        float gap = 4;
        float totalW = xBoxW + gap + yBoxW + gap + zBoxW;
        float startX = x + (width - totalW) / 2f;

      
        drawCoordBox(startX, y, "X", xVal, labelW, xValueW, xBoxW, alphaFactor, alpha);
        startX += xBoxW + gap;

        // Y
        drawCoordBox(startX, y, "Y", yVal, labelW, yValueW, yBoxW, alphaFactor, alpha);
        startX += yBoxW + gap;

      
        drawCoordBox(startX, y, "Z", zVal, labelW, zValueW, zBoxW, alphaFactor, alpha);
    }

    private void drawCoordBox(float x, float y, String label, String value,
                              float labelWidth, float valueWidth, float boxWidth,
                              float alphaFactor, int alpha) {
        Render2D.gradientRect(x, y - 1.5f, boxWidth, 10,
                new int[]{
                        new Color(28, 28, 28, alpha).getRGB(),
                        new Color(20, 20, 20, alpha).getRGB(),
                        new Color(28, 28, 28, alpha).getRGB(),
                        new Color(20, 20, 20, alpha).getRGB()
                },
                3);

        Render2D.outline(x, y - 1.5f, boxWidth, 10, 0.25f,
                new Color(55, 55, 55, (int) (130 * alphaFactor)).getRGB(), 3);

      
        float contentW = labelWidth + 3 + valueWidth;
        float contentX = x + (boxWidth - contentW) / 2f;

      
        Fonts.mntsb.draw(label, contentX, y, FONT_SIZE,
                new Color(100, 100, 100, alpha).getRGB());

        Fonts.mntsb.draw(value, contentX + labelWidth + 3, y, FONT_SIZE,
                new Color(190, 190, 190, alpha).getRGB());
    }
}

KeyBinds.Java:
Expand Collapse Copy
package ARTheryx.screens.hud.wex;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ChatScreen;
import org.lwjgl.glfw.GLFW;
import ARTheryx.Initialization;
import ARTheryx.client.draggables.AbstractHudElement;
import ARTheryx.modules.impl.render.Hud;
import ARTheryx.modules.module.ModuleStructure;
import ARTheryx.util.render.Render2D;
import ARTheryx.util.render.font.Fonts;

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

public class WexHudKeyBinds extends AbstractHudElement {

    private final Random random = new Random();

    private List<ModuleStructure> keysList = new ArrayList<>();
    private long lastKeyChange = 0L;
    private String currentRandomKey = "NONE";

    private float animatedWidth = 90.0f;
    private float animatedHeight = 25.0f;
    private long lastUpdateTime = System.currentTimeMillis();

    private static final float FONT_SIZE = 6.0f;
    private static final float TITLE_SIZE = 6.5f;
    private static final float MIN_WIDTH = 90.0f;
    private static final float MIN_HEIGHT = 25.0f;
    private static final float ROW_HEIGHT = 12.0f;
    private static final float ANIMATION_SPEED = 6.0f;

    public WexHudKeyBinds() {
        super("KeyBinds", 300, 40, 90, 25, true);
        stopAnimation();
    }

    @Override
    public boolean visible() {
        Hud h = Hud.getInstance();
        return h != null && h.isState() && h.isHudPartEnabled("KeyBinds") && mc.player != null;
    }

    @Override
    public void tick() {
        if (mc.player == null) {
            keysList = new ArrayList<>();
            stopAnimation();
            return;
        }

        if (Initialization.getInstance() == null
                || Initialization.getInstance().getManager() == null
                || Initialization.getInstance().getManager().getModuleRepository() == null) {
            keysList = new ArrayList<>();
            stopAnimation();
            return;



        }

        keysList = Initialization.getInstance().getManager().getModuleRepository().allModules().stream()
                .filter(module -> module.isState() && module.getKey() != GLFW.GLFW_KEY_UNKNOWN)
                .toList();

        boolean hasActiveKeys = !keysList.isEmpty();
        boolean inChat = mc.currentScreen instanceof ChatScreen;

        if (hasActiveKeys || inChat) {
            startAnimation();
        } else {
            stopAnimation();
        }

        if (!hasActiveKeys && inChat) {
            long now = System.currentTimeMillis();
            if (now - lastKeyChange >= 1000L) {
                List<String> demoKeys = List.of("A", "B", "C", "D", "E", "R", "V");
                currentRandomKey = demoKeys.get(random.nextInt(demoKeys.size()));
                lastKeyChange = now;
            }
        }
    }

    private float lerp(float current, float target, float deltaTime) {
        float factor = (float) (1.0 - Math.pow(0.0001, deltaTime * ANIMATION_SPEED));
        return current + (target - current) * factor;
    }

    @Override
    public void drawDraggable(DrawContext context, int alpha) {
        if (mc.player == null || alpha <= 0) return;

        float x = getX();
        float y = getY();


        float alphaFactor = alpha / 255.0f;

        long now = System.currentTimeMillis();
        float deltaTime = (now - lastUpdateTime) / 1000.0f;
        lastUpdateTime = now;
        deltaTime = Math.min(deltaTime, 0.1f);

        boolean hasActiveKeys = !keysList.isEmpty();
        boolean showExample = !hasActiveKeys && mc.currentScreen instanceof ChatScreen;

        int rows = showExample ? 1 : keysList.size();
        int activeCount = showExample ? 1 : keysList.size();

        float targetWidth = MIN_WIDTH;
        if (showExample) {
            String name = "Example Module";
            String bind = currentRandomKey;
            float nameWidth = Fonts.mntsb.getWidth(name, FONT_SIZE);
            float bindWidth = Fonts.mntsb.getWidth(bind, FONT_SIZE);
            targetWidth = Math.max(targetWidth, nameWidth + bindWidth + 38.0f);
        } else {
            for (ModuleStructure module : keysList) {
                String bind = getKeyName(module.getKey());
                float nameWidth = Fonts.mntsb.getWidth(module.getName(), FONT_SIZE);
                float bindWidth = Fonts.mntsb.getWidth(bind, FONT_SIZE);
                targetWidth = Math.max(targetWidth, nameWidth + bindWidth + 38.0f);
            }
        }

        float targetHeight = MIN_HEIGHT + rows * ROW_HEIGHT + 2;

        animatedWidth = lerp(animatedWidth, targetWidth, deltaTime);
        animatedHeight = lerp(animatedHeight, targetHeight, deltaTime);

        if (Math.abs(animatedWidth - targetWidth) < 0.3f) animatedWidth = targetWidth;
        if (Math.abs(animatedHeight - targetHeight) < 0.3f) animatedHeight = targetHeight;

        setWidth((int) Math.ceil(animatedWidth));
        setHeight((int) Math.ceil(animatedHeight));




        Render2D.gradientRect(x, y, getWidth(), getHeight(),
                new int[]{
                        new Color(18, 18, 18, (int) (230 * alphaFactor)).getRGB(),
                        new Color(12, 12, 12, (int) (230 * alphaFactor)).getRGB(),
                        new Color(18, 18, 18, (int) (230 * alphaFactor)).getRGB(),
                        new Color(12, 12, 12, (int) (230 * alphaFactor)).getRGB()
                },
                5);


        Render2D.outline(x, y, getWidth(), getHeight(), 0.3f,
                new Color(60, 60, 60, (int) (150 * alphaFactor)).getRGB(), 5);


        String title = "Binds";
        Fonts.mntsb.draw(title, x + 8, y + 7, TITLE_SIZE,
                new Color(200, 200, 200, alpha).getRGB());


        String romanCount = toRoman(activeCount);
        float romanWidth = Fonts.mntsb.getWidth(romanCount, FONT_SIZE);
        float badgeX = x + getWidth() - romanWidth - 10;

        Render2D.gradientRect(badgeX - 3, y + 5, romanWidth + 6, 10,
                new int[]{
                        new Color(30, 30, 30, alpha).getRGB(),
                        new Color(22, 22, 22, alpha).getRGB(),
                        new Color(30, 30, 30, alpha).getRGB(),
                        new Color(22, 22, 22, alpha).getRGB()
                },
                4);

        Render2D.outline(badgeX - 3, y + 5, romanWidth + 6, 10, 0.3f,
                new Color(70, 70, 70, (int) (140 * alphaFactor)).getRGB(), 4);

        Fonts.mntsb.draw(romanCount, badgeX, y + 6.5f, FONT_SIZE,
                new Color(180, 180, 180, alpha).getRGB());


        Render2D.rect(x + 6, y + MIN_HEIGHT - 4, getWidth() - 12, 0.4f,
                new Color(50, 50, 50, (int) (180 * alphaFactor)).getRGB(), 0);


        float rowY = y + MIN_HEIGHT;

        if (showExample) {
            drawBindRow(x, rowY, getWidth(), "Example Module", currentRandomKey, alphaFactor, alpha);
        } else {
            for (ModuleStructure module : keysList) {
                drawBindRow(x, rowY, getWidth(), module.getName(), getKeyName(module.getKey()), alphaFactor, alpha);
                rowY += ROW_HEIGHT;
            }
        }
    }

    private void drawBindRow(float x, float y, float width, String name, String bind, float alphaFactor, int alpha) {
        float bindWidth = Fonts.mntsb.getWidth(bind, FONT_SIZE);
        float bindBoxX = x + width - bindWidth - 10.0f;


        Render2D.gradientRect(bindBoxX - 3, y - 1.5f, bindWidth + 6, 10,
                new int[]{
                        new Color(28, 28, 28, alpha).getRGB(),
                        new Color(20, 20, 20, alpha).getRGB(),
                        new Color(28, 28, 28, alpha).getRGB(),
                        new Color(20, 20, 20, alpha).getRGB()
                },
                3);

        Render2D.outline(bindBoxX - 3, y - 1.5f, bindWidth + 6, 10, 0.25f,
                new Color(55, 55, 55, (int) (130 * alphaFactor)).getRGB(), 3);


        Render2D.rect(x + 7, y, 1.0f, 7.0f,
                new Color(130, 130, 130, (int) (200 * alphaFactor)).getRGB(), 1);


        Fonts.mntsb.draw(name, x + 12, y - 0.5f, FONT_SIZE,
                new Color(190, 190, 190, alpha).getRGB());


        Fonts.mntsb.draw(bind, bindBoxX, y, FONT_SIZE,
                new Color(140, 140, 140, alpha).getRGB());
    }


    private String toRoman(int number) {
        if (number <= 0) return "0";
        if (number > 3999) return String.valueOf(number);

        String[] thousands = {"", "M", "MM", "MMM"};
        String[] hundreds = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"};
        String[] tens = {"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"};
        String[] ones = {"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"};

        return thousands[number / 1000]
                + hundreds[(number % 1000) / 100]
                + tens[(number % 100) / 10]
                + ones[number % 10];
    }

    private String getKeyName(int key) {
        return switch (key) {
            case GLFW.GLFW_KEY_UNKNOWN -> "NONE";
            case GLFW.GLFW_KEY_SPACE -> "SPACE";
            case GLFW.GLFW_KEY_ENTER -> "ENTER";
            case GLFW.GLFW_KEY_TAB -> "TAB";
            case GLFW.GLFW_KEY_BACKSPACE -> "BACK";
            case GLFW.GLFW_KEY_DELETE -> "DEL";
            case GLFW.GLFW_KEY_INSERT -> "INS";
            case GLFW.GLFW_KEY_HOME -> "HOME";
            case GLFW.GLFW_KEY_END -> "END";
            case GLFW.GLFW_KEY_PAGE_UP -> "PGUP";
            case GLFW.GLFW_KEY_PAGE_DOWN -> "PGDN";
            case GLFW.GLFW_KEY_LEFT_SHIFT, GLFW.GLFW_KEY_RIGHT_SHIFT -> "SHIFT";
            case GLFW.GLFW_KEY_LEFT_CONTROL, GLFW.GLFW_KEY_RIGHT_CONTROL -> "CTRL";
            case GLFW.GLFW_KEY_LEFT_ALT, GLFW.GLFW_KEY_RIGHT_ALT -> "ALT";
            case GLFW.GLFW_KEY_ESCAPE -> "ESC";
            case GLFW.GLFW_KEY_UP -> "UP";
            case GLFW.GLFW_KEY_DOWN -> "DOWN";
            case GLFW.GLFW_KEY_LEFT -> "LEFT";
            case GLFW.GLFW_KEY_RIGHT -> "RIGHT";
            default -> {
                if (key >= GLFW.GLFW_KEY_F1 && key <= GLFW.GLFW_KEY_F12) {
                    yield "F" + (key - GLFW.GLFW_KEY_F1 + 1);
                } else if (key >= GLFW.GLFW_KEY_A && key <= GLFW.GLFW_KEY_Z) {
                    yield String.valueOf((char) (key - GLFW.GLFW_KEY_A + 'A'));
                } else if (key >= GLFW.GLFW_KEY_0 && key <= GLFW.GLFW_KEY_9) {
                    yield String.valueOf((char) (key - GLFW.GLFW_KEY_0 + '0'));
                } else if (key >= GLFW.GLFW_KEY_KP_0 && key <= GLFW.GLFW_KEY_KP_9) {
                    yield "NUM" + (key - GLFW.GLFW_KEY_KP_0);
                } else {
                    yield "KEY" + key;
                }
            }
        };
    }
}
Мб кому то надо как так что кому то не понятно как конвертировать лотинские в римские
это прям плохо..
 
Назад
Сверху Снизу