Визуальная часть Keystokes excellent ready HUD element

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
25 Янв 2024
Сообщения
110
Реакции
0
Выберите загрузчик игры
  1. Vanilla
  2. Прочие моды

Перед прочтением основного контента ниже, пожалуйста, обратите внимание на обновление внутри секции Майна на нашем форуме. У нас появились:

  • бесплатные читы для Майнкрафт — любое использование на свой страх и риск;
  • маркетплейс Майнкрафт — абсолютно любая коммерция, связанная с игрой, за исключением продажи читов (аккаунты, предоставления услуг, поиск кодеров читов и так далее);
  • приватные читы для Minecraft — в этом разделе только платные хаки для игры, покупайте группу "Продавец" и выставляйте на продажу свой софт;
  • обсуждения и гайды — всё тот же раздел с вопросами, но теперь модернизированный: поиск нужных хаков, пати с игроками-читерами и другая полезная информация.

Спасибо!

не знаю почему но на всех :frog-wow:YOUGAME:da: почти нету нормального дизайна их и тем более на экселлент так что вот вам заливаю создано в privateclient - fungetx :negr:
ss -
Пожалуйста, авторизуйтесь для просмотра ссылки.






KeystrokesRender:
Expand Collapse Copy
package org.excellent.client.screen.hud.impl;

import lombok.Getter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.settings.KeyBinding;
import net.mojang.blaze3d.matrix.MatrixStack;
import net.mojang.blaze3d.platform.GlStateManager;
import org.excellent.client.managers.events.render.Render2DEvent;
import org.excellent.client.managers.module.impl.client.Theme;
import org.excellent.client.managers.module.settings.impl.DragSetting;
import org.excellent.client.screen.hud.IRenderer;
import org.excellent.client.utils.math.Mathf;
import org.excellent.client.utils.render.color.ColorUtil;
import org.excellent.client.utils.render.draw.RenderUtil;
import org.excellent.client.utils.render.draw.Round;
import org.excellent.client.utils.render.font.Fonts;
import org.lwjgl.glfw.GLFW;

import java.util.HashMap;
import java.util.Map;

[USER=270918]@Getter[/USER]
public class KeyStrokesRenderer implements IRenderer {
    private final DragSetting drag;
    private final Minecraft mc = Minecraft.getInstance();

    private final Map<String, Float> keyAnimations = new HashMap<>();
    private final Map<String, Long> keyPressTime = new HashMap<>();
    private float scaleV;
    private boolean blurEnabled = false;
    private final float keySize = 24f;
    private final float spacing = 2f;
    private final float mouseKeySize = 18f;
    public KeyStrokesRenderer(DragSetting drag) {
        this.drag = drag;// не момню на деф экселленте такойже драг ну проверите кароче
        initializeAnimations();
    }

    private void initializeAnimations() {
        keyAnimations.put("W", 0f);
        keyAnimations.put("A", 0f);
        keyAnimations.put("S", 0f);
        keyAnimations.put("D", 0f);
        keyAnimations.put("LMB", 0f);
        keyAnimations.put("RMB", 0f);
        keyAnimations.put("SPACE", 0f);

        keyPressTime.put("W", 0L);
        keyPressTime.put("A", 0L);
        keyPressTime.put("S", 0L);
        keyPressTime.put("D", 0L);
        keyPressTime.put("LMB", 0L);
        keyPressTime.put("RMB", 0L);
        keyPressTime.put("SPACE", 0L);
    }

    public void setBlurEnabled(boolean blurEnabled) {
        this.blurEnabled = blurEnabled;
    }

