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

Визуальная часть Watermark 1.21.8 Fabric

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
3 Ноя 2025
Сообщения
6
Реакции
0
Выберите загрузчик игры
  1. Fabric
Слам, YouGame, решил залить свою ватермарку. Хотел сделать красивую, а получилось дерьмо
не знаю, кому нужно. Делал на какой-то нн-базе с рендером.
1775316643774.png

watermark:
Expand Collapse Copy
package com.ferrion.overlay;

import com.ferrion.gui.ClickGUI;
import com.ferrion.render.ColorRGBA;
import com.ferrion.render.Ferrion2D;
import com.ferrion.render.font.TtfFont;
import net.minecraft.client.MinecraftClient;

public final class Watermark {
    private static final MinecraftClient mc = MinecraftClient.getInstance();
    private static final ColorRGBA COLOR_WHITE = ColorRGBA.rgba(255, 255, 255, 255);
    private static final ColorRGBA COLOR_LAVENDER = ColorRGBA.rgba(200, 162, 200, 255);
    private static final ColorRGBA COLOR_GRAY = ColorRGBA.rgba(150, 150, 150, 255);
    private static final float WATERMARK_RADIUS = 8f;
    private static final float WATERMARK_BLUR_RADIUS = 10f;
    private static final float WATERMARK_PADDING = 8f;
    private static final float WATERMARK_FONT_SIZE = 7.5f;
    private static final float WATERMARK_HEIGHT = 26f;
    private static final float WATERMARK_SPACING = 8f;
    private static final String FONT_PATH = "ferrion/fonts/opnsans.ttf";
    private static TtfFont cachedFont = null;

    private Watermark() {
    }

    public static void render(float x, float y, String text, int ping, int fps) {
        float hudAlpha = ClickGUI.getHudAlpha();
        if (hudAlpha < 0.01f) {
            return;
        }

        String username = mc.getSession().getUsername();
        String fpsText = String.valueOf(fps);
        String msText = String.valueOf(ping);
        boolean hasBossBar = false;
        try {
            var bossBarHud = mc.inGameHud.getBossBarHud();
            var bossBarsField = bossBarHud.getClass().getDeclaredField("bossBars");
            bossBarsField.setAccessible(true);
            var bossBars = (java.util.Map<?, ?>) bossBarsField.get(bossBarHud);
            hasBossBar = !bossBars.isEmpty();
        } catch (Exception e) {
            hasBossBar = false;
        }

        float bossBarOffset = hasBossBar ? 20f : 0f;
        float posY = 10f + bossBarOffset;
        float guiSlideDistance = 20f;
        float guiSlideOffset = -guiSlideDistance * (1.0f - hudAlpha);
        if (hudAlpha > 0.01f) {
            renderWatermark(posY + guiSlideOffset, hudAlpha, username, fpsText, msText);
        }
    }

