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

Визуальная часть Watermark 1.21.11 RICH

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
13 Июл 2025
Сообщения
207
Реакции
0
Выберите загрузчик игры
  1. Vanilla
SS
1771044228443.png

Code


Watermark:
Expand Collapse Copy
package rich.screens.hud;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.util.math.MathHelper;
import rich.client.draggables.AbstractHudElement;
import rich.modules.impl.render.Hud;
import rich.util.render.Render2D;
import rich.util.render.font.Fonts;
import rich.util.tps.TPSCalculate;

import java.awt.*;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

public class Watermark extends AbstractHudElement {

    private String lastFps = "";
    private String oldFps = "";
    private long fpsAnimationStart = 0;

    private String lastTime = "";
    private String oldTime = "";
    private long timeAnimationStart = 0;

    private String lastTps = "";
    private String oldTps = "";
    private long tpsAnimationStart = 0;

    private static final long ANIMATION_DURATION = 200;
    private static final float ANIMATION_OFFSET = 8.0f;
    private static final float CORNER_RADIUS = 6f;

    public Watermark() {
        super("Watermark", 10, 10, 200, 22, false);
    }

    @Override
    public void tick() {}

    private int clampAlpha(float alpha) {
        return Math.max(0, Math.min(255, (int) (alpha * 255)));
    }

    @Override
    public void drawDraggable(DrawContext context, int alpha) {
        if (alpha <= 0) return;

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

        String clientName = "Anolix Client";
        String fpsNumber = String.valueOf(mc.getCurrentFps());
        String fpsText = "fps";
        String time = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm"));

        boolean showTps = Hud.getInstance() != null && Hud.getInstance().showTps.isValue();

        float tpsValue = 20.0f;
        if (TPSCalculate.getInstance() != null) {
            tpsValue = TPSCalculate.getInstance().getTpsRounded();
        }
        String tpsNumber = String.format("%.1f", tpsValue);
        String tpsText = "tps ";

        long currentTime = System.currentTimeMillis();

        if (!fpsNumber.equals(lastFps)) {
            oldFps = lastFps;
            lastFps = fpsNumber;
            fpsAnimationStart = currentTime;
        }

        if (!time.equals(lastTime)) {
            oldTime = lastTime;
            lastTime = time;
            timeAnimationStart = currentTime;
        }

        if (!tpsNumber.equals(lastTps)) {
            oldTps = lastTps;
            lastTps = tpsNumber;
            tpsAnimationStart = currentTime;
        }

        float fpsAnimation = Math.min(1.0f, (currentTime - fpsAnimationStart) / (float) ANIMATION_DURATION);
        float timeAnimation = Math.min(1.0f, (currentTime - timeAnimationStart) / (float) ANIMATION_DURATION);
        float tpsAnimation = Math.min(1.0f, (currentTime - tpsAnimationStart) / (float) ANIMATION_DURATION);

        float clientNameWidth = Fonts.BOLD.getWidth(clientName, 7);
        float fpsNumberWidth = Fonts.BOLD.getWidth(fpsNumber, 7);
        float fpsTextWidth = Fonts.BOLD.getWidth(fpsText, 7);
        float timeWidth = Fonts.BOLD.getWidth(time, 7);
        float tpsNumberWidth = Fonts.BOLD.getWidth(tpsNumber, 7);
        float tpsTextWidth = Fonts.BOLD.getWidth(tpsText, 7);

        float gap = 5f;
        float separatorWidth = Fonts.TEST.getWidth("»", 8);
        float iconTextGap = 3f;

        float contentWidth = 20 + clientNameWidth + gap + separatorWidth + gap +
                10 + fpsNumberWidth + 2 + fpsTextWidth + gap + separatorWidth + gap +
                10 + timeWidth + 4;

        if (showTps) {
            contentWidth += gap + separatorWidth + gap + 10 + tpsNumberWidth + 2 + tpsTextWidth + 4;
        }

        setWidth((int) contentWidth);
        setHeight(22);

        Render2D.blur(x - 2, y - 1, contentWidth + 4, 24, 12f, CORNER_RADIUS + 2, withAlpha(0xAA000000, alpha));

        int[] gradientColors = {
                withAlpha(0xFF252525, alpha),
                withAlpha(0xFF151515, alpha),
                withAlpha(0xFF151515, alpha),
                withAlpha(0xFF252525, alpha)
        };
        Render2D.gradientRect(x, y, contentWidth, 22, gradientColors, CORNER_RADIUS);

        Render2D.outline(x, y, contentWidth, 22, 1f, withAlpha(0x33FFFFFF, alpha), CORNER_RADIUS);

        float textY = y + 6;
        float offsetX = x + 5;

        Fonts.ICONS.draw("A", offsetX, textY - 1, 12, withAlpha(0xFFFFFFFF, alpha));offsetX += 13;
        Fonts.BOLD.draw(clientName, offsetX, textY + 1, 7, withAlpha(0xFFFFFFFF, alpha));offsetX += clientNameWidth + gap;
        Fonts.TEST.draw("»", offsetX, textY, 8, withAlpha(0x88FFFFFF, alpha));offsetX += separatorWidth + gap;

        Fonts.CATEGORY_ICONS.draw("b", offsetX, textY, 9, withAlpha(0xFFE0E0E0, alpha));offsetX += 9 + iconTextGap;

        drawAnimatedTextPerChar(fpsNumber, oldFps, offsetX, textY + 1, 7, fpsAnimation, alpha);offsetX += fpsNumberWidth + 2;
        Fonts.BOLD.draw(fpsText, offsetX, textY + 1, 7, withAlpha(0xAAFFFFFF, alpha));offsetX += fpsTextWidth + gap;
        Fonts.TEST.draw("»", offsetX, textY, 8, withAlpha(0x88FFFFFF, alpha));offsetX += separatorWidth + gap;

        Fonts.CATEGORY_ICONS.draw("n", offsetX, textY, 9, withAlpha(0xFFE0E0E0, alpha));offsetX += 9 + iconTextGap;

        drawAnimatedTextPerChar(time, oldTime, offsetX, textY + 1, 7, timeAnimation, alpha);offsetX += timeWidth + gap;

        if (showTps) {
            Fonts.TEST.draw("»", offsetX, textY, 8, withAlpha(0x88FFFFFF, alpha));offsetX += separatorWidth + gap;

            Fonts.ICONSTYPETHO.draw("t", offsetX, textY - 1, 10, withAlpha(0xFFE0E0E0, alpha));offsetX += 10 + iconTextGap;

            drawAnimatedTextPerChar(tpsNumber, oldTps, offsetX, textY + 1, 7, tpsAnimation, alpha);offsetX += tpsNumberWidth + 2;
            Fonts.BOLD.draw(tpsText, offsetX, textY + 1, 7, withAlpha(0xAAFFFFFF, alpha));
        }
    }