    [USER=1367676]@override[/USER]
    public void render(Render2DEvent event) {
        if (mc.player == null || mc.world == null) return;

        MatrixStack matrix = event.getMatrix();


        float x = drag.position.x;
        float y = drag.position.y;
        float width = drag.size.x;
        float height = drag.size.y;
        if (x == 0 || y == 0) {
            drag.position.set(10, mc.getMainWindow().getScaledHeight() - height - 80);
        }
        scaleV = Mathf.fast(scaleV, shouldShow() ? 1 : 0, 12);
        if (Mathf.round(scaleV, .1d) <= 0) return;
        updateKeyStates();
        GlStateManager.pushMatrix();
        GlStateManager.translatef(x + width / 2f, y + height / 2f, 1);
        GlStateManager.scalef(scaleV, scaleV, scaleV);
        GlStateManager.translatef(-(x + width / 2f), -(y + height / 2f), 1);
        drawKeys(matrix, x, y);

        GlStateManager.popMatrix();
    }

    private void drawKeys(MatrixStack matrix, float baseX, float baseY) {
        float currentY = baseY + spacing;

        drawKey(matrix, baseX + keySize + spacing, currentY, "W", keySize);
        currentY += keySize + spacing;
        drawKey(matrix, baseX + spacing, currentY, "A", keySize);
        drawKey(matrix, baseX + keySize + spacing, currentY, "S", keySize);
        drawKey(matrix, baseX + keySize * 2 + spacing, currentY, "D", keySize);
        currentY += keySize + spacing;
        float mouseRowY = currentY;
        float mouseWidth = (keySize * 3 + spacing) / 2f - spacing / 2f;
        drawKey(matrix, baseX + spacing, mouseRowY, "LMB", mouseWidth, mouseKeySize);
        drawKey(matrix, baseX + mouseWidth + spacing * 2, mouseRowY, "RMB", mouseWidth, mouseKeySize);
        currentY += mouseKeySize + spacing;

        drawKey(matrix, baseX + spacing, currentY, "SPACE", keySize * 3 + spacing, mouseKeySize);
    }

    private void drawKey(MatrixStack matrix, float x, float y, String keyName, float width) {
        drawKey(matrix, x, y, keyName, width, keySize);
    }

    private void drawKey(MatrixStack matrix, float x, float y, String keyName, float width, float height) {
        float animation = keyAnimations.get(keyName);
        int activeColor = Theme.getInstance().clientColor();
        int inactiveColor = ColorUtil.getColor(25, 25, 25, 180);
        int backgroundColor = ColorUtil.overCol(inactiveColor, activeColor, animation);

        int textColor = ColorUtil.overCol(
                ColorUtil.getColor(150, 150, 150, 255),
                ColorUtil.getColor(255, 255, 255, 255),
                animation
        );

        RenderUtil.Rounded.roundedRect(matrix, x, y, width, height, backgroundColor, Round.of(4));
        if (animation > 0.1f) {
            RenderUtil.Shadow.drawShadow(matrix, x, y, width, height, 8f, animation * 0.8f, activeColor, Round.of(4));
        }

        RenderUtil.Rounded.roundedOutline(matrix, x, y, width, height, 1f,
                ColorUtil.getColor(255, 255, 255, (int) (30 + animation * 50)), Round.of(4));

        String displayText = getDisplayText(keyName);
        float fontSize = keyName.equals("SPACE") ? 6f : (keyName.contains("MB") ? 5f : 7f);
        float textWidth = Fonts.SF_MEDIUM.getWidth(displayText, fontSize);
        float textHeight = Fonts.SF_MEDIUM.getHeight(displayText, fontSize);

        float textX = x + (width - textWidth) / 2f;
        float textY = y + (height - textHeight) / 2f;

        float pressOffset = animation * 1.5f;
        textY += pressOffset;

        Fonts.SF_MEDIUM.draw(matrix, displayText, textX, textY, textColor, fontSize);

        // no work 20 cps everyclick
        if (keyName.contains("MB")) {
            drawCPS(matrix, x, y + height + 2, width, keyName);
        }
    }

