@ModuleInfo(
name = "Target Hud",
category = Category.Hud
)
@Getter
@Setter
public class TargetHUD extends Module {
private double scale = 0;
private static LivingEntity curTarget = null;
private float healthBarWidth;
public TargetHUD() {
}
@EventTarget
public void onRender(EventRender2D event) {
DraggableTargetHUD dth = (DraggableTargetHUD) Rich.instance.draggableHUD.getDraggableComponentByClass(DraggableTargetHUD.class);
float x = dth.getX();
float y = dth.getY();
dth.setWidth(153);
dth.setHeight(42);
if (Aura.target == null) {
curTarget = Aura.target;
if (mc.player != null && mc.currentScreen instanceof ChatScreen) {
curTarget = mc.player;
scale = AnimationHelper.animation((float) scale, (float) 1, (float) (6 * Rich.deltaTime()));
} else {
scale = AnimationHelper.animation((float) scale, (float) 0, (float) (6 * Rich.deltaTime()));
}
} else {
if (mc.player != null) {
curTarget = Aura.target;
scale = AnimationHelper.animation((float) scale, (float) 1, (float) (6 * Rich.deltaTime()));
}
}
if (curTarget != null) {
try {
GlStateManager.pushMatrix();
GL11.glTranslated(x + 50, y + 31, 0);
GL11.glScaled(scale, scale, 0);
GL11.glTranslated(-(x + 50), -(y + 31), 0);
RoundedUtil.drawGradientRound(x - 1, y - 1, dth.getWidth() - 20 + 2, dth.getHeight() + 2, 6, Hud.getColor(1), Hud.getColor(50), Hud.getColor(100), Hud.getColor(150), event.getMatrixStack());
RoundedUtil.drawRound(x, y, dth.getWidth() - 20, dth.getHeight(), 6, new Color(0, 0, 0, 150), event.getMatrixStack());
RenderUtils.drawBlurredShadow(x, y, dth.getWidth() - 20, dth.getHeight(), 15, new Color(0, 0, 0, 150));
double healthWid = (curTarget.getHealth() / curTarget.getMaxHealth() * 135.0D);
healthWid = MathHelper.clamp(healthWid, 0.0D, 135.0D);
healthBarWidth = AnimationHelper.animation((float) healthBarWidth, (float) healthWid, (float) (10 * Rich.deltaTime()));
String health = "" + MathematicHelper.round(curTarget.getHealth() * 20 / curTarget.getMaxHealth(), 1);
Fonts.MANROPE_BOLD.get(15).draw(curTarget.getName().getString(), x + 3, y + 5, -1);
RoundedUtil.drawGradientRound(x + 3, y + 32, 10 + healthBarWidth - 58, 7, 3, Hud.getColor(1), Hud.getColor(1), Hud.getColor(50), Hud.getColor(50), event.getMatrixStack());
Fonts.MANROPE_BOLD.get(15).draw("hp: " + health, x + 3, y + 15, -1);
for (NetworkPlayerInfo targetHead : mc.player.connection.getPlayerInfoMap()) {
mc.getTextureManager().bindTexture(targetHead.getLocationSkin());
GL11.glPushMatrix();
Gui.drawScaledCustomSizeModalRect((int) x + 95, y + 4, 8.0f, 8.0f, 8, 8, 35, 35, 64.0f, 64.0f);
GL11.glPopMatrix();
GlStateManager.bindTexture(0);
}
} catch (Exception exception) {
} finally {
GlStateManager.popMatrix();
}
}
}
public static void drawPlayerHead(double x, double y, double width, double height, double texX, double texY, double texWidth, double texHeight, LivingEntity player) {
NetworkPlayerInfo playerInfo = Objects.requireNonNull(Minecraft.getInstance().getConnection()).getPlayerInfo(player.getUniqueID());
if (playerInfo != null) {
RenderUtils.drawTexture(playerInfo.getLocationSkin(), x, y, width, height, texX, texY, texWidth, texHeight);
}
}
}