    private void drawAnimatedTextPerChar(String newText, String oldText, float x, float y, float size, float progress, int masterAlpha) {
        if (oldText.isEmpty() || progress >= 1.0f) {
            Fonts.BOLD.draw(newText, x, y, size, withAlpha(0xFFFFFFFF, masterAlpha));
            return;
        }

        float offsetX = x;
        int maxLen = Math.max(newText.length(), oldText.length());

        String paddedNew = padLeft(newText, maxLen);
        String paddedOld = padLeft(oldText, maxLen);

        for (int i = 0; i < paddedNew.length(); i++) {
            char newChar = paddedNew.charAt(i);
            char oldChar = paddedOld.charAt(i);

            if (newChar == ' ' && oldChar == ' ') continue;

            float charWidth = Fonts.BOLD.getWidth(String.valueOf(newChar != ' ' ? newChar : oldChar), size);

            boolean isNewDigit = Character.isDigit(newChar) || newChar == '.';
            boolean isOldDigit = Character.isDigit(oldChar) || oldChar == '.';
            boolean hasChanged = newChar != oldChar;

            if (!hasChanged || (!isNewDigit && !isOldDigit)) {
                if (newChar != ' ') {
                    Fonts.BOLD.draw(String.valueOf(newChar), offsetX, y, size, withAlpha(0xFFFFFFFF, masterAlpha));
                }
            } else {
                float easedProgress = easeOutCubic(progress);

                if (oldChar != ' ' && isOldDigit) {
                    float oldAlpha = 1.0f - easedProgress;
                    float oldOffsetY = easedProgress * ANIMATION_OFFSET;
                    int oldAlphaClamped = clampAlpha(oldAlpha * (masterAlpha / 255f));
                    if (oldAlphaClamped > 0) {
                        Fonts.BOLD.draw(String.valueOf(oldChar), offsetX, y + oldOffsetY, size, withAlpha(0xFFFFFF, oldAlphaClamped));
                    }
                }

                if (newChar != ' ' && isNewDigit) {
                    float newAlpha = easedProgress;
                    float newOffsetY = (1.0f - easedProgress) * -ANIMATION_OFFSET;
                    int newAlphaClamped = clampAlpha(newAlpha * (masterAlpha / 255f));
                    if (newAlphaClamped > 0) {
                        Fonts.BOLD.draw(String.valueOf(newChar), offsetX, y + newOffsetY, size, withAlpha(0xFFFFFF, newAlphaClamped));
                    }
                }
            }

            if (newChar != ' ') offsetX += charWidth;
        }
    }