    private void drawCPS(MatrixStack matrix, float x, float y, float width, String mouseButton) {
        long currentTime = System.currentTimeMillis();
        long pressTime = keyPressTime.get(mouseButton);

        // не правильно считает сам счетчик но это рендер можете удалить
        int cps = getCPS(mouseButton);

        if (cps > 0) {
            String cpsText = cps + " CPS";
            float fontSize = 4.5f;
            float textWidth = Fonts.SF_MEDIUM.getWidth(cpsText, fontSize);
            float textX = x + (width - textWidth) / 2f;

            Fonts.SF_MEDIUM.draw(matrix, cpsText, textX, y,
                    ColorUtil.getColor(200, 200, 200, 200), fontSize);
        }
    }

    private int getCPS(String mouseButton) {
    
        long currentTime = System.currentTimeMillis();
        long lastPress = keyPressTime.get(mouseButton);

        if (currentTime - lastPress < 100) {
            return (int) Math.min(20, 1000f / Math.max(1, currentTime - lastPress));
        }
        return 0;
    }

    private String getDisplayText(String keyName) {
        return switch (keyName) {
            case "LMB" -> "LMB";
            case "RMB" -> "RMB";
            case "SPACE" -> "SPACE";
            default -> keyName;
        };
    }

    private void updateKeyStates() {
        long currentTime = System.currentTimeMillis();

        updateKeyAnimation("W", isKeyPressed(mc.gameSettings.keyBindForward), currentTime);
        updateKeyAnimation("A", isKeyPressed(mc.gameSettings.keyBindLeft), currentTime);
        updateKeyAnimation("S", isKeyPressed(mc.gameSettings.keyBindBack), currentTime);
        updateKeyAnimation("D", isKeyPressed(mc.gameSettings.keyBindRight), currentTime);
        updateKeyAnimation("SPACE", isKeyPressed(mc.gameSettings.keyBindJump), currentTime);

        boolean leftClick = GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_LEFT) == GLFW.GLFW_PRESS;
        boolean rightClick = GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS;

        updateKeyAnimation("LMB", leftClick, currentTime);
        updateKeyAnimation("RMB", rightClick, currentTime);
    }

    private void updateKeyAnimation(String keyName, boolean isPressed, long currentTime) {
        float currentAnim = keyAnimations.get(keyName);

        if (isPressed) {
            keyAnimations.put(keyName, Mathf.fast(currentAnim, 1.0f, 20f));
            keyPressTime.put(keyName, currentTime);
        } else {
            keyAnimations.put(keyName, Mathf.fast(currentAnim, 0.0f, 15f));
        }
    }

    private boolean isKeyPressed(KeyBinding keyBinding) {
        try {
            return keyBinding.isKeyDown();
        } catch (Exception e) {
            return false;
        }
    }

    private boolean shouldShow() {
        return (mc.player != null && mc.world != null) || (mc.currentScreen instanceof ChatScreen);
    }
}
 
не знаю почему но на всех :frog-wow:YOUGAME:da:почти нету нормального дизайна их и тем более на экселлент так что вот вам заливаю создано в privateclient - fungetx :negr:
ss -
Пожалуйста, авторизуйтесь для просмотра ссылки.






KeystrokesRender:
Expand Collapse Copy
package org.excellent.client.screen.hud.impl;

import lombok.Getter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.settings.KeyBinding;
import net.mojang.blaze3d.matrix.MatrixStack;
import net.mojang.blaze3d.platform.GlStateManager;
import org.excellent.client.managers.events.render.Render2DEvent;
import org.excellent.client.managers.module.impl.client.Theme;
import org.excellent.client.managers.module.settings.impl.DragSetting;
import org.excellent.client.screen.hud.IRenderer;
import org.excellent.client.utils.math.Mathf;
import org.excellent.client.utils.render.color.ColorUtil;
import org.excellent.client.utils.render.draw.RenderUtil;
import org.excellent.client.utils.render.draw.Round;
import org.excellent.client.utils.render.font.Fonts;
import org.lwjgl.glfw.GLFW;

