- Выберите загрузчик игры
- Fabric
сливаю говно на югейм день #1
made by claude opus 4.7
ss:
vibecode:
made by claude opus 4.7
ss:
vibecode:
Java:
package ru.cylix.module.impl.visuals.HUD;
import com.mojang.blaze3d.opengl.GlStateManager;
import java.util.ArrayList;
import java.util.List;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.texture.AbstractTexture;
import net.minecraft.client.texture.TextureManager;
import net.minecraft.client.texture.GlTexture;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.mob.CreeperEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.network.PlayerListEntry;
import ru.cylix.module.impl.combat.HitAura;
import ru.cylix.ui.draggable.DraggableManager;
import ru.cylix.util.color.ColorUtil;
import ru.cylix.util.render.animation.util.Animation;
import ru.cylix.util.render.animation.util.Easings;
import ru.cylix.util.render.core.Renderer2D;
import ru.cylix.util.render.math.ScaledResolution;
import ru.cylix.util.render.math.animation.AnimationMath;
import ru.cylix.util.render.text.FontRegistry;
@Environment(EnvType.CLIENT)
public class TargetHUD {
public static MinecraftClient mc = MinecraftClient.getInstance();
private static float animatedHealthWidth = 0.0F;
public static Animation openAnimation = new Animation();
private static LivingEntity lastTarget = null;
public static void targetHUD(Renderer2D r2, DrawContext drawContext) {
ScaledResolution sr = new ScaledResolution(mc);
float width = 195.0F;
float height = 60.0F;
Entity currentTarget = HitAura.target;
boolean chatOpen = mc.currentScreen instanceof ChatScreen;
boolean shouldShow = false;
if (currentTarget != null) {
shouldShow = true;
} else if (chatOpen && mc.player != null) {
currentTarget = mc.player;
shouldShow = true;
}
openAnimation.update();
if (shouldShow) {
openAnimation.run(1.0, 0.15F, Easings.CUBIC_OUT);
} else {
openAnimation.run(0.0, 0.15F, Easings.CUBIC_OUT);
}
float animation = openAnimation.get();
if (animation <= 0.001F) {
animatedHealthWidth = 0.0F;
lastTarget = null;
return;
}
if (currentTarget instanceof LivingEntity living) {
if (lastTarget != living) {
lastTarget = living;
animatedHealthWidth = 0.0F;
}
}
float preferredX = (sr.getWidth() - width) / 2.0F;
float preferredY = (sr.getHeight() - height) / 2.0F + 50.0F;
DraggableManager.DragSession session = DraggableManager.getInstance().beginDrag("targetHUD", preferredX, preferredY, width, height);
float x = session.positionX();
float y = session.positionY();
// Scale animation
r2.pushTranslation(x + width / 2.0F, y + height / 2.0F);
r2.pushScale(animation, animation, 0.0F);
r2.pushTranslation(-(x + width / 2.0F), -(y + height / 2.0F));
if (currentTarget instanceof LivingEntity living) {
renderTargetHud(r2, drawContext, living, x, y, width, height, animation);
}
r2.popTransform();
r2.popClipRect();
r2.popRotation();
r2.popScale();
DraggableManager.getInstance().endDrag(session);
}
private static void renderTargetHud(Renderer2D r2, DrawContext drawContext, LivingEntity target, float x, float y, float width, float height, float animation) {
float padding = 6.75F;
float headSize = 48.0F;
float barHeight = 4.5F;
int mainColor = Renderer2D.ColorUtil.getMainColor(1, 1);
// Background
int bgColor = ColorUtil.replAlpha(ColorUtil.getColor(30, 30, 30, 255), animation * 0.85F);
r2.rect(x, y, width, height, 9.0F, bgColor);
// Head position - centered vertically, offset up a bit for the bar
float headX = x + padding + 2.0F;
float headY = y + (height - headSize - barHeight - 2.0F) / 2.0F;
if (target instanceof PlayerEntity player) {
if (mc.getNetworkHandler() != null) {
PlayerListEntry entry = mc.getNetworkHandler().getPlayerListEntry(player.getUuid());
if (entry != null) {
drawPlayerHeadCustom(r2, entry.getSkinTextures().body().texturePath(), headX, headY, headSize, animation);
}
}
} else {
// Placeholder for non-player entities
int placeholderBg = ColorUtil.replAlpha(ColorUtil.getColor(60, 60, 60, 255), animation * 0.8F);
r2.rect(headX, headY, headSize, headSize, 6.0F, placeholderBg);
r2.pushAlpha(animation);
r2.text(FontRegistry.INTER_MEDIUM, headX + headSize / 2.0F - 6.0F, headY + headSize / 2.0F + 9.0F, 27.0F, "?", ColorUtil.replAlpha(ColorUtil.getColor(200, 200, 200, 255), animation));
r2.popAlpha();
}
// Text positions
float textX = headX + headSize + 12.0F;
float textY = y + 18.0F;
// Get health
float hp = Math.round(target.getHealth());
float maxHp = target.getMaxHealth();
String hpText = (int) hp + "hp";
float hpWidth = r2.measureText(FontRegistry.INTER_MEDIUM, hpText, 27.0F).width;
float hpX = x + width - padding - hpWidth - 3.0F;
// Calculate max name width
float maxNameWidth = hpX - textX - 6.0F;
// Name (truncate if needed)
String name = target instanceof CreeperEntity ? "Creeper" : ru.cylix.module.impl.player.NameProtect.protect(target.getName().getString());
float nameWidth = r2.measureText(FontRegistry.INTER_MEDIUM, name, 27.0F).width;
while (nameWidth > maxNameWidth && name.length() > 1) {
name = name.substring(0, name.length() - 1);
nameWidth = r2.measureText(FontRegistry.INTER_MEDIUM, name, 27.0F).width;
}
r2.pushAlpha(animation);
// Draw name
r2.text(FontRegistry.INTER_MEDIUM, textX, textY, 27.0F, name, -1);
// Draw HP text (dimmed)
int hpTextColor = ColorUtil.replAlpha(ColorUtil.getColor(255, 255, 255, 255), animation * 0.35F);
r2.text(FontRegistry.INTER_MEDIUM, textX, textY + 21.0F, 24.0F, hpText, hpTextColor);
r2.popAlpha();
// Health bar
float barX = x + padding + 3.75F;
float barY = y + height - padding - barHeight - 1.5F;
float barWidth = width - padding * 2.0F - 7.5F;
float percent = Math.min(1.0F, hp / maxHp);
float targetBarWidth = barWidth * percent;
animatedHealthWidth = AnimationMath.animation(animatedHealthWidth, targetBarWidth, 0.15F);
// Draw health bar (just the fill, no background)
if (animatedHealthWidth > 0.0F) {
int barColor = ColorUtil.replAlpha(mainColor, animation);
r2.rect(barX, barY, animatedHealthWidth, barHeight, 2.25F, barColor);
}
}
private static void drawPlayerHeadCustom(Renderer2D r2, Identifier skinTexture, float x, float y, float size, float alpha) {
try {
TextureManager textureManager = mc.getTextureManager();
if (textureManager == null) return;
AbstractTexture texture = textureManager.getTexture(skinTexture);
if (texture == null) return;
if (!(texture.getGlTexture() instanceof GlTexture glTexture)) return;
int textureId = glTexture.getGlId();
if (textureId <= 0) return;
GlStateManager._bindTexture(textureId);
r2.pushAlpha(alpha);
r2.drawRgbaTextureWithUVRounded(textureId, x, y, size, size, 0.125F, 0.125F, 0.25F, 0.25F, 6.0F);
r2.drawRgbaTextureWithUVRounded(textureId, x, y, size, size, 0.625F, 0.125F, 0.75F, 0.25F, 6.0F);
r2.popAlpha();
} catch (Exception ignored) {}
}
public static void renderPendingItems(DrawContext drawContext) {
// Not used in minimal design
}
}