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

Визуальная часть ServerHelperHUD | Rich 1.21.11 fabric

  • Автор темы Автор темы Ded_xB
  • Дата начала Дата начала
Начинающий
Начинающий
Статус
Онлайн
Регистрация
26 Дек 2024
Сообщения
80
Реакции
0
Выберите загрузчик игры
  1. Fabric
1771506694111.png

Сделал ServerHelperHUD криво, но все же хотя бы работает. Если надо, сами дорабатывайте, фонс сами найдете.

ServerHelperHUD.java:
Expand Collapse Copy
package rich.screens.hud;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.item.ItemStack;
import org.lwjgl.glfw.GLFW;
import rich.Initialization;
import rich.client.draggables.AbstractHudElement;
import rich.modules.impl.misc.ServerHelper;
import rich.modules.impl.render.Hud;
import rich.util.ColorUtil;
import rich.util.render.Render2D;
import rich.util.render.font.Fonts;
import rich.util.render.item.ItemRender;

import java.awt.*;

public class ServerHelperHUD extends AbstractHudElement {

    public ServerHelperHUD() {
        super("ServerHelper", 200, 200, 18, 18, true);
    }

    @Override
    public void drawDraggable(DrawContext context, int alpha) {
        if (!Hud.getInstance().interfaceSettings.isSelected("ServerHelper")) return;

        ServerHelper serverHelper = Initialization.getInstance().getManager().getModuleProvider().get(ServerHelper.class);
        if (serverHelper == null || !serverHelper.isState() || mc.player == null) return;

        float startX = getX();
        float y = getY();
        float x = startX;
        float spacing = 6;
        float size = 18;

        for (ServerHelper.KeyBind bind : serverHelper.getKeyBindings()) {
            if (bind.setting().getKey() <= 0 || !bind.setting().getVisible().get() || !hasCustomItem(bind)) {
                continue;
            }

            Render2D.rect(x, y, size, size, ColorUtil.getColor(15, 15, 15, (int)(alpha * 0.8f)), 4);

            String keyName = getEnglishKeyName(bind.setting().getKey());
            float fontSize = 6f;
            float textWidth = Fonts.SFPRO_REGULAR.getWidth(keyName, fontSize);
            float rectW = Math.max(8, textWidth + 3);
            float rectH = 6.5f;
            float rectX = x + size - rectW + 1.5f;
            float rectY = y + size - rectH + 0.5f;

            Render2D.rect(rectX, rectY, rectW, rectH, ColorUtil.getColor(200, 30, 30, (int)(alpha * 0.7f)), 2);

            ItemStack stack = new ItemStack(bind.item());
            float itemScale = 0.65f;
            if (ItemRender.needsContextRender(stack)) {
                ItemRender.drawItemCenteredWithContext(context, stack, x + size / 2f, y + size / 2f - 1.2f, itemScale, alpha / 255f);
            } else {
                ItemRender.drawItemCentered(stack, x + size / 2f, y + size / 2f - 1.2f, itemScale, alpha / 255f);
            }

            x += size + spacing;
        }

        x = startX;
        for (ServerHelper.KeyBind bind : serverHelper.getKeyBindings()) {
            if (bind.setting().getKey() <= 0 || !bind.setting().getVisible().get() || !hasCustomItem(bind)) {
                continue;
            }

            String keyName = getEnglishKeyName(bind.setting().getKey());
            float fontSize = 5.5f;
            float textWidth = Fonts.SFPRO_REGULAR.getWidth(keyName, fontSize);

            float rectW = Math.max(8, textWidth + 3);
            float rectH = 6.5f;
            float rectX = x + size - rectW + 1.5f;
            float rectY = y + size - rectH + 0.5f;

            int textColor = ColorUtil.getColor(255, 255, 255, (int)(alpha * 0.8f));
            Fonts.SFPRO_REGULAR.draw(keyName, rectX + (rectW / 2f) - (textWidth / 2f), rectY + 0.8f, fontSize, textColor);

            x += size + spacing;
        }

        setWidth((int) (x - getX()));
        setHeight((int) size);
    }

    private String getEnglishKeyName(int key) {
        if (key >= GLFW.GLFW_MOUSE_BUTTON_1 && key <= GLFW.GLFW_MOUSE_BUTTON_8) {
            return "M" + (key + 1);
        }
        return switch (key) {
            case GLFW.GLFW_KEY_A -> "A"; case GLFW.GLFW_KEY_B -> "B"; case GLFW.GLFW_KEY_C -> "C";
            case GLFW.GLFW_KEY_D -> "D"; case GLFW.GLFW_KEY_E -> "E"; case GLFW.GLFW_KEY_F -> "F";
            case GLFW.GLFW_KEY_G -> "G"; case GLFW.GLFW_KEY_H -> "H"; case GLFW.GLFW_KEY_I -> "I";
            case GLFW.GLFW_KEY_J -> "J"; case GLFW.GLFW_KEY_K -> "K"; case GLFW.GLFW_KEY_L -> "L";
            case GLFW.GLFW_KEY_M -> "M"; case GLFW.GLFW_KEY_N -> "N"; case GLFW.GLFW_KEY_O -> "O";
            case GLFW.GLFW_KEY_P -> "P"; case GLFW.GLFW_KEY_Q -> "Q"; case GLFW.GLFW_KEY_R -> "R";
            case GLFW.GLFW_KEY_S -> "S"; case GLFW.GLFW_KEY_T -> "T"; case GLFW.GLFW_KEY_U -> "U";
            case GLFW.GLFW_KEY_V -> "V"; case GLFW.GLFW_KEY_W -> "W"; case GLFW.GLFW_KEY_X -> "X";
            case GLFW.GLFW_KEY_Y -> "Y"; case GLFW.GLFW_KEY_Z -> "Z";
            case GLFW.GLFW_KEY_LEFT_SHIFT -> "LS"; case GLFW.GLFW_KEY_TAB -> "TAB";
            case GLFW.GLFW_KEY_SPACE -> "SPC";
            default -> {
                String name = GLFW.glfwGetKeyName(key, 0);
                yield (name != null ? name.toUpperCase() : "B" + key);
            }
        };
    }

    private boolean hasCustomItem(ServerHelper.KeyBind bind) {
        if (mc.player == null) return false;
        String targetName = bind.setting().getName();
        for (int i = 0; i < mc.player.getInventory().size(); i++) {
            ItemStack stack = mc.player.getInventory().getStack(i);
            if (!stack.isEmpty() && stack.getItem() == bind.item()) {
                if (!stack.getComponents().contains(DataComponentTypes.CUSTOM_NAME)) return true;
                if (stack.getName().getString().contains(targetName)) return true;
            }
        }
        ItemStack offhand = mc.player.getOffHandStack();
        if (offhand.getItem() == bind.item()) {
            if (!offhand.getComponents().contains(DataComponentTypes.CUSTOM_NAME) || offhand.getName().getString().contains(targetName)) return true;
        }
        return false;
    }

    @Override
    public boolean visible() {
        return Hud.getInstance().interfaceSettings.isSelected(getName());
    }
}
 