import java.util.HashMap;
import java.util.Map;

[USER=270918]@Getter[/USER]
public class KeyStrokesRenderer implements IRenderer {
    private final DragSetting drag;
    private final Minecraft mc = Minecraft.getInstance();

    private final Map<String, Float> keyAnimations = new HashMap<>();
    private final Map<String, Long> keyPressTime = new HashMap<>();
    private float scaleV;
    private boolean blurEnabled = false;
    private final float keySize = 24f;
    private final float spacing = 2f;
    private final float mouseKeySize = 18f;
    public KeyStrokesRenderer(DragSetting drag) {
        this.drag = drag;// не момню на деф экселленте такойже драг ну проверите кароче
        initializeAnimations();
    }

    private void initializeAnimations() {
        keyAnimations.put("W", 0f);
        keyAnimations.put("A", 0f);
        keyAnimations.put("S", 0f);
        keyAnimations.put("D", 0f);
        keyAnimations.put("LMB", 0f);
        keyAnimations.put("RMB", 0f);
        keyAnimations.put("SPACE", 0f);

        keyPressTime.put("W", 0L);
        keyPressTime.put("A", 0L);
        keyPressTime.put("S", 0L);
        keyPressTime.put("D", 0L);
        keyPressTime.put("LMB", 0L);
        keyPressTime.put("RMB", 0L);
        keyPressTime.put("SPACE", 0L);
    }

    public void setBlurEnabled(boolean blurEnabled) {
        this.blurEnabled = blurEnabled;
    }

    [USER=1367676]@override[/USER]
    public void render(Render2DEvent event) {
        if (mc.player == null || mc.world == null) return;

        MatrixStack matrix = event.getMatrix();


        float x = drag.position.x;
        float y = drag.position.y;
        float width = drag.size.x;
        float height = drag.size.y;
        if (x == 0 || y == 0) {
            drag.position.set(10, mc.getMainWindow().getScaledHeight() - height - 80);
        }
        scaleV = Mathf.fast(scaleV, shouldShow() ? 1 : 0, 12);
        if (Mathf.round(scaleV, .1d) <= 0) return;
        updateKeyStates();
        GlStateManager.pushMatrix();
        GlStateManager.translatef(x + width / 2f, y + height / 2f, 1);
        GlStateManager.scalef(scaleV, scaleV, scaleV);
        GlStateManager.translatef(-(x + width / 2f), -(y + height / 2f), 1);
        drawKeys(matrix, x, y);

        GlStateManager.popMatrix();
    }

    private void drawKeys(MatrixStack matrix, float baseX, float baseY) {
        float currentY = baseY + spacing;

        drawKey(matrix, baseX + keySize + spacing, currentY, "W", keySize);
        currentY += keySize + spacing;
        drawKey(matrix, baseX + spacing, currentY, "A", keySize);
        drawKey(matrix, baseX + keySize + spacing, currentY, "S", keySize);
        drawKey(matrix, baseX + keySize * 2 + spacing, currentY, "D", keySize);
        currentY += keySize + spacing;
        float mouseRowY = currentY;
        float mouseWidth = (keySize * 3 + spacing) / 2f - spacing / 2f;
        drawKey(matrix, baseX + spacing, mouseRowY, "LMB", mouseWidth, mouseKeySize);
        drawKey(matrix, baseX + mouseWidth + spacing * 2, mouseRowY, "RMB", mouseWidth, mouseKeySize);
        currentY += mouseKeySize + spacing;

        drawKey(matrix, baseX + spacing, currentY, "SPACE", keySize * 3 + spacing, mouseKeySize);
    }

    private void drawKey(MatrixStack matrix, float x, float y, String keyName, float width) {
        drawKey(matrix, x, y, keyName, width, keySize);
    }