    private static void renderWatermark(float y, float alpha, String username, String fpsText, String msText) {
        float ferrionWidth = calculateTextWidth("FERRION");
        float usernameWidth = calculateTextWidth(username);
        float fpsNumWidth = calculateTextWidth(fpsText);
        float fpsTextWidth = calculateTextWidth("fps");
        float msNumWidth = calculateTextWidth(msText);
        float msTextWidth = calculateTextWidth("mc");

        float totalWidth = WATERMARK_PADDING + ferrionWidth + WATERMARK_SPACING + usernameWidth +
                WATERMARK_SPACING + fpsNumWidth + fpsTextWidth + WATERMARK_SPACING +
                msNumWidth + msTextWidth + WATERMARK_PADDING;

        float screenWidth = Ferrion2D.width();
        float centerX = (screenWidth - totalWidth) / 2f;
        int bgAlpha = (int) (200 * alpha);
        Ferrion2D.blurredRoundedRect(centerX, y, totalWidth, WATERMARK_HEIGHT,
                WATERMARK_RADIUS, WATERMARK_BLUR_RADIUS,
                ColorRGBA.rgba(29, 29, 39, bgAlpha));

        int gradientAlpha = (int) (255 * alpha);
        Ferrion2D.roundedRectGradient(centerX, y, totalWidth, WATERMARK_HEIGHT, WATERMARK_RADIUS,
                ColorRGBA.rgba(29, 29, 39, gradientAlpha),
                ColorRGBA.rgba(0, 0, 0, gradientAlpha));
        float textY = y + (WATERMARK_HEIGHT - WATERMARK_FONT_SIZE) / 2f - 0.5f;
        float currentX = centerX + WATERMARK_PADDING;
        currentX += drawStaticText("FERRION", currentX, textY, WATERMARK_FONT_SIZE, alpha);
        currentX += WATERMARK_SPACING;
        drawDivider(currentX - WATERMARK_SPACING / 2f - 1f, y, WATERMARK_HEIGHT, alpha);
        Ferrion2D.text(username, currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_WHITE, alpha));
        currentX += usernameWidth + WATERMARK_SPACING;
        drawDivider(currentX - WATERMARK_SPACING / 2f - 1f, y, WATERMARK_HEIGHT, alpha);
        Ferrion2D.text(fpsText, currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_WHITE, alpha));
        currentX += fpsNumWidth;
        Ferrion2D.text("fps", currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_LAVENDER, alpha));
        currentX += fpsTextWidth + WATERMARK_SPACING;
        drawDivider(currentX - WATERMARK_SPACING / 2f - 1f, y, WATERMARK_HEIGHT, alpha);
        Ferrion2D.text(msText, currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_WHITE, alpha));
        currentX += msNumWidth;
        Ferrion2D.text("mc", currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_LAVENDER, alpha));
    }
    
    private static void drawDivider(float x, float y, float height, float alpha) {
        float dividerHeight = height - 12f;
        float dividerY = y + 6f;
        float dividerWidth = 1.5f;
        
        Ferrion2D.roundedRect(x, dividerY, dividerWidth, dividerHeight, 0.75f,
                applyAlpha(ColorRGBA.rgba(80, 80, 90, 255), alpha * 0.4f));
    }

    private static float drawStaticText(String text, float x, float y, float size, float alpha) {
        float currentX = x;
        TtfFont font = getFont();
        ColorRGBA color = applyAlpha(COLOR_LAVENDER, alpha);
        for (int i = 0; i < text.length(); i++) {
            char c = text.charAt(i);
            Ferrion2D.text(String.valueOf(c), currentX, y, size, color);
            var glyph = font.glyph(c);
            currentX += glyph.xadvance();
        }
        return calculateTextWidth(text);
    }

    private static ColorRGBA applyAlpha(ColorRGBA color, float alpha) {
        int a = (int) (color.a() * 255 * alpha);
        return ColorRGBA.rgba((int)(color.r() * 255), (int)(color.g() * 255),
                (int)(color.b() * 255), a);
    }

    private static float calculateTextWidth(String text) {
        TtfFont font = getFont();
        float width = 0f;
        for (int i = 0; i < text.length(); i++) {
            char c = text.charAt(i);
            var glyph = font.glyph(c);
            width += glyph.xadvance();
        }
        return width;
    }

    private static TtfFont getFont() {
        if (cachedFont == null) {
            int pixelHeight = Math.max(8, Math.round(WATERMARK_FONT_SIZE));
            cachedFont = TtfFont.fromResource(FONT_PATH, pixelHeight);
        }
        return cachedFont;
    }
}
надеюсь одобрят?
 
Слам, YouGame, решил залить свою ватермарку. Хотел сделать красивую, а получилось дерьмо
не знаю, кому нужно. Делал на какой-то нн-базе с рендером.

Посмотреть вложение 332324
watermark:
Expand Collapse Copy
package com.ferrion.overlay;

import com.ferrion.gui.ClickGUI;
import com.ferrion.render.ColorRGBA;
import com.ferrion.render.Ferrion2D;
import com.ferrion.render.font.TtfFont;
import net.minecraft.client.MinecraftClient;

public final class Watermark {
    private static final MinecraftClient mc = MinecraftClient.getInstance();
    private static final ColorRGBA COLOR_WHITE = ColorRGBA.rgba(255, 255, 255, 255);
    private static final ColorRGBA COLOR_LAVENDER = ColorRGBA.rgba(200, 162, 200, 255);
    private static final ColorRGBA COLOR_GRAY = ColorRGBA.rgba(150, 150, 150, 255);
    private static final float WATERMARK_RADIUS = 8f;
    private static final float WATERMARK_BLUR_RADIUS = 10f;
    private static final float WATERMARK_PADDING = 8f;
    private static final float WATERMARK_FONT_SIZE = 7.5f;
    private static final float WATERMARK_HEIGHT = 26f;
    private static final float WATERMARK_SPACING = 8f;
    private static final String FONT_PATH = "ferrion/fonts/opnsans.ttf";
    private static TtfFont cachedFont = null;