    private String padLeft(String text, int length) {
        if (text.length() >= length) return text;
        return " ".repeat(length - text.length()) + text;
    }

    private float easeOutCubic(float t) {
        return 1.0f - (float) Math.pow(1.0 - t, 3);
    }

    private int withAlpha(int color, int alpha) {
        return (color & 0x00FFFFFF) | (MathHelper.clamp(alpha, 0, 255) << 24);
    }
}
 
float clientNameWidth = Fonts.BOLD.getWidth(clientName, 7); float fpsNumberWidth = Fonts.BOLD.getWidth(fpsNumber, 7); float fpsTextWidth = Fonts.BOLD.getWidth(fpsText, 7); float timeWidth = Fonts.BOLD.getWidth(time, 7); float tpsNumberWidth = Fonts.BOLD.getWidth(tpsNumber, 7); float tpsTextWidth = Fonts.BOLD.getWidth(tpsText, 7);
я тебя услышал родной
 
SS
Посмотреть вложение 327507
Code


Watermark:
Expand Collapse Copy
package rich.screens.hud;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.util.math.MathHelper;
import rich.client.draggables.AbstractHudElement;
import rich.modules.impl.render.Hud;
import rich.util.render.Render2D;
import rich.util.render.font.Fonts;
import rich.util.tps.TPSCalculate;

import java.awt.*;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

public class Watermark extends AbstractHudElement {

    private String lastFps = "";
    private String oldFps = "";
    private long fpsAnimationStart = 0;

    private String lastTime = "";
    private String oldTime = "";
    private long timeAnimationStart = 0;

    private String lastTps = "";
    private String oldTps = "";
    private long tpsAnimationStart = 0;

    private static final long ANIMATION_DURATION = 200;
    private static final float ANIMATION_OFFSET = 8.0f;
    private static final float CORNER_RADIUS = 6f;

    public Watermark() {
        super("Watermark", 10, 10, 200, 22, false);
    }

    @Override
    public void tick() {}

    private int clampAlpha(float alpha) {
        return Math.max(0, Math.min(255, (int) (alpha * 255)));
    }

