Подпишитесь на наш Telegram-канал, чтобы всегда быть в курсе важных обновлений! Перейти

Визуальная часть Watermark exp 3.1

  • Автор темы Автор темы GThicig
  • Дата начала Дата начала
изменил с другого поста так что не пишите ыыыыы спиздил с другой темы ыыыыыы щас побегут пасты

SS
Посмотреть вложение 320660
WatermarkRenderer:
Expand Collapse Copy
package im.expensive.ui.display.impl;

import com.mojang.blaze3d.matrix.MatrixStack;
import im.expensive.Expensive;
import im.expensive.events.EventDisplay;
import im.expensive.events.EventUpdate;
import im.expensive.ui.display.ElementRenderer;
import im.expensive.ui.styles.Style;
import im.expensive.utils.render.ColorUtils;
import im.expensive.utils.render.DisplayUtils;
import im.expensive.utils.render.font.Fonts;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import net.minecraft.util.ResourceLocation;

@FieldDefaults(level = AccessLevel.PRIVATE)
@RequiredArgsConstructor
public class WatermarkRenderer implements ElementRenderer {

    @Override
    public void update(EventUpdate e) {}

    @Override
    public void render(EventDisplay eventDisplay) {
        MatrixStack ms = eventDisplay.getMatrixStack();
        Style style = Expensive.getInstance().getStyleManager().getCurrentStyle();

        float posX = 5;
        float posY = 5;
        float fontSize = 7.0f;
        float spacing = 3f;
        float padding = 5.0f;
        float elementHeight = 16;

        // тут меняем название своего клиента
        String username = "CursDLC";
        String SERVER = mc.getCurrentServerData() != null ? mc.getCurrentServerData().serverIP : "Singleplayer";
        String FPS = mc.debugFPS + " fps";
        String PING = mc.player != null
                ? mc.player.connection.getPlayerInfo(mc.player.getGameProfile().getId()).getResponseTime() + " ms"
                : "N/A";

        String TPS = "20 tps";
        String BPS = String.format("%.2f bps", mc.player != null ? mc.player.getMotion().length() * 20 : 0.0);

        float usernameWidth = Fonts.sfMedium.getWidth(username, fontSize);
        float serverWidth = Fonts.sfMedium.getWidth(SERVER, fontSize);
        float fpsWidth = Fonts.sfMedium.getWidth(FPS, fontSize);
        float pingWidth = Fonts.sfMedium.getWidth(PING, fontSize);
        float tpsWidth = Fonts.sfMedium.getWidth(TPS, fontSize);
        float bpsWidth = Fonts.sfMedium.getWidth(BPS, fontSize);

        // 🎈Очко🎇
        float iconSpacing = 3f;
        float usernameIconWidth = Fonts.icons2.getWidth("U", fontSize);
        float serverIconWidth = Fonts.icons2.getWidth("F", fontSize);
        float fpsIconWidth = Fonts.icons2.getWidth("S", fontSize);
        float pingIconWidth = Fonts.icons2.getWidth("Q", fontSize);
        float tpsIconWidth = Fonts.icons2.getWidth("T", fontSize);
        float bpsIconWidth = Fonts.icons2.getWidth("B", fontSize);

        final ResourceLocation logo = new ResourceLocation("expensive/images/mainmenu/icon1.png");
        float logoSize = elementHeight + 4;

        float contentWidth =
                usernameIconWidth + iconSpacing + usernameWidth + spacing +
                        serverIconWidth + iconSpacing + serverWidth + spacing +
                        fpsIconWidth + iconSpacing + fpsWidth + spacing +
                        pingIconWidth + iconSpacing + pingWidth;

        float secondContentWidth =
                tpsIconWidth + iconSpacing + tpsWidth + spacing +
                        bpsIconWidth + iconSpacing + bpsWidth;

        float width = contentWidth + padding * 2;
        float width2 = secondContentWidth + padding * 2;

        float radius = 3f;

        drawFullRect(posX, posY, logoSize, elementHeight, radius);
        DisplayUtils.drawImage(logo,
                posX + (logoSize - 8) / 2,
                posY + (elementHeight - 8) / 2,
                8, 8,
                style.getSecondColor().getRGB());

        drawFullRect(posX + logoSize + 3, posY, width, elementHeight, radius);

        float textPosX = posX + logoSize + 3 + padding;
        float textPosY = posY + (elementHeight - fontSize) / 2 + 1;

        Fonts.icons2.drawText(ms, "U", textPosX, textPosY, style.getSecondColor().getRGB(), fontSize);
        textPosX += usernameIconWidth + iconSpacing;
        Fonts.sfMedium.drawText(ms, username, textPosX, textPosY, ColorUtils.rgb(255, 255, 255), fontSize);
        textPosX += usernameWidth + spacing;

        Fonts.icons2.drawText(ms, "F", textPosX, textPosY, style.getSecondColor().getRGB(), fontSize);
        textPosX += serverIconWidth + iconSpacing;
        Fonts.sfMedium.drawText(ms, SERVER, textPosX, textPosY, ColorUtils.rgb(255, 255, 255), fontSize);
        textPosX += serverWidth + spacing;

        Fonts.icons2.drawText(ms, "S", textPosX, textPosY, style.getSecondColor().getRGB(), fontSize);
        textPosX += fpsIconWidth + iconSpacing;
        Fonts.sfMedium.drawText(ms, FPS, textPosX, textPosY, ColorUtils.rgb(255, 255, 255), fontSize);
        textPosX += fpsWidth + spacing;

        Fonts.icons2.drawText(ms, "Q", textPosX, textPosY, style.getSecondColor().getRGB(), fontSize);
        textPosX += pingIconWidth + iconSpacing;
        Fonts.sfMedium.drawText(ms, PING, textPosX, textPosY, ColorUtils.rgb(255, 255, 255), fontSize);

        float posY2 = posY + elementHeight + 4;

        drawFullRect(posX, posY2, width2, elementHeight, radius);

        float textPosX2 = posX + padding;
        float textPosY2 = posY2 + (elementHeight - fontSize) / 2 + 1;

        Fonts.icons2.drawText(ms, "T", textPosX2, textPosY2, style.getSecondColor().getRGB(), fontSize);
        textPosX2 += tpsIconWidth + iconSpacing;
        Fonts.sfMedium.drawText(ms, TPS, textPosX2, textPosY2, ColorUtils.rgb(255, 255, 255), fontSize);

        textPosX2 += tpsWidth + spacing;
        Fonts.icons2.drawText(ms, "B", textPosX2, textPosY2, style.getSecondColor().getRGB(), fontSize);
        textPosX2 += bpsIconWidth + iconSpacing;
        Fonts.sfMedium.drawText(ms, BPS, textPosX2, textPosY2, ColorUtils.rgb(255, 255, 255), fontSize);
    }

    private void drawFullRect(float x, float y, float width, float height, float radius) {
        DisplayUtils.drawRoundedRect(x, y, width, height, radius, ColorUtils.rgb(10, 15, 13));
        DisplayUtils.drawShadow(x + 3, y + 3, width, height, 4, ColorUtils.rgba(0, 0, 0, 90));
    }
}
извините за лого подправьте там
Фу бля
 
майнкрафт пастинг. итоги. в рендере слишком дохуя логики и формирование строк каждый кадр))
 
Назад
Сверху Снизу