    private Watermark() {
    }

    public static void render(float x, float y, String text, int ping, int fps) {
        float hudAlpha = ClickGUI.getHudAlpha();
        if (hudAlpha < 0.01f) {
            return;
        }

        String username = mc.getSession().getUsername();
        String fpsText = String.valueOf(fps);
        String msText = String.valueOf(ping);
        boolean hasBossBar = false;
        try {
            var bossBarHud = mc.inGameHud.getBossBarHud();
            var bossBarsField = bossBarHud.getClass().getDeclaredField("bossBars");
            bossBarsField.setAccessible(true);
            var bossBars = (java.util.Map<?, ?>) bossBarsField.get(bossBarHud);
            hasBossBar = !bossBars.isEmpty();
        } catch (Exception e) {
            hasBossBar = false;
        }

        float bossBarOffset = hasBossBar ? 20f : 0f;
        float posY = 10f + bossBarOffset;
        float guiSlideDistance = 20f;
        float guiSlideOffset = -guiSlideDistance * (1.0f - hudAlpha);
        if (hudAlpha > 0.01f) {
            renderWatermark(posY + guiSlideOffset, hudAlpha, username, fpsText, msText);
        }
    }

    private static void renderWatermark(float y, float alpha, String username, String fpsText, String msText) {
        float ferrionWidth = calculateTextWidth("FERRION");
        float usernameWidth = calculateTextWidth(username);
        float fpsNumWidth = calculateTextWidth(fpsText);
        float fpsTextWidth = calculateTextWidth("fps");
        float msNumWidth = calculateTextWidth(msText);
        float msTextWidth = calculateTextWidth("mc");

        float totalWidth = WATERMARK_PADDING + ferrionWidth + WATERMARK_SPACING + usernameWidth +
                WATERMARK_SPACING + fpsNumWidth + fpsTextWidth + WATERMARK_SPACING +
                msNumWidth + msTextWidth + WATERMARK_PADDING;

        float screenWidth = Ferrion2D.width();
        float centerX = (screenWidth - totalWidth) / 2f;
        int bgAlpha = (int) (200 * alpha);
        Ferrion2D.blurredRoundedRect(centerX, y, totalWidth, WATERMARK_HEIGHT,
                WATERMARK_RADIUS, WATERMARK_BLUR_RADIUS,
                ColorRGBA.rgba(29, 29, 39, bgAlpha));

        int gradientAlpha = (int) (255 * alpha);
        Ferrion2D.roundedRectGradient(centerX, y, totalWidth, WATERMARK_HEIGHT, WATERMARK_RADIUS,
                ColorRGBA.rgba(29, 29, 39, gradientAlpha),
                ColorRGBA.rgba(0, 0, 0, gradientAlpha));
        float textY = y + (WATERMARK_HEIGHT - WATERMARK_FONT_SIZE) / 2f - 0.5f;
        float currentX = centerX + WATERMARK_PADDING;
        currentX += drawStaticText("FERRION", currentX, textY, WATERMARK_FONT_SIZE, alpha);
        currentX += WATERMARK_SPACING;
        drawDivider(currentX - WATERMARK_SPACING / 2f - 1f, y, WATERMARK_HEIGHT, alpha);
        Ferrion2D.text(username, currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_WHITE, alpha));
        currentX += usernameWidth + WATERMARK_SPACING;
        drawDivider(currentX - WATERMARK_SPACING / 2f - 1f, y, WATERMARK_HEIGHT, alpha);
        Ferrion2D.text(fpsText, currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_WHITE, alpha));
        currentX += fpsNumWidth;
        Ferrion2D.text("fps", currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_LAVENDER, alpha));
        currentX += fpsTextWidth + WATERMARK_SPACING;
        drawDivider(currentX - WATERMARK_SPACING / 2f - 1f, y, WATERMARK_HEIGHT, alpha);
        Ferrion2D.text(msText, currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_WHITE, alpha));
        currentX += msNumWidth;
        Ferrion2D.text("mc", currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_LAVENDER, alpha));
    }
   
    private static void drawDivider(float x, float y, float height, float alpha) {
        float dividerHeight = height - 12f;
        float dividerY = y + 6f;
        float dividerWidth = 1.5f;
       
        Ferrion2D.roundedRect(x, dividerY, dividerWidth, dividerHeight, 0.75f,
                applyAlpha(ColorRGBA.rgba(80, 80, 90, 255), alpha * 0.4f));
    }

    private static float drawStaticText(String text, float x, float y, float size, float alpha) {
        float currentX = x;
        TtfFont font = getFont();
        ColorRGBA color = applyAlpha(COLOR_LAVENDER, alpha);
        for (int i = 0; i < text.length(); i++) {
            char c = text.charAt(i);
            Ferrion2D.text(String.valueOf(c), currentX, y, size, color);
            var glyph = font.glyph(c);
            currentX += glyph.xadvance();
        }
        return calculateTextWidth(text);
    }

    private static ColorRGBA applyAlpha(ColorRGBA color, float alpha) {
        int a = (int) (color.a() * 255 * alpha);
        return ColorRGBA.rgba((int)(color.r() * 255), (int)(color.g() * 255),
                (int)(color.b() * 255), a);
    }

    private static float calculateTextWidth(String text) {
        TtfFont font = getFont();
        float width = 0f;
        for (int i = 0; i < text.length(); i++) {
            char c = text.charAt(i);
            var glyph = font.glyph(c);
            width += glyph.xadvance();
        }
        return width;
    }

    private static TtfFont getFont() {
        if (cachedFont == null) {
            int pixelHeight = Math.max(8, Math.round(WATERMARK_FONT_SIZE));
            cachedFont = TtfFont.fromResource(FONT_PATH, pixelHeight);
        }
        return cachedFont;
    }
}
надеюсь одобрят?
хз, шрифт руина
 
Слам, YouGame, решил залить свою ватермарку. Хотел сделать красивую, а получилось дерьмо
не знаю, кому нужно. Делал на какой-то нн-базе с рендером.

Посмотреть вложение 332324
watermark:
Expand Collapse Copy
package com.ferrion.overlay;

import com.ferrion.gui.ClickGUI;
import com.ferrion.render.ColorRGBA;
import com.ferrion.render.Ferrion2D;
import com.ferrion.render.font.TtfFont;
import net.minecraft.client.MinecraftClient;

public final class Watermark {
    private static final MinecraftClient mc = MinecraftClient.getInstance();
    private static final ColorRGBA COLOR_WHITE = ColorRGBA.rgba(255, 255, 255, 255);
    private static final ColorRGBA COLOR_LAVENDER = ColorRGBA.rgba(200, 162, 200, 255);
    private static final ColorRGBA COLOR_GRAY = ColorRGBA.rgba(150, 150, 150, 255);
    private static final float WATERMARK_RADIUS = 8f;
    private static final float WATERMARK_BLUR_RADIUS = 10f;
    private static final float WATERMARK_PADDING = 8f;
    private static final float WATERMARK_FONT_SIZE = 7.5f;
    private static final float WATERMARK_HEIGHT = 26f;
    private static final float WATERMARK_SPACING = 8f;
    private static final String FONT_PATH = "ferrion/fonts/opnsans.ttf";
    private static TtfFont cachedFont = null;

    private Watermark() {
    }

    public static void render(float x, float y, String text, int ping, int fps) {
        float hudAlpha = ClickGUI.getHudAlpha();
        if (hudAlpha < 0.01f) {
            return;
        }

        String username = mc.getSession().getUsername();
        String fpsText = String.valueOf(fps);
        String msText = String.valueOf(ping);
        boolean hasBossBar = false;
        try {
            var bossBarHud = mc.inGameHud.getBossBarHud();
            var bossBarsField = bossBarHud.getClass().getDeclaredField("bossBars");
            bossBarsField.setAccessible(true);
            var bossBars = (java.util.Map<?, ?>) bossBarsField.get(bossBarHud);
            hasBossBar = !bossBars.isEmpty();
        } catch (Exception e) {
            hasBossBar = false;
        }

        float bossBarOffset = hasBossBar ? 20f : 0f;
        float posY = 10f + bossBarOffset;
        float guiSlideDistance = 20f;
        float guiSlideOffset = -guiSlideDistance * (1.0f - hudAlpha);
        if (hudAlpha > 0.01f) {
            renderWatermark(posY + guiSlideOffset, hudAlpha, username, fpsText, msText);
        }
    }