    @Override
    public void drawDraggable(DrawContext context, int alpha) {
        if (alpha <= 0) return;

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

        String clientName = "Anolix Client";
        String fpsNumber = String.valueOf(mc.getCurrentFps());
        String fpsText = "fps";
        String time = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm"));

        boolean showTps = Hud.getInstance() != null && Hud.getInstance().showTps.isValue();

        float tpsValue = 20.0f;
        if (TPSCalculate.getInstance() != null) {
            tpsValue = TPSCalculate.getInstance().getTpsRounded();
        }
        String tpsNumber = String.format("%.1f", tpsValue);
        String tpsText = "tps ";

        long currentTime = System.currentTimeMillis();

        if (!fpsNumber.equals(lastFps)) {
            oldFps = lastFps;
            lastFps = fpsNumber;
            fpsAnimationStart = currentTime;
        }

        if (!time.equals(lastTime)) {
            oldTime = lastTime;
            lastTime = time;
            timeAnimationStart = currentTime;
        }

        if (!tpsNumber.equals(lastTps)) {
            oldTps = lastTps;
            lastTps = tpsNumber;
            tpsAnimationStart = currentTime;
        }

        float fpsAnimation = Math.min(1.0f, (currentTime - fpsAnimationStart) / (float) ANIMATION_DURATION);
        float timeAnimation = Math.min(1.0f, (currentTime - timeAnimationStart) / (float) ANIMATION_DURATION);
        float tpsAnimation = Math.min(1.0f, (currentTime - tpsAnimationStart) / (float) ANIMATION_DURATION);

        float clientNameWidth = Fonts.BOLD.getWidth(clientName, 7);
        float fpsNumberWidth = Fonts.BOLD.getWidth(fpsNumber, 7);
        float fpsTextWidth = Fonts.BOLD.getWidth(fpsText, 7);
        float timeWidth = Fonts.BOLD.getWidth(time, 7);
        float tpsNumberWidth = Fonts.BOLD.getWidth(tpsNumber, 7);
        float tpsTextWidth = Fonts.BOLD.getWidth(tpsText, 7);

        float gap = 5f;
        float separatorWidth = Fonts.TEST.getWidth("»", 8);
        float iconTextGap = 3f;

        float contentWidth = 20 + clientNameWidth + gap + separatorWidth + gap +
                10 + fpsNumberWidth + 2 + fpsTextWidth + gap + separatorWidth + gap +
                10 + timeWidth + 4;

        if (showTps) {
            contentWidth += gap + separatorWidth + gap + 10 + tpsNumberWidth + 2 + tpsTextWidth + 4;
        }

        setWidth((int) contentWidth);
        setHeight(22);

        Render2D.blur(x - 2, y - 1, contentWidth + 4, 24, 12f, CORNER_RADIUS + 2, withAlpha(0xAA000000, alpha));

        int[] gradientColors = {
                withAlpha(0xFF252525, alpha),
                withAlpha(0xFF151515, alpha),
                withAlpha(0xFF151515, alpha),
                withAlpha(0xFF252525, alpha)
        };
        Render2D.gradientRect(x, y, contentWidth, 22, gradientColors, CORNER_RADIUS);

        Render2D.outline(x, y, contentWidth, 22, 1f, withAlpha(0x33FFFFFF, alpha), CORNER_RADIUS);

        float textY = y + 6;
        float offsetX = x + 5;

        Fonts.ICONS.draw("A", offsetX, textY - 1, 12, withAlpha(0xFFFFFFFF, alpha));offsetX += 13;
        Fonts.BOLD.draw(clientName, offsetX, textY + 1, 7, withAlpha(0xFFFFFFFF, alpha));offsetX += clientNameWidth + gap;
        Fonts.TEST.draw("»", offsetX, textY, 8, withAlpha(0x88FFFFFF, alpha));offsetX += separatorWidth + gap;

        Fonts.CATEGORY_ICONS.draw("b", offsetX, textY, 9, withAlpha(0xFFE0E0E0, alpha));offsetX += 9 + iconTextGap;

        drawAnimatedTextPerChar(fpsNumber, oldFps, offsetX, textY + 1, 7, fpsAnimation, alpha);offsetX += fpsNumberWidth + 2;
        Fonts.BOLD.draw(fpsText, offsetX, textY + 1, 7, withAlpha(0xAAFFFFFF, alpha));offsetX += fpsTextWidth + gap;
        Fonts.TEST.draw("»", offsetX, textY, 8, withAlpha(0x88FFFFFF, alpha));offsetX += separatorWidth + gap;

        Fonts.CATEGORY_ICONS.draw("n", offsetX, textY, 9, withAlpha(0xFFE0E0E0, alpha));offsetX += 9 + iconTextGap;

        drawAnimatedTextPerChar(time, oldTime, offsetX, textY + 1, 7, timeAnimation, alpha);offsetX += timeWidth + gap;

        if (showTps) {
            Fonts.TEST.draw("»", offsetX, textY, 8, withAlpha(0x88FFFFFF, alpha));offsetX += separatorWidth + gap;

            Fonts.ICONSTYPETHO.draw("t", offsetX, textY - 1, 10, withAlpha(0xFFE0E0E0, alpha));offsetX += 10 + iconTextGap;

            drawAnimatedTextPerChar(tpsNumber, oldTps, offsetX, textY + 1, 7, tpsAnimation, alpha);offsetX += tpsNumberWidth + 2;
            Fonts.BOLD.draw(tpsText, offsetX, textY + 1, 7, withAlpha(0xAAFFFFFF, alpha));
        }
    }

