Начинающий
- Статус
- Оффлайн
- Регистрация
- 24 Июл 2025
- Сообщения
- 22
- Реакции
- 0
- Выберите загрузчик игры
- Fabric
первая работа не судите строго, там не адаптируется под длинну юзернейма т. к. не знал как это сделать
Code:
package rich.screens.hud;
import antidaunleak.api.UserProfile;
import net.minecraft.client.gui.DrawContext;
import rich.client.draggables.AbstractHudElement;
import rich.util.render.Render2D;
import rich.util.render.font.Fonts;
import java.awt.*;
public class Watermark extends AbstractHudElement {
public Watermark() {
super("Watermark", 10, 10, 257, 26, false);
startAnimation();
}
@Override
public void tick() {
}
@Override
public void drawDraggable(DrawContext context, int alpha) {
if (alpha <= 0) return;
float x = getX();
float y = getY();
float width = 140f;
float height = 16f;
float padding = 5;
float fontSize = 7.5f;
String username = mc.getSession().getUsername();
String role = UserProfile.getInstance().profile("role");
String fpsText = String.valueOf(mc.getCurrentFps());
String msText = "0";
if (mc.getCurrentServerEntry() != null) {
msText = String.valueOf(mc.getCurrentServerEntry().ping);
}
int[] gradientColors = {
new Color(48, 47, 57, 255).getRGB(),
new Color(0x11, 0x11, 0x11, 255).getRGB(),
new Color(0x11, 0x11, 0x11, 255).getRGB(),
new Color(48, 47, 57, 255).getRGB()
};
Render2D.gradientRect(x, y, width, height, gradientColors, 3);
float textX = x + padding;
float textY = y + (height - Fonts.BOLD.getHeight(fontSize)) / 2;
Fonts.ICONS.draw("A", textX, textY + 0.5f, fontSize, new Color(255, 255, 255, 255).getRGB());
textX += Fonts.ICONS.getWidth("A", fontSize) + 3;
Fonts.TEST.draw("•", textX, textY - 0.5f, fontSize + 1, new Color(0x4b, 0x4b, 0x50, 255).getRGB());
textX += Fonts.TEST.getWidth("•", fontSize + 1) + 3;
Fonts.BOLD.draw(username, textX, textY, fontSize, new Color(255, 255, 255, 255).getRGB());
textX += Fonts.BOLD.getWidth(username, fontSize) + 2;
Fonts.TEST.draw("[", textX, textY - 1f, fontSize + 1, new Color(141, 140, 143, 255).getRGB());
textX += Fonts.TEST.getWidth("[", fontSize + 1);
Fonts.BOLD.draw(role, textX, textY, fontSize, new Color(0xA3, 0x9B, 0xD6, 255).getRGB());
textX += Fonts.BOLD.getWidth(role, fontSize);
Fonts.TEST.draw("]", textX, textY - 1f, fontSize + 1, new Color(141, 140, 143, 255).getRGB());
textX += Fonts.TEST.getWidth("]", fontSize + 1) + 3;
Fonts.TEST.draw("•", textX, textY - 0.5f, fontSize + 1, new Color(0x4b, 0x4b, 0x50, 255).getRGB());
textX += Fonts.TEST.getWidth("•", fontSize + 1) + 3;
Fonts.BOLD.draw(fpsText, textX, textY, fontSize, new Color(255, 255, 255, 255).getRGB());
textX += Fonts.BOLD.getWidth(fpsText, fontSize);
Fonts.BOLD.draw("FPS", textX, textY, fontSize, new Color(0xA3, 0x9B, 0xD6, 255).getRGB());
textX += Fonts.BOLD.getWidth("FPS", fontSize) + 3;
Fonts.TEST.draw("•", textX, textY - 0.5f, fontSize + 1, new Color(0x4b, 0x4b, 0x50, 255).getRGB());
textX += Fonts.TEST.getWidth("•", fontSize) + 3;
Fonts.BOLD.draw(msText, textX, textY, fontSize, new Color(255, 255, 255, 255).getRGB());
textX += Fonts.BOLD.getWidth(msText, fontSize);
Fonts.BOLD.draw("MS", textX, textY, fontSize, new Color(0xA3, 0x9B, 0xD6, 255).getRGB());
setWidth((int) width);
setHeight((int) height);
}
}
Последнее редактирование:
