Начинающий
- Статус
- Оффлайн
- Регистрация
- 2 Мар 2026
- Сообщения
- 16
- Реакции
- 0
- Выберите загрузчик игры
- Fabric
Это моя первая тема, я с гпт сделал такой классный TargetHUD, он намного лучше того, что в зените по дефолту.
ss -- снизу
dw -- снизу
ss -- снизу
dw -- снизу
TargetHUD Zenith Recode:
package micronix.experiment.client.hud.elements.component;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.network.AbstractClientPlayerEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import micronix.experiment.Experiment;
import micronix.experiment.base.animations.base.Animation;
import micronix.experiment.base.animations.base.Easing;
import micronix.experiment.base.font.Font;
import micronix.experiment.base.font.Fonts;
import micronix.experiment.base.theme.Theme;
import micronix.experiment.client.hud.elements.draggable.DraggableHudElement;
import micronix.experiment.client.modules.impl.combat.Aura;
import micronix.experiment.utility.render.display.base.BorderRadius;
import micronix.experiment.utility.render.display.base.CustomDrawContext;
import micronix.experiment.utility.render.display.base.color.ColorRGBA;
import micronix.experiment.utility.render.display.shader.DrawUtil;
import net.minecraft.scoreboard.ReadableScoreboardScore;
import net.minecraft.scoreboard.Scoreboard;
import net.minecraft.scoreboard.ScoreboardDisplaySlot;
import net.minecraft.scoreboard.ScoreboardObjective;
import static java.lang.Math.round;
public class TargetHudComponent extends DraggableHudElement {
private final Animation healthAnimation = new Animation(300, Easing.LINEAR);
private final Animation toggleAnimation = new Animation(300, 0, Easing.CUBIC_OUT);
private LivingEntity target;
public TargetHudComponent(String name, float initialX, float initialY, float windowWidth, float windowHeight, float offsetX, float offsetY, Align align) {
super(name, initialX, initialY, windowWidth, windowHeight, offsetX, offsetY, align);
}
@Override
public void render(CustomDrawContext ctx) {
this.width = 130f;
this.height = 40f;
Aura aura = Aura.INSTANCE;
LivingEntity target = (mc.currentScreen instanceof ChatScreen) ? mc.player : aura.getTarget();
setTarget(target);
if (toggleAnimation.getValue() == 0 || this.target == null) return;
renderTargetHud(ctx, this.target, (float) toggleAnimation.getValue());
}
private float getScoreboardHealth(LivingEntity entity) {
if (!(entity instanceof PlayerEntity player)) {
return entity.getHealth();
}
try {
Scoreboard scoreboard = player.getScoreboard();
if (scoreboard == null) return entity.getHealth();
ScoreboardObjective objective = scoreboard.getObjectiveForSlot(ScoreboardDisplaySlot.LIST);
if (objective == null) return entity.getHealth();
ReadableScoreboardScore score = scoreboard.getScore(player, objective);
if (score == null) return entity.getHealth();
int scorePoints = score.getScore();
if (scorePoints > 0 && scorePoints <= player.getMaxHealth()) {
return (float) scorePoints;
}
} catch (Exception e) {
}
return entity.getHealth();
}
private void renderTargetHud(CustomDrawContext ctx, LivingEntity target, float animation) {
float posX = x, posY = y;
float width = 100f;
float height = 40f;
float padding = 4.5f;
float headSize = 18f;
float barHeight = 2.5f;
Theme theme = Experiment.getInstance().getThemeManager().getCurrentTheme();
ctx.pushMatrix();
{
float scale = animation;
ctx.getMatrices().translate(posX + width / 2f, posY + height / 2f, 0);
ctx.getMatrices().scale(scale, scale, 1);
ctx.getMatrices().translate(-(posX + width / 2f), -(posY + height / 2f), 0);
BorderRadius radius = BorderRadius.all(6f);
DrawUtil.drawBlurHud(ctx.getMatrices(), posX, posY, width, height,
21, radius, ColorRGBA.WHITE);
DrawUtil.drawRoundedRect(ctx.getMatrices(), posX, posY, width, height,
radius, theme.getForegroundColor());
float headX = posX + padding + 2f;
float headY = posY + (height - headSize) / 2f - 5f;
if (target instanceof PlayerEntity player) {
DrawUtil.drawPlayerHeadWithRoundedShader(
ctx.getMatrices(),
((AbstractClientPlayerEntity) player).getSkinTextures().texture(),
headX, headY, headSize,
BorderRadius.all(2f),
ColorRGBA.WHITE.withAlpha((int)(255 * animation))
);
} else {
ColorRGBA placeholderBg = new ColorRGBA(60, 60, 60, (int)(200 * animation));
ctx.drawRoundedRect(headX, headY, headSize, headSize,
BorderRadius.all(4f), placeholderBg);
Font bigFont = Fonts.SEMIBOLD.getFont(10);
String questionMark = "?";
float qX = headX + (headSize - bigFont.width(questionMark)) / 2f;
float qY = headY + (headSize - bigFont.height()) / 2f;
ctx.drawText(bigFont, questionMark, qX, qY,
new ColorRGBA(200, 200, 200, (int)(255 * animation)));
}
Font font = Fonts.MEDIUM.getFont(6f);
float textY = posY + (height - font.height()) / 2f - 10F;
float textX = headX + headSize + 7f;
float hp = Math.round(getScoreboardHealth(target));
String hpText = (int) hp + "hp";
float hpWidth = font.width(hpText);
float hpX = posX + width - padding - hpWidth - 2;
float maxNameWidth = hpX - textX - 2f;
String name = target.getName().getString();
while (font.width(name) > maxNameWidth && name.length() > 0) {
name = name.substring(0, name.length() - 1);
}
ctx.drawText(font, name, textX, textY,
theme.getWhite().withAlpha((int)(255 * animation)));
ctx.drawText(font, hpText, textX, textY + 10,
theme.getWhite().withAlpha(20).withAlpha((int)(255 * animation)));
float barX = posX + padding + 2.5f;
float barY = posY + height - padding - barHeight - 2f;
float barWidth = width - padding * 2f - 5;
float percent = Math.min(1f, hp / target.getMaxHealth());
float animHp = healthAnimation.update(barWidth * percent);
ctx.drawRoundedRect(barX, barY, animHp, barHeight,
BorderRadius.all(0f),
theme.getColor().withAlpha((int)(255 * animation)));
}
ctx.popMatrix();
this.width = width;
this.height = height;
}
public void setTarget(LivingEntity target) {
if (target == null) {
toggleAnimation.update(0);
if (toggleAnimation.getValue() == 0) {
this.target = null;
}
} else {
if (target != this.target) {
toggleAnimation.update(0);
if (toggleAnimation.getValue() == 0) {
this.target = target;
}
} else {
toggleAnimation.update(1);
}
}
}
}