    private void drawAnimatedTextPerChar(String newText, String oldText, float x, float y, float size, float progress, int masterAlpha) {
        if (oldText.isEmpty() || progress >= 1.0f) {
            Fonts.BOLD.draw(newText, x, y, size, withAlpha(0xFFFFFFFF, masterAlpha));
            return;
        }

        float offsetX = x;
        int maxLen = Math.max(newText.length(), oldText.length());

        String paddedNew = padLeft(newText, maxLen);
        String paddedOld = padLeft(oldText, maxLen);

        for (int i = 0; i < paddedNew.length(); i++) {
            char newChar = paddedNew.charAt(i);
            char oldChar = paddedOld.charAt(i);

            if (newChar == ' ' && oldChar == ' ') continue;

            float charWidth = Fonts.BOLD.getWidth(String.valueOf(newChar != ' ' ? newChar : oldChar), size);

            boolean isNewDigit = Character.isDigit(newChar) || newChar == '.';
            boolean isOldDigit = Character.isDigit(oldChar) || oldChar == '.';
            boolean hasChanged = newChar != oldChar;

            if (!hasChanged || (!isNewDigit && !isOldDigit)) {
                if (newChar != ' ') {
                    Fonts.BOLD.draw(String.valueOf(newChar), offsetX, y, size, withAlpha(0xFFFFFFFF, masterAlpha));
                }
            } else {
                float easedProgress = easeOutCubic(progress);

                if (oldChar != ' ' && isOldDigit) {
                    float oldAlpha = 1.0f - easedProgress;
                    float oldOffsetY = easedProgress * ANIMATION_OFFSET;
                    int oldAlphaClamped = clampAlpha(oldAlpha * (masterAlpha / 255f));
                    if (oldAlphaClamped > 0) {
                        Fonts.BOLD.draw(String.valueOf(oldChar), offsetX, y + oldOffsetY, size, withAlpha(0xFFFFFF, oldAlphaClamped));
                    }
                }

                if (newChar != ' ' && isNewDigit) {
                    float newAlpha = easedProgress;
                    float newOffsetY = (1.0f - easedProgress) * -ANIMATION_OFFSET;
                    int newAlphaClamped = clampAlpha(newAlpha * (masterAlpha / 255f));
                    if (newAlphaClamped > 0) {
                        Fonts.BOLD.draw(String.valueOf(newChar), offsetX, y + newOffsetY, size, withAlpha(0xFFFFFF, newAlphaClamped));
                    }
                }
            }

            if (newChar != ' ') offsetX += charWidth;
        }
    }

    private String padLeft(String text, int length) {
        if (text.length() >= length) return text;
        return " ".repeat(length - text.length()) + text;
    }

    private float easeOutCubic(float t) {
        return 1.0f - (float) Math.pow(1.0 - t, 3);
    }

    private int withAlpha(int color, int alpha) {
        return (color & 0x00FFFFFF) | (MathHelper.clamp(alpha, 0, 255) << 24);
    }
}
Какая же параша, может ты хоть когда то над своими вотермарками больше 5 минут поработаешь без джпт? /del
 
SS
Посмотреть вложение 327507
Code


Watermark:
Expand Collapse Copy
package rich.screens.hud;

import net.minecraft.client.gui.DrawContext;
import net.minecraft.util.math.MathHelper;
import rich.client.draggables.AbstractHudElement;
import rich.modules.impl.render.Hud;
import rich.util.render.Render2D;
import rich.util.render.font.Fonts;
import rich.util.tps.TPSCalculate;

import java.awt.*;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

public class Watermark extends AbstractHudElement {

    private String lastFps = "";
    private String oldFps = "";
    private long fpsAnimationStart = 0;

    private String lastTime = "";
    private String oldTime = "";
    private long timeAnimationStart = 0;

    private String lastTps = "";
    private String oldTps = "";
    private long tpsAnimationStart = 0;

    private static final long ANIMATION_DURATION = 200;
    private static final float ANIMATION_OFFSET = 8.0f;
    private static final float CORNER_RADIUS = 6f;

    public Watermark() {
        super("Watermark", 10, 10, 200, 22, false);
    }

    @Override
    public void tick() {}

    private int clampAlpha(float alpha) {
        return Math.max(0, Math.min(255, (int) (alpha * 255)));
    }

    @Override
    public void drawDraggable(DrawContext context, int alpha) {
        if (alpha <= 0) return;

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

        String clientName = "Anolix Client";
        String fpsNumber = String.valueOf(mc.getCurrentFps());
        String fpsText = "fps";
        String time = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm"));

        boolean showTps = Hud.getInstance() != null && Hud.getInstance().showTps.isValue();

        float tpsValue = 20.0f;
        if (TPSCalculate.getInstance() != null) {
            tpsValue = TPSCalculate.getInstance().getTpsRounded();
        }
        String tpsNumber = String.format("%.1f", tpsValue);
        String tpsText = "tps ";

        long currentTime = System.currentTimeMillis();

        if (!fpsNumber.equals(lastFps)) {
            oldFps = lastFps;
            lastFps = fpsNumber;
            fpsAnimationStart = currentTime;
        }

        if (!time.equals(lastTime)) {
            oldTime = lastTime;
            lastTime = time;
            timeAnimationStart = currentTime;
        }

        if (!tpsNumber.equals(lastTps)) {
            oldTps = lastTps;
            lastTps = tpsNumber;
            tpsAnimationStart = currentTime;
        }

        float fpsAnimation = Math.min(1.0f, (currentTime - fpsAnimationStart) / (float) ANIMATION_DURATION);
        float timeAnimation = Math.min(1.0f, (currentTime - timeAnimationStart) / (float) ANIMATION_DURATION);
        float tpsAnimation = Math.min(1.0f, (currentTime - tpsAnimationStart) / (float) ANIMATION_DURATION);

        float clientNameWidth = Fonts.BOLD.getWidth(clientName, 7);
        float fpsNumberWidth = Fonts.BOLD.getWidth(fpsNumber, 7);
        float fpsTextWidth = Fonts.BOLD.getWidth(fpsText, 7);
        float timeWidth = Fonts.BOLD.getWidth(time, 7);
        float tpsNumberWidth = Fonts.BOLD.getWidth(tpsNumber, 7);
        float tpsTextWidth = Fonts.BOLD.getWidth(tpsText, 7);

        float gap = 5f;
        float separatorWidth = Fonts.TEST.getWidth("»", 8);
        float iconTextGap = 3f;

        float contentWidth = 20 + clientNameWidth + gap + separatorWidth + gap +
                10 + fpsNumberWidth + 2 + fpsTextWidth + gap + separatorWidth + gap +
                10 + timeWidth + 4;

        if (showTps) {
            contentWidth += gap + separatorWidth + gap + 10 + tpsNumberWidth + 2 + tpsTextWidth + 4;
        }

        setWidth((int) contentWidth);
        setHeight(22);

        Render2D.blur(x - 2, y - 1, contentWidth + 4, 24, 12f, CORNER_RADIUS + 2, withAlpha(0xAA000000, alpha));

        int[] gradientColors = {
                withAlpha(0xFF252525, alpha),
                withAlpha(0xFF151515, alpha),
                withAlpha(0xFF151515, alpha),
                withAlpha(0xFF252525, alpha)
        };
        Render2D.gradientRect(x, y, contentWidth, 22, gradientColors, CORNER_RADIUS);

        Render2D.outline(x, y, contentWidth, 22, 1f, withAlpha(0x33FFFFFF, alpha), CORNER_RADIUS);

        float textY = y + 6;
        float offsetX = x + 5;

        Fonts.ICONS.draw("A", offsetX, textY - 1, 12, withAlpha(0xFFFFFFFF, alpha));offsetX += 13;
        Fonts.BOLD.draw(clientName, offsetX, textY + 1, 7, withAlpha(0xFFFFFFFF, alpha));offsetX += clientNameWidth + gap;
        Fonts.TEST.draw("»", offsetX, textY, 8, withAlpha(0x88FFFFFF, alpha));offsetX += separatorWidth + gap;

        Fonts.CATEGORY_ICONS.draw("b", offsetX, textY, 9, withAlpha(0xFFE0E0E0, alpha));offsetX += 9 + iconTextGap;

        drawAnimatedTextPerChar(fpsNumber, oldFps, offsetX, textY + 1, 7, fpsAnimation, alpha);offsetX += fpsNumberWidth + 2;
        Fonts.BOLD.draw(fpsText, offsetX, textY + 1, 7, withAlpha(0xAAFFFFFF, alpha));offsetX += fpsTextWidth + gap;
        Fonts.TEST.draw("»", offsetX, textY, 8, withAlpha(0x88FFFFFF, alpha));offsetX += separatorWidth + gap;

        Fonts.CATEGORY_ICONS.draw("n", offsetX, textY, 9, withAlpha(0xFFE0E0E0, alpha));offsetX += 9 + iconTextGap;

        drawAnimatedTextPerChar(time, oldTime, offsetX, textY + 1, 7, timeAnimation, alpha);offsetX += timeWidth + gap;

        if (showTps) {
            Fonts.TEST.draw("»", offsetX, textY, 8, withAlpha(0x88FFFFFF, alpha));offsetX += separatorWidth + gap;

            Fonts.ICONSTYPETHO.draw("t", offsetX, textY - 1, 10, withAlpha(0xFFE0E0E0, alpha));offsetX += 10 + iconTextGap;

            drawAnimatedTextPerChar(tpsNumber, oldTps, offsetX, textY + 1, 7, tpsAnimation, alpha);offsetX += tpsNumberWidth + 2;
            Fonts.BOLD.draw(tpsText, offsetX, textY + 1, 7, withAlpha(0xAAFFFFFF, alpha));
        }
    }