return switch (key) { case GLFW.GLFW_KEY_A -> "A"; case GLFW.GLFW_KEY_B -> "B"; case GLFW.GLFW_KEY_C -> "C"; case GLFW.GLFW_KEY_D -> "D"; case GLFW.GLFW_KEY_E -> "E"; case GLFW.GLFW_KEY_F -> "F"; case GLFW.GLFW_KEY_G -> "G"; case GLFW.GLFW_KEY_H -> "H"; case GLFW.GLFW_KEY_I -> "I"; case GLFW.GLFW_KEY_J -> "J"; case GLFW.GLFW_KEY_K -> "K"; case GLFW.GLFW_KEY_L -> "L"; case GLFW.GLFW_KEY_M -> "M"; case GLFW.GLFW_KEY_N -> "N"; case GLFW.GLFW_KEY_O -> "O"; case GLFW.GLFW_KEY_P -> "P"; case GLFW.GLFW_KEY_Q -> "Q"; case GLFW.GLFW_KEY_R -> "R"; case GLFW.GLFW_KEY_S -> "S"; case GLFW.GLFW_KEY_T -> "T"; case GLFW.GLFW_KEY_U -> "U"; case GLFW.GLFW_KEY_V -> "V"; case GLFW.GLFW_KEY_W -> "W"; case GLFW.GLFW_KEY_X -> "X"; case GLFW.GLFW_KEY_Y -> "Y"; case GLFW.GLFW_KEY_Z -> "Z"; case GLFW.GLFW_KEY_LEFT_SHIFT -> "LS"; case GLFW.GLFW_KEY_TAB -> "TAB"; case GLFW.GLFW_KEY_SPACE -> "SPC";
ahahhahaha
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Посмотреть вложение 328098
Сделал ServerHelperHUD криво, но все же хотя бы работает. Если надо, сами дорабатывайте, фонс сами найдете.

ServerHelperHUD.java:
Expand Collapse Copy
package rich.screens.hud;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.item.ItemStack;
import org.lwjgl.glfw.GLFW;
import rich.Initialization;
import rich.client.draggables.AbstractHudElement;
import rich.modules.impl.misc.ServerHelper;
import rich.modules.impl.render.Hud;
import rich.util.ColorUtil;
import rich.util.render.Render2D;
import rich.util.render.font.Fonts;
import rich.util.render.item.ItemRender;

import java.awt.*;

public class ServerHelperHUD extends AbstractHudElement {

    public ServerHelperHUD() {
        super("ServerHelper", 200, 200, 18, 18, true);
    }

    @Override
    public void drawDraggable(DrawContext context, int alpha) {
        if (!Hud.getInstance().interfaceSettings.isSelected("ServerHelper")) return;

        ServerHelper serverHelper = Initialization.getInstance().getManager().getModuleProvider().get(ServerHelper.class);
        if (serverHelper == null || !serverHelper.isState() || mc.player == null) return;

        float startX = getX();
        float y = getY();
        float x = startX;
        float spacing = 6;
        float size = 18;

        for (ServerHelper.KeyBind bind : serverHelper.getKeyBindings()) {
            if (bind.setting().getKey() <= 0 || !bind.setting().getVisible().get() || !hasCustomItem(bind)) {
                continue;
            }

            Render2D.rect(x, y, size, size, ColorUtil.getColor(15, 15, 15, (int)(alpha * 0.8f)), 4);

            String keyName = getEnglishKeyName(bind.setting().getKey());
            float fontSize = 6f;
            float textWidth = Fonts.SFPRO_REGULAR.getWidth(keyName, fontSize);
            float rectW = Math.max(8, textWidth + 3);
            float rectH = 6.5f;
            float rectX = x + size - rectW + 1.5f;
            float rectY = y + size - rectH + 0.5f;

            Render2D.rect(rectX, rectY, rectW, rectH, ColorUtil.getColor(200, 30, 30, (int)(alpha * 0.7f)), 2);

            ItemStack stack = new ItemStack(bind.item());
            float itemScale = 0.65f;
            if (ItemRender.needsContextRender(stack)) {
                ItemRender.drawItemCenteredWithContext(context, stack, x + size / 2f, y + size / 2f - 1.2f, itemScale, alpha / 255f);
            } else {
                ItemRender.drawItemCentered(stack, x + size / 2f, y + size / 2f - 1.2f, itemScale, alpha / 255f);
            }

            x += size + spacing;
        }

        x = startX;
        for (ServerHelper.KeyBind bind : serverHelper.getKeyBindings()) {
            if (bind.setting().getKey() <= 0 || !bind.setting().getVisible().get() || !hasCustomItem(bind)) {
                continue;
            }

            String keyName = getEnglishKeyName(bind.setting().getKey());
            float fontSize = 5.5f;
            float textWidth = Fonts.SFPRO_REGULAR.getWidth(keyName, fontSize);

            float rectW = Math.max(8, textWidth + 3);
            float rectH = 6.5f;
            float rectX = x + size - rectW + 1.5f;
            float rectY = y + size - rectH + 0.5f;

            int textColor = ColorUtil.getColor(255, 255, 255, (int)(alpha * 0.8f));
            Fonts.SFPRO_REGULAR.draw(keyName, rectX + (rectW / 2f) - (textWidth / 2f), rectY + 0.8f, fontSize, textColor);

            x += size + spacing;
        }

        setWidth((int) (x - getX()));
        setHeight((int) size);
    }

    private String getEnglishKeyName(int key) {
        if (key >= GLFW.GLFW_MOUSE_BUTTON_1 && key <= GLFW.GLFW_MOUSE_BUTTON_8) {
            return "M" + (key + 1);
        }
        return switch (key) {
            case GLFW.GLFW_KEY_A -> "A"; case GLFW.GLFW_KEY_B -> "B"; case GLFW.GLFW_KEY_C -> "C";
            case GLFW.GLFW_KEY_D -> "D"; case GLFW.GLFW_KEY_E -> "E"; case GLFW.GLFW_KEY_F -> "F";
            case GLFW.GLFW_KEY_G -> "G"; case GLFW.GLFW_KEY_H -> "H"; case GLFW.GLFW_KEY_I -> "I";
            case GLFW.GLFW_KEY_J -> "J"; case GLFW.GLFW_KEY_K -> "K"; case GLFW.GLFW_KEY_L -> "L";
            case GLFW.GLFW_KEY_M -> "M"; case GLFW.GLFW_KEY_N -> "N"; case GLFW.GLFW_KEY_O -> "O";
            case GLFW.GLFW_KEY_P -> "P"; case GLFW.GLFW_KEY_Q -> "Q"; case GLFW.GLFW_KEY_R -> "R";
            case GLFW.GLFW_KEY_S -> "S"; case GLFW.GLFW_KEY_T -> "T"; case GLFW.GLFW_KEY_U -> "U";
            case GLFW.GLFW_KEY_V -> "V"; case GLFW.GLFW_KEY_W -> "W"; case GLFW.GLFW_KEY_X -> "X";
            case GLFW.GLFW_KEY_Y -> "Y"; case GLFW.GLFW_KEY_Z -> "Z";
            case GLFW.GLFW_KEY_LEFT_SHIFT -> "LS"; case GLFW.GLFW_KEY_TAB -> "TAB";
            case GLFW.GLFW_KEY_SPACE -> "SPC";
            default -> {
                String name = GLFW.glfwGetKeyName(key, 0);
                yield (name != null ? name.toUpperCase() : "B" + key);
            }
        };
    }

    private boolean hasCustomItem(ServerHelper.KeyBind bind) {
        if (mc.player == null) return false;
        String targetName = bind.setting().getName();
        for (int i = 0; i < mc.player.getInventory().size(); i++) {
            ItemStack stack = mc.player.getInventory().getStack(i);
            if (!stack.isEmpty() && stack.getItem() == bind.item()) {
                if (!stack.getComponents().contains(DataComponentTypes.CUSTOM_NAME)) return true;
                if (stack.getName().getString().contains(targetName)) return true;
            }
        }
        ItemStack offhand = mc.player.getOffHandStack();
        if (offhand.getItem() == bind.item()) {
            if (!offhand.getComponents().contains(DataComponentTypes.CUSTOM_NAME) || offhand.getName().getString().contains(targetName)) return true;
        }
        return false;
    }

    @Override
    public boolean visible() {
        return Hud.getInstance().interfaceSettings.isSelected(getName());
    }
}
ну ИИ код так ещё и дизайн так себе, ну не знаю даже 'return switch (key) { case GLFW.GLFW_KEY_A -> "A"; case GLFW.GLFW_KEY_B -> "B";'
 
case GLFW.GLFW_KEY_A -> "A"; case GLFW.GLFW_KEY_B -> "B"; case GLFW.GLFW_KEY_C -> "C";
case GLFW.GLFW_KEY_D -> "D"; case GLFW.GLFW_KEY_E -> "E"; case GLFW.GLFW_KEY_F -> "F";
case GLFW.GLFW_KEY_G -> "G"; case GLFW.GLFW_KEY_H -> "H"; case GLFW.GLFW_KEY_I -> "I";
case GLFW.GLFW_KEY_J -> "J"; case GLFW.GLFW_KEY_K -> "K"; case GLFW.GLFW_KEY_L -> "L";
case GLFW.GLFW_KEY_M -> "M"; case GLFW.GLFW_KEY_N -> "N"; case GLFW.GLFW_KEY_O -> "O";
case GLFW.GLFW_KEY_P -> "P"; case GLFW.GLFW_KEY_Q -> "Q"; case GLFW.GLFW_KEY_R -> "R";
case GLFW.GLFW_KEY_S -> "S"; case GLFW.GLFW_KEY_T -> "T"; case GLFW.GLFW_KEY_U -> "U";
case GLFW.GLFW_KEY_V -> "V"; case GLFW.GLFW_KEY_W -> "W"; case GLFW.GLFW_KEY_X -> "X";
case GLFW.GLFW_KEY_Y -> "Y"; case GLFW.GLFW_KEY_Z -> "Z";
Чтто это нахуй, ещё и кривая залупа
 
Посмотреть вложение 328098
Сделал ServerHelperHUD криво, но все же хотя бы работает. Если надо, сами дорабатывайте, фонс сами найдете.

ServerHelperHUD.java:
Expand Collapse Copy
package rich.screens.hud;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.component.DataComponentTypes;
import net.minecraft.item.ItemStack;
import org.lwjgl.glfw.GLFW;
import rich.Initialization;
import rich.client.draggables.AbstractHudElement;
import rich.modules.impl.misc.ServerHelper;
import rich.modules.impl.render.Hud;
import rich.util.ColorUtil;
import rich.util.render.Render2D;
import rich.util.render.font.Fonts;
import rich.util.render.item.ItemRender;

import java.awt.*;

public class ServerHelperHUD extends AbstractHudElement {

    public ServerHelperHUD() {
        super("ServerHelper", 200, 200, 18, 18, true);
    }

    @Override
    public void drawDraggable(DrawContext context, int alpha) {
        if (!Hud.getInstance().interfaceSettings.isSelected("ServerHelper")) return;

        ServerHelper serverHelper = Initialization.getInstance().getManager().getModuleProvider().get(ServerHelper.class);
        if (serverHelper == null || !serverHelper.isState() || mc.player == null) return;

        float startX = getX();
        float y = getY();
        float x = startX;
        float spacing = 6;
        float size = 18;

        for (ServerHelper.KeyBind bind : serverHelper.getKeyBindings()) {
            if (bind.setting().getKey() <= 0 || !bind.setting().getVisible().get() || !hasCustomItem(bind)) {
                continue;
            }

            Render2D.rect(x, y, size, size, ColorUtil.getColor(15, 15, 15, (int)(alpha * 0.8f)), 4);

            String keyName = getEnglishKeyName(bind.setting().getKey());
            float fontSize = 6f;
            float textWidth = Fonts.SFPRO_REGULAR.getWidth(keyName, fontSize);
            float rectW = Math.max(8, textWidth + 3);
            float rectH = 6.5f;
            float rectX = x + size - rectW + 1.5f;
            float rectY = y + size - rectH + 0.5f;

            Render2D.rect(rectX, rectY, rectW, rectH, ColorUtil.getColor(200, 30, 30, (int)(alpha * 0.7f)), 2);

            ItemStack stack = new ItemStack(bind.item());
            float itemScale = 0.65f;
            if (ItemRender.needsContextRender(stack)) {
                ItemRender.drawItemCenteredWithContext(context, stack, x + size / 2f, y + size / 2f - 1.2f, itemScale, alpha / 255f);
            } else {
                ItemRender.drawItemCentered(stack, x + size / 2f, y + size / 2f - 1.2f, itemScale, alpha / 255f);
            }

            x += size + spacing;
        }

        x = startX;
        for (ServerHelper.KeyBind bind : serverHelper.getKeyBindings()) {
            if (bind.setting().getKey() <= 0 || !bind.setting().getVisible().get() || !hasCustomItem(bind)) {
                continue;
            }

            String keyName = getEnglishKeyName(bind.setting().getKey());
            float fontSize = 5.5f;
            float textWidth = Fonts.SFPRO_REGULAR.getWidth(keyName, fontSize);

            float rectW = Math.max(8, textWidth + 3);
            float rectH = 6.5f;
            float rectX = x + size - rectW + 1.5f;
            float rectY = y + size - rectH + 0.5f;

            int textColor = ColorUtil.getColor(255, 255, 255, (int)(alpha * 0.8f));
            Fonts.SFPRO_REGULAR.draw(keyName, rectX + (rectW / 2f) - (textWidth / 2f), rectY + 0.8f, fontSize, textColor);

            x += size + spacing;
        }

        setWidth((int) (x - getX()));
        setHeight((int) size);
    }

    private String getEnglishKeyName(int key) {
        if (key >= GLFW.GLFW_MOUSE_BUTTON_1 && key <= GLFW.GLFW_MOUSE_BUTTON_8) {
            return "M" + (key + 1);
        }
        return switch (key) {
            case GLFW.GLFW_KEY_A -> "A"; case GLFW.GLFW_KEY_B -> "B"; case GLFW.GLFW_KEY_C -> "C";
            case GLFW.GLFW_KEY_D -> "D"; case GLFW.GLFW_KEY_E -> "E"; case GLFW.GLFW_KEY_F -> "F";
            case GLFW.GLFW_KEY_G -> "G"; case GLFW.GLFW_KEY_H -> "H"; case GLFW.GLFW_KEY_I -> "I";
            case GLFW.GLFW_KEY_J -> "J"; case GLFW.GLFW_KEY_K -> "K"; case GLFW.GLFW_KEY_L -> "L";
            case GLFW.GLFW_KEY_M -> "M"; case GLFW.GLFW_KEY_N -> "N"; case GLFW.GLFW_KEY_O -> "O";
            case GLFW.GLFW_KEY_P -> "P"; case GLFW.GLFW_KEY_Q -> "Q"; case GLFW.GLFW_KEY_R -> "R";
            case GLFW.GLFW_KEY_S -> "S"; case GLFW.GLFW_KEY_T -> "T"; case GLFW.GLFW_KEY_U -> "U";
            case GLFW.GLFW_KEY_V -> "V"; case GLFW.GLFW_KEY_W -> "W"; case GLFW.GLFW_KEY_X -> "X";
            case GLFW.GLFW_KEY_Y -> "Y"; case GLFW.GLFW_KEY_Z -> "Z";
            case GLFW.GLFW_KEY_LEFT_SHIFT -> "LS"; case GLFW.GLFW_KEY_TAB -> "TAB";
            case GLFW.GLFW_KEY_SPACE -> "SPC";
            default -> {
                String name = GLFW.glfwGetKeyName(key, 0);
                yield (name != null ? name.toUpperCase() : "B" + key);
            }
        };
    }

    private boolean hasCustomItem(ServerHelper.KeyBind bind) {
        if (mc.player == null) return false;
        String targetName = bind.setting().getName();
        for (int i = 0; i < mc.player.getInventory().size(); i++) {
            ItemStack stack = mc.player.getInventory().getStack(i);
            if (!stack.isEmpty() && stack.getItem() == bind.item()) {
                if (!stack.getComponents().contains(DataComponentTypes.CUSTOM_NAME)) return true;
                if (stack.getName().getString().contains(targetName)) return true;
            }
        }
        ItemStack offhand = mc.player.getOffHandStack();
        if (offhand.getItem() == bind.item()) {
            if (!offhand.getComponents().contains(DataComponentTypes.CUSTOM_NAME) || offhand.getName().getString().contains(targetName)) return true;
        }
        return false;
    }

    @Override
    public boolean visible() {
        return Hud.getInstance().interfaceSettings.isSelected(getName());
    }
}
/del легче уж на юг под 1.16.5 найти и иишкой за 3 минуты спастить
 
ну ИИ код так ещё и дизайн так себе, ну не знаю даже 'return switch (key) { case GLFW.GLFW_KEY_A -> "A"; case GLFW.GLFW_KEY_B -> "B";'
Мне было лень писать самому хоть и 10 мин заняло ии в помощь + я уже переписал себе сам без ИИ и я говорил кривая чисто для пастеров
 
Назад
Сверху Снизу