Начинающий
- Статус
- Оффлайн
- Регистрация
- 26 Сен 2025
- Сообщения
- 283
- Реакции
- 2
- Выберите загрузчик игры
- Fabric
как-будто максимально топорная работа, выглядит +-, но внутри говнокод
сделано в нетрезвом состоянии.
ss:
сделано в нетрезвом состоянии.
Assembly:
package wtf.ancient.display.hud;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.BlockPos;
import wtf.ancient.utils.client.managers.api.draggable.AbstractDraggable;
import wtf.ancient.utils.display.color.ColorAssist;
import wtf.ancient.utils.display.font.FontRenderer;
import wtf.ancient.utils.display.font.Fonts;
import wtf.ancient.utils.display.shape.ShapeProperties;
import wtf.ancient.utils.interactions.simulate.Simulations;
import wtf.ancient.utils.math.calc.Calculate;
import wtf.ancient.utils.client.packet.network.Network;
import java.awt.Color;
public class Watermark extends AbstractDraggable {
private int fpsCount;
private int ping;
private static final int COLOR1 = new Color(225, 225, 225).getRGB();
private static final int COLOR2 = new Color(120, 120, 120).getRGB();
private static final int gap = 3;
private static final int vgap = 3;
private static final float RECT_HEIGHT = 18f;
private static final int BG = new Color(0, 0, 0, 150).getRGB();
private static final int FG = new Color(14, 14, 14, 14).getRGB();
private final FontRenderer font = Fonts.getSize(16, Fonts.Type.REGULAR);
private final FontRenderer icons = Fonts.getSize(20, Fonts.Type.ICONSTYPENEW);
private final FontRenderer icons2 = Fonts.getSize(20, Fonts.Type.ICONSCATEGORY);
private final FontRenderer logo = Fonts.getSize(35, Fonts.Type.LOGO);
public Watermark() {
super("Watermark", 10, 10, 150, 40, true);
}
@Override
public void tick() {
if (mc.player == null) return;
fpsCount = mc.getCurrentFps();
ping = getPing();
}
@Override
public void drawDraggable(DrawContext ctx) {
MatrixStack matrix = ctx.getMatrices();
var player = mc.player;
if (player == null) return;
double bpsVal = Calculate.round(Simulations.getSpeedSqrt(player) * 20.0F, 0.05F);
BlockPos pos = player.getBlockPos();
String xyzStr = pos.getX() + " " + pos.getY() + " " + pos.getZ();
String tpsStr = String.format("%.2f", Network.TPS) + " tps";
String clientName = "Ancient";
String fpsStr = fpsCount + " fps";
String pingStr = ping + " ms";
String bpsStr = bpsVal + " bps";
float startX = getX();
float startY = getY();
int idx = 0;
float row1X = startX;
row1X = drawLogoSegment(matrix, row1X, startY, "A", idx); idx += 15;
row1X = drawTextOnlySegment(matrix, row1X, startY, clientName, idx); idx += 15;
row1X = drawSegment(matrix, row1X, startY, "w", fpsStr, idx, icons); idx += 15;
row1X = drawSegment(matrix, row1X, startY, "t", pingStr, idx, icons); idx += 15;
float row2Y = startY + RECT_HEIGHT + vgap;
float row2X = startX;
row2X = drawSegment(matrix, row2X, row2Y, "s", tpsStr, idx, icons); idx += 15;
row2X = drawSegment(matrix, row2X, row2Y, "B", bpsStr, idx, icons2); idx += 15;
row2X = drawSegment(matrix, row2X, row2Y, "u", xyzStr, idx, icons);
float width1 = row1X - startX;
float width2 = row2X - startX;
setWidth((int) Math.max(width1, width2));
setHeight((int) (RECT_HEIGHT * 2 + vgap));
}
private float drawLogoSegment(MatrixStack matrix, float x, float y, String logoIcon, int index) {
if (logoIcon == null) logoIcon = "A";
float w = logo.getStringWidth(logoIcon);
float textY = y + 5.5f;
blur.render(ShapeProperties.create(matrix, x, y, w, RECT_HEIGHT).quality(20f).round(6f).color(BG).build());
logo.drawString(matrix, logoIcon, x, textY - 2f, getFade(index));
return x + w + gap;
}
private float drawTextOnlySegment(MatrixStack matrix, float x, float y, String text, int index) {
if (text == null || text.isEmpty()) text = "N/A";
float textW = font.getStringWidth(text);
float w = 6 + textW + 6;
float textY = y + 5.5f;
renderPlate(matrix, x, y, w);
font.drawString(matrix, text, x + 6, textY + 1f, getFade(index));
return x + w + gap;
}
private float drawSegment(MatrixStack matrix, float x, float y, String icon, String text, int index, FontRenderer iconFont) {
if (text == null || text.isEmpty()) text = "N/A";
if (icon == null) icon = "A";
float iconW = 10;
float textW = font.getStringWidth(text);
float w = 6 + iconW + textW + 6;
float textY = y + 5.5f;
renderPlate(matrix, x, y, w);
iconFont.drawString(matrix, icon, x + 5, textY + 1f, getFade(index));
font.drawString(matrix, text, x + 6 + iconW, textY + 1f, getFade(index + 10));
return x + w + gap;
}
private void renderPlate(MatrixStack matrix, float x, float y, float w) {
blur.render(ShapeProperties.create(matrix, x, y, w, RECT_HEIGHT).round(6).quality(5).color(BG).build());
rectangle.render(ShapeProperties.create(matrix, x, y, w, RECT_HEIGHT).round(6).quality(5).color(FG).build());
}
private int getFade(int index) {
return ColorAssist.fade(15, index * 15, COLOR1, COLOR2);
}
private int getPing() {
if (mc.getNetworkHandler() != null && mc.player != null) {
var entry = mc.getNetworkHandler().getPlayerListEntry(mc.player.getUuid());
if (entry != null) return entry.getLatency();
}
return 0;
}
}