    private void drawKey(MatrixStack matrix, float x, float y, String keyName, float width, float height) {
        float animation = keyAnimations.get(keyName);
        int activeColor = Theme.getInstance().clientColor();
        int inactiveColor = ColorUtil.getColor(25, 25, 25, 180);
        int backgroundColor = ColorUtil.overCol(inactiveColor, activeColor, animation);

        int textColor = ColorUtil.overCol(
                ColorUtil.getColor(150, 150, 150, 255),
                ColorUtil.getColor(255, 255, 255, 255),
                animation
        );

        RenderUtil.Rounded.roundedRect(matrix, x, y, width, height, backgroundColor, Round.of(4));
        if (animation > 0.1f) {
            RenderUtil.Shadow.drawShadow(matrix, x, y, width, height, 8f, animation * 0.8f, activeColor, Round.of(4));
        }

        RenderUtil.Rounded.roundedOutline(matrix, x, y, width, height, 1f,
                ColorUtil.getColor(255, 255, 255, (int) (30 + animation * 50)), Round.of(4));

        String displayText = getDisplayText(keyName);
        float fontSize = keyName.equals("SPACE") ? 6f : (keyName.contains("MB") ? 5f : 7f);
        float textWidth = Fonts.SF_MEDIUM.getWidth(displayText, fontSize);
        float textHeight = Fonts.SF_MEDIUM.getHeight(displayText, fontSize);

        float textX = x + (width - textWidth) / 2f;
        float textY = y + (height - textHeight) / 2f;

        float pressOffset = animation * 1.5f;
        textY += pressOffset;

        Fonts.SF_MEDIUM.draw(matrix, displayText, textX, textY, textColor, fontSize);

        // no work 20 cps everyclick
        if (keyName.contains("MB")) {
            drawCPS(matrix, x, y + height + 2, width, keyName);
        }
    }

    private void drawCPS(MatrixStack matrix, float x, float y, float width, String mouseButton) {
        long currentTime = System.currentTimeMillis();
        long pressTime = keyPressTime.get(mouseButton);

        // не правильно считает сам счетчик но это рендер можете удалить
        int cps = getCPS(mouseButton);

        if (cps > 0) {
            String cpsText = cps + " CPS";
            float fontSize = 4.5f;
            float textWidth = Fonts.SF_MEDIUM.getWidth(cpsText, fontSize);
            float textX = x + (width - textWidth) / 2f;

            Fonts.SF_MEDIUM.draw(matrix, cpsText, textX, y,
                    ColorUtil.getColor(200, 200, 200, 200), fontSize);
        }
    }

    private int getCPS(String mouseButton) {
   
        long currentTime = System.currentTimeMillis();
        long lastPress = keyPressTime.get(mouseButton);

        if (currentTime - lastPress < 100) {
            return (int) Math.min(20, 1000f / Math.max(1, currentTime - lastPress));
        }
        return 0;
    }

    private String getDisplayText(String keyName) {
        return switch (keyName) {
            case "LMB" -> "LMB";
            case "RMB" -> "RMB";
            case "SPACE" -> "SPACE";
            default -> keyName;
        };
    }

    private void updateKeyStates() {
        long currentTime = System.currentTimeMillis();

        updateKeyAnimation("W", isKeyPressed(mc.gameSettings.keyBindForward), currentTime);
        updateKeyAnimation("A", isKeyPressed(mc.gameSettings.keyBindLeft), currentTime);
        updateKeyAnimation("S", isKeyPressed(mc.gameSettings.keyBindBack), currentTime);
        updateKeyAnimation("D", isKeyPressed(mc.gameSettings.keyBindRight), currentTime);
        updateKeyAnimation("SPACE", isKeyPressed(mc.gameSettings.keyBindJump), currentTime);

        boolean leftClick = GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_LEFT) == GLFW.GLFW_PRESS;
        boolean rightClick = GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS;