    private static void renderWatermark(float y, float alpha, String username, String fpsText, String msText) {
        float ferrionWidth = calculateTextWidth("FERRION");
        float usernameWidth = calculateTextWidth(username);
        float fpsNumWidth = calculateTextWidth(fpsText);
        float fpsTextWidth = calculateTextWidth("fps");
        float msNumWidth = calculateTextWidth(msText);
        float msTextWidth = calculateTextWidth("mc");

        float totalWidth = WATERMARK_PADDING + ferrionWidth + WATERMARK_SPACING + usernameWidth +
                WATERMARK_SPACING + fpsNumWidth + fpsTextWidth + WATERMARK_SPACING +
                msNumWidth + msTextWidth + WATERMARK_PADDING;

        float screenWidth = Ferrion2D.width();
        float centerX = (screenWidth - totalWidth) / 2f;
        int bgAlpha = (int) (200 * alpha);
        Ferrion2D.blurredRoundedRect(centerX, y, totalWidth, WATERMARK_HEIGHT,
                WATERMARK_RADIUS, WATERMARK_BLUR_RADIUS,
                ColorRGBA.rgba(29, 29, 39, bgAlpha));

        int gradientAlpha = (int) (255 * alpha);
        Ferrion2D.roundedRectGradient(centerX, y, totalWidth, WATERMARK_HEIGHT, WATERMARK_RADIUS,
                ColorRGBA.rgba(29, 29, 39, gradientAlpha),
                ColorRGBA.rgba(0, 0, 0, gradientAlpha));
        float textY = y + (WATERMARK_HEIGHT - WATERMARK_FONT_SIZE) / 2f - 0.5f;
        float currentX = centerX + WATERMARK_PADDING;
        currentX += drawStaticText("FERRION", currentX, textY, WATERMARK_FONT_SIZE, alpha);
        currentX += WATERMARK_SPACING;
        drawDivider(currentX - WATERMARK_SPACING / 2f - 1f, y, WATERMARK_HEIGHT, alpha);
        Ferrion2D.text(username, currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_WHITE, alpha));
        currentX += usernameWidth + WATERMARK_SPACING;
        drawDivider(currentX - WATERMARK_SPACING / 2f - 1f, y, WATERMARK_HEIGHT, alpha);
        Ferrion2D.text(fpsText, currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_WHITE, alpha));
        currentX += fpsNumWidth;
        Ferrion2D.text("fps", currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_LAVENDER, alpha));
        currentX += fpsTextWidth + WATERMARK_SPACING;
        drawDivider(currentX - WATERMARK_SPACING / 2f - 1f, y, WATERMARK_HEIGHT, alpha);
        Ferrion2D.text(msText, currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_WHITE, alpha));
        currentX += msNumWidth;
        Ferrion2D.text("mc", currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_LAVENDER, alpha));
    }
   
    private static void drawDivider(float x, float y, float height, float alpha) {
        float dividerHeight = height - 12f;
        float dividerY = y + 6f;
        float dividerWidth = 1.5f;
       
        Ferrion2D.roundedRect(x, dividerY, dividerWidth, dividerHeight, 0.75f,
                applyAlpha(ColorRGBA.rgba(80, 80, 90, 255), alpha * 0.4f));
    }

    private static float drawStaticText(String text, float x, float y, float size, float alpha) {
        float currentX = x;
        TtfFont font = getFont();
        ColorRGBA color = applyAlpha(COLOR_LAVENDER, alpha);
        for (int i = 0; i < text.length(); i++) {
            char c = text.charAt(i);
            Ferrion2D.text(String.valueOf(c), currentX, y, size, color);
            var glyph = font.glyph(c);
            currentX += glyph.xadvance();
        }
        return calculateTextWidth(text);
    }

    private static ColorRGBA applyAlpha(ColorRGBA color, float alpha) {
        int a = (int) (color.a() * 255 * alpha);
        return ColorRGBA.rgba((int)(color.r() * 255), (int)(color.g() * 255),
                (int)(color.b() * 255), a);
    }

    private static float calculateTextWidth(String text) {
        TtfFont font = getFont();
        float width = 0f;
        for (int i = 0; i < text.length(); i++) {
            char c = text.charAt(i);
            var glyph = font.glyph(c);
            width += glyph.xadvance();
        }
        return width;
    }

    private static TtfFont getFont() {
        if (cachedFont == null) {
            int pixelHeight = Math.max(8, Math.round(WATERMARK_FONT_SIZE));
            cachedFont = TtfFont.fromResource(FONT_PATH, pixelHeight);
        }
        return cachedFont;
    }
}
надеюсь одобрят?
дай линк на базу
 
Слам, YouGame, решил залить свою ватермарку. Хотел сделать красивую, а получилось дерьмо
не знаю, кому нужно. Делал на какой-то нн-базе с рендером.

Посмотреть вложение 332324
watermark:
Expand Collapse Copy
package com.ferrion.overlay;

import com.ferrion.gui.ClickGUI;
import com.ferrion.render.ColorRGBA;
import com.ferrion.render.Ferrion2D;
import com.ferrion.render.font.TtfFont;
import net.minecraft.client.MinecraftClient;

public final class Watermark {
    private static final MinecraftClient mc = MinecraftClient.getInstance();
    private static final ColorRGBA COLOR_WHITE = ColorRGBA.rgba(255, 255, 255, 255);
    private static final ColorRGBA COLOR_LAVENDER = ColorRGBA.rgba(200, 162, 200, 255);
    private static final ColorRGBA COLOR_GRAY = ColorRGBA.rgba(150, 150, 150, 255);
    private static final float WATERMARK_RADIUS = 8f;
    private static final float WATERMARK_BLUR_RADIUS = 10f;
    private static final float WATERMARK_PADDING = 8f;
    private static final float WATERMARK_FONT_SIZE = 7.5f;
    private static final float WATERMARK_HEIGHT = 26f;
    private static final float WATERMARK_SPACING = 8f;
    private static final String FONT_PATH = "ferrion/fonts/opnsans.ttf";
    private static TtfFont cachedFont = null;

    private Watermark() {
    }

    public static void render(float x, float y, String text, int ping, int fps) {
        float hudAlpha = ClickGUI.getHudAlpha();
        if (hudAlpha < 0.01f) {
            return;
        }

        String username = mc.getSession().getUsername();
        String fpsText = String.valueOf(fps);
        String msText = String.valueOf(ping);
        boolean hasBossBar = false;
        try {
            var bossBarHud = mc.inGameHud.getBossBarHud();
            var bossBarsField = bossBarHud.getClass().getDeclaredField("bossBars");
            bossBarsField.setAccessible(true);
            var bossBars = (java.util.Map<?, ?>) bossBarsField.get(bossBarHud);
            hasBossBar = !bossBars.isEmpty();
        } catch (Exception e) {
            hasBossBar = false;
        }

        float bossBarOffset = hasBossBar ? 20f : 0f;
        float posY = 10f + bossBarOffset;
        float guiSlideDistance = 20f;
        float guiSlideOffset = -guiSlideDistance * (1.0f - hudAlpha);
        if (hudAlpha > 0.01f) {
            renderWatermark(posY + guiSlideOffset, hudAlpha, username, fpsText, msText);
        }
    }

