Начинающий
- Статус
- Оффлайн
- Регистрация
- 17 Мар 2025
- Сообщения
- 35
- Реакции
- 0
- Выберите загрузчик игры
- Fabric
сделал недавно простенькую ватермарк
ss прикреплен
КОД
↓
ss прикреплен
КОД
↓
Watermark:
package fun.roclub.display.hud;
import net.minecraft.util.Formatting;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.client.util.math.MatrixStack;
import fun.roclub.utils.client.managers.api.draggable.AbstractDraggable;
import fun.roclub.utils.display.font.FontRenderer;
import fun.roclub.utils.display.font.Fonts;
import fun.roclub.utils.display.shape.ShapeProperties;
import fun.roclub.utils.display.color.ColorAssist;
import fun.roclub.utils.math.calc.Calculate;
import fun.roclub.utils.interactions.simulate.Simulations;
import java.awt.*;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
public class Watermark extends AbstractDraggable {
private static final AnimatedValue fpsAnim = new AnimatedValue(0, 0.02f);
private static final AnimatedValue xAnim = new AnimatedValue(0, 0.02f);
private static final AnimatedValue yAnim = new AnimatedValue(0, 0.02f);
private static final AnimatedValue zAnim = new AnimatedValue(0, 0.02f);
private static final AnimatedValue speedAnim = new AnimatedValue(0, 0.02f);
private static final AnimatedValue pingAnim = new AnimatedValue(0, 0.02f);
public Watermark() {
super("Watermark", 10, 10, 150, 35, true);
}
@Override
public void tick() {
if (mc.player == null) return;
fpsAnim.setTarget(mc.getCurrentFps());
xAnim.setTarget((float) mc.player.getX());
yAnim.setTarget((float) mc.player.getY());
zAnim.setTarget((float) mc.player.getZ());
speedAnim.setTarget((float) (Simulations.getSpeedSqrt(mc.player) * 20));
if (mc.getNetworkHandler() != null) {
PlayerListEntry entry = mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid());
if (entry != null) {
pingAnim.setTarget(entry.getLatency());
}
}
}
@Override
public void drawDraggable(DrawContext context) {
if (mc.player == null) return;
MatrixStack matrix = context.getMatrices();
FontRenderer font = Fonts.getSize(18, Fonts.Type.DEFAULT);
FontRenderer fontIcons = Fonts.getSize(18, Fonts.Type.ICONS);
FontRenderer fontSmall = Fonts.getSize(16, Fonts.Type.DEFAULT);
String text = "RoClub";
int scWidth = window.getScaledWidth();
int scHeight = window.getScaledHeight();
float x = getX();
float y = getY();
float roclubWidth = font.getStringWidth(text) + 10;
float roclubX = x + 5;
blur.render(ShapeProperties.create(matrix, roclubX, y + 3, roclubWidth, 15)
.round(5).quality(10).color(new Color(0, 0, 0, 170).getRGB()).build());
String chuppachupsText = "Txixsy";
float chuppachupsX = roclubX + roclubWidth + 3;
float chuppachupsContentWidth = fontIcons.getStringWidth("W") + 2 + fontSmall.getStringWidth(chuppachupsText);
float chuppachupsWidth = chuppachupsContentWidth + 10;
blur.render(ShapeProperties.create(matrix, chuppachupsX, y + 3, chuppachupsWidth, 15)
.round(5).quality(10).color(new Color(0, 0, 0, 170).getRGB()).build());
float fpsX = chuppachupsX + chuppachupsWidth + 3;
String fpsText = fpsAnim.getInt() + " fps";
float fpsWidth = fontIcons.getStringWidth("X") + fontSmall.getStringWidth(fpsText) + 8;
blur.render(ShapeProperties.create(matrix, fpsX, y + 3, fpsWidth, 15)
.round(5).quality(10).color(new Color(0, 0, 0, 170).getRGB()).build());
LocalTime now = LocalTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
String timeText = now.format(formatter);
float timeWidth = fontIcons.getStringWidth("V") + fontSmall.getStringWidth(timeText + " time") + 8;
blur.render(ShapeProperties.create(matrix, x + 5, y + 19, timeWidth, 15)
.round(5).quality(10).color(new Color(0, 0, 0, 170).getRGB()).build());
FontRenderer fontSfpd = Fonts.getSize(18, Fonts.Type.DEFAULT);
float roclubTextWidth = fontSfpd.getStringWidth(text);
fontSfpd.drawString(matrix, text, roclubX + (roclubWidth - roclubTextWidth) / 2, y + 8.5f, -1);
float chuppachupsStartX = chuppachupsX + (chuppachupsWidth - chuppachupsContentWidth) / 2;
fontIcons.drawString(matrix, "W", chuppachupsStartX, y + 8.5f, -1);
fontSmall.drawString(matrix, chuppachupsText, chuppachupsStartX + fontIcons.getStringWidth("W") + 2, y + 8.5f, -1);
float fpsContentWidth = fontIcons.getStringWidth("X") + 2 + fontSmall.getStringWidth(fpsText);
float fpsStartX = fpsX + (fpsWidth - fpsContentWidth) / 2;
fontIcons.drawString(matrix, "X", fpsStartX, y + 8.5f, -1);
fontSmall.drawString(matrix, fpsText, fpsStartX + fontIcons.getStringWidth("X") + 2, y + 8.5f, -1);
String timeFullText = timeText + " time";
float timeContentWidth = fontIcons.getStringWidth("V") + 2 + fontSmall.getStringWidth(timeFullText);
float timeStartX = x + 5 + (timeWidth - timeContentWidth) / 2;
fontIcons.drawString(matrix, "V", timeStartX, y + 24.5f, -1);
fontSmall.drawString(matrix, timeFullText, timeStartX + fontIcons.getStringWidth("V") + 2, y + 24.5f, -1);
float offset = 0f;
float lineHeight = 10f;
String pingText = "ping: " + Formatting.GRAY + pingAnim.getInt();
fontSmall.drawString(matrix, pingText, scWidth - fontSmall.getStringWidth(pingText) - 3f, scHeight - 11f - offset, -1);
}
private static class AnimatedValue {
private float value;
private float target;
private final float speed;
public AnimatedValue(float start, float speed) {
this.value = start;
this.target = start;
this.speed = speed;
}
public void setTarget(float target) {
this.target = target;
}
public float get() {
value += (target - value) * speed;
return value;
}
public int getInt() {
return Math.round(get());
}
}
}