        updateKeyAnimation("LMB", leftClick, currentTime);
        updateKeyAnimation("RMB", rightClick, currentTime);
    }

    private void updateKeyAnimation(String keyName, boolean isPressed, long currentTime) {
        float currentAnim = keyAnimations.get(keyName);

        if (isPressed) {
            keyAnimations.put(keyName, Mathf.fast(currentAnim, 1.0f, 20f));
            keyPressTime.put(keyName, currentTime);
        } else {
            keyAnimations.put(keyName, Mathf.fast(currentAnim, 0.0f, 15f));
        }
    }

    private boolean isKeyPressed(KeyBinding keyBinding) {
        try {
            return keyBinding.isKeyDown();
        } catch (Exception e) {
            return false;
        }
    }

    private boolean shouldShow() {
        return (mc.player != null && mc.world != null) || (mc.currentScreen instanceof ChatScreen);
    }
}
/del gpt
 
зачем это вообще хуйня нужна, так ещё и сделана ущербно максимально
 
интересные конечно люди щас пошли видят работу чата гпт сразу "кал" причем другие темы где пастят вручную всякие экспенсивы не засирают так как работу от чата гпт но отличий то нет особо челик просто время не потратил зря а посмотрел там к примеру видео учебное и т.д пока другой сидит потно ctrl c ctrl v жмет своими пальцами
 
гуд +реп
 
интересные конечно люди щас пошли видят работу чата гпт сразу "кал" причем другие темы где пастят вручную всякие экспенсивы не засирают так как работу от чата гпт но отличий то нет особо челик просто время не потратил зря а посмотрел там к примеру видео учебное и т.д пока другой сидит потно ctrl c ctrl v жмет своими пальцами
ебать у тебя понятия
 
не знаю почему но на всех :frog-wow:YOUGAME:da:почти нету нормального дизайна их и тем более на экселлент так что вот вам заливаю создано в privateclient - fungetx :negr:
ss -
Пожалуйста, авторизуйтесь для просмотра ссылки.






KeystrokesRender:
Expand Collapse Copy
package org.excellent.client.screen.hud.impl;

import lombok.Getter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.settings.KeyBinding;
import net.mojang.blaze3d.matrix.MatrixStack;
import net.mojang.blaze3d.platform.GlStateManager;
import org.excellent.client.managers.events.render.Render2DEvent;
import org.excellent.client.managers.module.impl.client.Theme;
import org.excellent.client.managers.module.settings.impl.DragSetting;
import org.excellent.client.screen.hud.IRenderer;
import org.excellent.client.utils.math.Mathf;
import org.excellent.client.utils.render.color.ColorUtil;
import org.excellent.client.utils.render.draw.RenderUtil;
import org.excellent.client.utils.render.draw.Round;
import org.excellent.client.utils.render.font.Fonts;
import org.lwjgl.glfw.GLFW;

import java.util.HashMap;
import java.util.Map;

[USER=270918]@Getter[/USER]
public class KeyStrokesRenderer implements IRenderer {
    private final DragSetting drag;
    private final Minecraft mc = Minecraft.getInstance();

    private final Map<String, Float> keyAnimations = new HashMap<>();
    private final Map<String, Long> keyPressTime = new HashMap<>();
    private float scaleV;
    private boolean blurEnabled = false;
    private final float keySize = 24f;
    private final float spacing = 2f;
    private final float mouseKeySize = 18f;
    public KeyStrokesRenderer(DragSetting drag) {
        this.drag = drag;// не момню на деф экселленте такойже драг ну проверите кароче
        initializeAnimations();
    }