    private void drawAnimatedTextPerChar(String newText, String oldText, float x, float y, float size, float progress, int masterAlpha) {
        if (oldText.isEmpty() || progress >= 1.0f) {
            Fonts.BOLD.draw(newText, x, y, size, withAlpha(0xFFFFFFFF, masterAlpha));
            return;
        }

        float offsetX = x;
        int maxLen = Math.max(newText.length(), oldText.length());

        String paddedNew = padLeft(newText, maxLen);
        String paddedOld = padLeft(oldText, maxLen);

        for (int i = 0; i < paddedNew.length(); i++) {
            char newChar = paddedNew.charAt(i);
            char oldChar = paddedOld.charAt(i);

            if (newChar == ' ' && oldChar == ' ') continue;

            float charWidth = Fonts.BOLD.getWidth(String.valueOf(newChar != ' ' ? newChar : oldChar), size);

            boolean isNewDigit = Character.isDigit(newChar) || newChar == '.';
            boolean isOldDigit = Character.isDigit(oldChar) || oldChar == '.';
            boolean hasChanged = newChar != oldChar;

            if (!hasChanged || (!isNewDigit && !isOldDigit)) {
                if (newChar != ' ') {
                    Fonts.BOLD.draw(String.valueOf(newChar), offsetX, y, size, withAlpha(0xFFFFFFFF, masterAlpha));
                }
            } else {
                float easedProgress = easeOutCubic(progress);

                if (oldChar != ' ' && isOldDigit) {
                    float oldAlpha = 1.0f - easedProgress;
                    float oldOffsetY = easedProgress * ANIMATION_OFFSET;
                    int oldAlphaClamped = clampAlpha(oldAlpha * (masterAlpha / 255f));
                    if (oldAlphaClamped > 0) {
                        Fonts.BOLD.draw(String.valueOf(oldChar), offsetX, y + oldOffsetY, size, withAlpha(0xFFFFFF, oldAlphaClamped));
                    }
                }

                if (newChar != ' ' && isNewDigit) {
                    float newAlpha = easedProgress;
                    float newOffsetY = (1.0f - easedProgress) * -ANIMATION_OFFSET;
                    int newAlphaClamped = clampAlpha(newAlpha * (masterAlpha / 255f));
                    if (newAlphaClamped > 0) {
                        Fonts.BOLD.draw(String.valueOf(newChar), offsetX, y + newOffsetY, size, withAlpha(0xFFFFFF, newAlphaClamped));
                    }
                }
            }

            if (newChar != ' ') offsetX += charWidth;
        }
    }

    private String padLeft(String text, int length) {
        if (text.length() >= length) return text;
        return " ".repeat(length - text.length()) + text;
    }

    private float easeOutCubic(float t) {
        return 1.0f - (float) Math.pow(1.0 - t, 3);
    }

    private int withAlpha(int color, int alpha) {
        return (color & 0x00FFFFFF) | (MathHelper.clamp(alpha, 0, 255) << 24);
    }
}
дерьмо ебанное
 
Назад
Сверху Снизу