    private static void renderWatermark(float y, float alpha, String username, String fpsText, String msText) {
        float ferrionWidth = calculateTextWidth("FERRION");
        float usernameWidth = calculateTextWidth(username);
        float fpsNumWidth = calculateTextWidth(fpsText);
        float fpsTextWidth = calculateTextWidth("fps");
        float msNumWidth = calculateTextWidth(msText);
        float msTextWidth = calculateTextWidth("mc");

        float totalWidth = WATERMARK_PADDING + ferrionWidth + WATERMARK_SPACING + usernameWidth +
                WATERMARK_SPACING + fpsNumWidth + fpsTextWidth + WATERMARK_SPACING +
                msNumWidth + msTextWidth + WATERMARK_PADDING;

        float screenWidth = Ferrion2D.width();
        float centerX = (screenWidth - totalWidth) / 2f;
        int bgAlpha = (int) (200 * alpha);
        Ferrion2D.blurredRoundedRect(centerX, y, totalWidth, WATERMARK_HEIGHT,
                WATERMARK_RADIUS, WATERMARK_BLUR_RADIUS,
                ColorRGBA.rgba(29, 29, 39, bgAlpha));

        int gradientAlpha = (int) (255 * alpha);
        Ferrion2D.roundedRectGradient(centerX, y, totalWidth, WATERMARK_HEIGHT, WATERMARK_RADIUS,
                ColorRGBA.rgba(29, 29, 39, gradientAlpha),
                ColorRGBA.rgba(0, 0, 0, gradientAlpha));
        float textY = y + (WATERMARK_HEIGHT - WATERMARK_FONT_SIZE) / 2f - 0.5f;
        float currentX = centerX + WATERMARK_PADDING;
        currentX += drawStaticText("FERRION", currentX, textY, WATERMARK_FONT_SIZE, alpha);
        currentX += WATERMARK_SPACING;
        drawDivider(currentX - WATERMARK_SPACING / 2f - 1f, y, WATERMARK_HEIGHT, alpha);
        Ferrion2D.text(username, currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_WHITE, alpha));
        currentX += usernameWidth + WATERMARK_SPACING;
        drawDivider(currentX - WATERMARK_SPACING / 2f - 1f, y, WATERMARK_HEIGHT, alpha);
        Ferrion2D.text(fpsText, currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_WHITE, alpha));
        currentX += fpsNumWidth;
        Ferrion2D.text("fps", currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_LAVENDER, alpha));
        currentX += fpsTextWidth + WATERMARK_SPACING;
        drawDivider(currentX - WATERMARK_SPACING / 2f - 1f, y, WATERMARK_HEIGHT, alpha);
        Ferrion2D.text(msText, currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_WHITE, alpha));
        currentX += msNumWidth;
        Ferrion2D.text("mc", currentX, textY, WATERMARK_FONT_SIZE, applyAlpha(COLOR_LAVENDER, alpha));
    }
   
    private static void drawDivider(float x, float y, float height, float alpha) {
        float dividerHeight = height - 12f;
        float dividerY = y + 6f;
        float dividerWidth = 1.5f;
       
        Ferrion2D.roundedRect(x, dividerY, dividerWidth, dividerHeight, 0.75f,
                applyAlpha(ColorRGBA.rgba(80, 80, 90, 255), alpha * 0.4f));
    }

    private static float drawStaticText(String text, float x, float y, float size, float alpha) {
        float currentX = x;
        TtfFont font = getFont();
        ColorRGBA color = applyAlpha(COLOR_LAVENDER, alpha);
        for (int i = 0; i < text.length(); i++) {
            char c = text.charAt(i);
            Ferrion2D.text(String.valueOf(c), currentX, y, size, color);
            var glyph = font.glyph(c);
            currentX += glyph.xadvance();
        }
        return calculateTextWidth(text);
    }

    private static ColorRGBA applyAlpha(ColorRGBA color, float alpha) {
        int a = (int) (color.a() * 255 * alpha);
        return ColorRGBA.rgba((int)(color.r() * 255), (int)(color.g() * 255),
                (int)(color.b() * 255), a);
    }

    private static float calculateTextWidth(String text) {
        TtfFont font = getFont();
        float width = 0f;
        for (int i = 0; i < text.length(); i++) {
            char c = text.charAt(i);
            var glyph = font.glyph(c);
            width += glyph.xadvance();
        }
        return width;
    }

    private static TtfFont getFont() {
        if (cachedFont == null) {
            int pixelHeight = Math.max(8, Math.round(WATERMARK_FONT_SIZE));
            cachedFont = TtfFont.fromResource(FONT_PATH, pixelHeight);
        }
        return cachedFont;
    }
}
надеюсь одобрят?
под чипсы с чаем пойдет
 
Слам, YouGame, решил залить свою ватермарку. Хотел сделать красивую, а получилось дерьмо
не знаю, кому нужно. Делал на какой-то нн-базе с рендером.

Посмотреть вложение 332324
watermark:
Expand Collapse Copy
package com.ferrion.overlay;
    private static final MinecraftClient mc = MinecraftClient.getInstance();
нифига ты маладец
 
Назад
Сверху Снизу