    private void initializeAnimations() {
        keyAnimations.put("W", 0f);
        keyAnimations.put("A", 0f);
        keyAnimations.put("S", 0f);
        keyAnimations.put("D", 0f);
        keyAnimations.put("LMB", 0f);
        keyAnimations.put("RMB", 0f);
        keyAnimations.put("SPACE", 0f);

        keyPressTime.put("W", 0L);
        keyPressTime.put("A", 0L);
        keyPressTime.put("S", 0L);
        keyPressTime.put("D", 0L);
        keyPressTime.put("LMB", 0L);
        keyPressTime.put("RMB", 0L);
        keyPressTime.put("SPACE", 0L);
    }

    public void setBlurEnabled(boolean blurEnabled) {
        this.blurEnabled = blurEnabled;
    }

    [USER=1367676]@override[/USER]
    public void render(Render2DEvent event) {
        if (mc.player == null || mc.world == null) return;

        MatrixStack matrix = event.getMatrix();


        float x = drag.position.x;
        float y = drag.position.y;
        float width = drag.size.x;
        float height = drag.size.y;
        if (x == 0 || y == 0) {
            drag.position.set(10, mc.getMainWindow().getScaledHeight() - height - 80);
        }
        scaleV = Mathf.fast(scaleV, shouldShow() ? 1 : 0, 12);
        if (Mathf.round(scaleV, .1d) <= 0) return;
        updateKeyStates();
        GlStateManager.pushMatrix();
        GlStateManager.translatef(x + width / 2f, y + height / 2f, 1);
        GlStateManager.scalef(scaleV, scaleV, scaleV);
        GlStateManager.translatef(-(x + width / 2f), -(y + height / 2f), 1);
        drawKeys(matrix, x, y);

        GlStateManager.popMatrix();
    }

    private void drawKeys(MatrixStack matrix, float baseX, float baseY) {
        float currentY = baseY + spacing;

        drawKey(matrix, baseX + keySize + spacing, currentY, "W", keySize);
        currentY += keySize + spacing;
        drawKey(matrix, baseX + spacing, currentY, "A", keySize);
        drawKey(matrix, baseX + keySize + spacing, currentY, "S", keySize);
        drawKey(matrix, baseX + keySize * 2 + spacing, currentY, "D", keySize);
        currentY += keySize + spacing;
        float mouseRowY = currentY;
        float mouseWidth = (keySize * 3 + spacing) / 2f - spacing / 2f;
        drawKey(matrix, baseX + spacing, mouseRowY, "LMB", mouseWidth, mouseKeySize);
        drawKey(matrix, baseX + mouseWidth + spacing * 2, mouseRowY, "RMB", mouseWidth, mouseKeySize);
        currentY += mouseKeySize + spacing;

        drawKey(matrix, baseX + spacing, currentY, "SPACE", keySize * 3 + spacing, mouseKeySize);
    }

    private void drawKey(MatrixStack matrix, float x, float y, String keyName, float width) {
        drawKey(matrix, x, y, keyName, width, keySize);
    }

    private void drawKey(MatrixStack matrix, float x, float y, String keyName, float width, float height) {
        float animation = keyAnimations.get(keyName);
        int activeColor = Theme.getInstance().clientColor();
        int inactiveColor = ColorUtil.getColor(25, 25, 25, 180);
        int backgroundColor = ColorUtil.overCol(inactiveColor, activeColor, animation);

        int textColor = ColorUtil.overCol(
                ColorUtil.getColor(150, 150, 150, 255),
                ColorUtil.getColor(255, 255, 255, 255),
                animation
        );

        RenderUtil.Rounded.roundedRect(matrix, x, y, width, height, backgroundColor, Round.of(4));
        if (animation > 0.1f) {
            RenderUtil.Shadow.drawShadow(matrix, x, y, width, height, 8f, animation * 0.8f, activeColor, Round.of(4));
        }

        RenderUtil.Rounded.roundedOutline(matrix, x, y, width, height, 1f,
                ColorUtil.getColor(255, 255, 255, (int) (30 + animation * 50)), Round.of(4));

        String displayText = getDisplayText(keyName);
        float fontSize = keyName.equals("SPACE") ? 6f : (keyName.contains("MB") ? 5f : 7f);
        float textWidth = Fonts.SF_MEDIUM.getWidth(displayText, fontSize);
        float textHeight = Fonts.SF_MEDIUM.getHeight(displayText, fontSize);

        float textX = x + (width - textWidth) / 2f;
        float textY = y + (height - textHeight) / 2f;

        float pressOffset = animation * 1.5f;
        textY += pressOffset;

        Fonts.SF_MEDIUM.draw(matrix, displayText, textX, textY, textColor, fontSize);

        // no work 20 cps everyclick
        if (keyName.contains("MB")) {
            drawCPS(matrix, x, y + height + 2, width, keyName);
        }
    }

    private void drawCPS(MatrixStack matrix, float x, float y, float width, String mouseButton) {
        long currentTime = System.currentTimeMillis();
        long pressTime = keyPressTime.get(mouseButton);

        // не правильно считает сам счетчик но это рендер можете удалить
        int cps = getCPS(mouseButton);

        if (cps > 0) {
            String cpsText = cps + " CPS";
            float fontSize = 4.5f;
            float textWidth = Fonts.SF_MEDIUM.getWidth(cpsText, fontSize);
            float textX = x + (width - textWidth) / 2f;

            Fonts.SF_MEDIUM.draw(matrix, cpsText, textX, y,
                    ColorUtil.getColor(200, 200, 200, 200), fontSize);
        }
    }

    private int getCPS(String mouseButton) {
   
        long currentTime = System.currentTimeMillis();
        long lastPress = keyPressTime.get(mouseButton);

        if (currentTime - lastPress < 100) {
            return (int) Math.min(20, 1000f / Math.max(1, currentTime - lastPress));
        }
        return 0;
    }

    private String getDisplayText(String keyName) {
        return switch (keyName) {
            case "LMB" -> "LMB";
            case "RMB" -> "RMB";
            case "SPACE" -> "SPACE";
            default -> keyName;
        };
    }

    private void updateKeyStates() {
        long currentTime = System.currentTimeMillis();

        updateKeyAnimation("W", isKeyPressed(mc.gameSettings.keyBindForward), currentTime);
        updateKeyAnimation("A", isKeyPressed(mc.gameSettings.keyBindLeft), currentTime);
        updateKeyAnimation("S", isKeyPressed(mc.gameSettings.keyBindBack), currentTime);
        updateKeyAnimation("D", isKeyPressed(mc.gameSettings.keyBindRight), currentTime);
        updateKeyAnimation("SPACE", isKeyPressed(mc.gameSettings.keyBindJump), currentTime);

        boolean leftClick = GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_LEFT) == GLFW.GLFW_PRESS;
        boolean rightClick = GLFW.glfwGetMouseButton(mc.getMainWindow().getHandle(), GLFW.GLFW_MOUSE_BUTTON_RIGHT) == GLFW.GLFW_PRESS;

        updateKeyAnimation("LMB", leftClick, currentTime);
        updateKeyAnimation("RMB", rightClick, currentTime);
    }

    private void updateKeyAnimation(String keyName, boolean isPressed, long currentTime) {
        float currentAnim = keyAnimations.get(keyName);

        if (isPressed) {
            keyAnimations.put(keyName, Mathf.fast(currentAnim, 1.0f, 20f));
            keyPressTime.put(keyName, currentTime);
        } else {
            keyAnimations.put(keyName, Mathf.fast(currentAnim, 0.0f, 15f));
        }
    }

    private boolean isKeyPressed(KeyBinding keyBinding) {
        try {
            return keyBinding.isKeyDown();
        } catch (Exception e) {
            return false;
        }
    }

    private boolean shouldShow() {
        return (mc.player != null && mc.world != null) || (mc.currentScreen instanceof ChatScreen);
    }
}
какая же это дристня
 
Назад
Сверху Снизу