Начинающий
- Статус
- Оффлайн
- Регистрация
- 5 Сен 2025
- Сообщения
- 131
- Реакции
- 4
- Выберите загрузчик игры
- OptiFine
Всем привет!
сегодня Я сливаю вам свой TargetHud под стиль вексайда и с добавкой своего.
ss -
методы не дам заменяйте на своё!
Код ниже:
сегодня Я сливаю вам свой TargetHud под стиль вексайда и с добавкой своего.
ss -
методы не дам заменяйте на своё!
Код ниже:
Код:
package femboy.dlc.display.display.impl;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import femboy.dlc.events.EventDisplay;
import femboy.dlc.main.FemboyDLC;
import femboy.dlc.display.display.ElementRenderer;
import femboy.dlc.modules.impl.render.HUD;
import femboy.dlc.util.client.draggings.Dragging;
import femboy.dlc.util.math.main.MathUtil;
import femboy.dlc.util.math.main.StopWatch;
import femboy.dlc.util.visual.animation.Direction;
import femboy.dlc.util.visual.animation.impl.EaseBackIn;
import femboy.dlc.util.visual.animation.impl.EaseInOutQuad;
import femboy.dlc.util.visual.components.Scissor;
import femboy.dlc.util.visual.main.color.ColorUtils;
import femboy.dlc.util.visual.main.display.DisplayUtils;
import femboy.dlc.util.visual.main.display.Round;
import femboy.dlc.util.visual.main.fonts.Fonts;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.scoreboard.Score;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
@FieldDefaults(level = AccessLevel.PRIVATE)
@RequiredArgsConstructor
public class TargetInfoRenderer implements ElementRenderer {
final StopWatch stopWatch = new StopWatch();
final Dragging drag;
LivingEntity entity = null;
boolean allow;
final EaseInOutQuad fadeAnimation = new EaseInOutQuad(655, 1.0, Direction.FORWARDS);
final EaseBackIn fadeAnimation2 = new EaseBackIn(655, 1.0, Direction.FORWARDS.ordinal());
float currentAlpha = 0f;
float healthAnimation = 0.0f;
float absorptionAnimation = 0.0f;
float displayedHealth = 0f;
float targetHealth = 0f;
private long lastHealthUpdateTime = 0;
private float hitAnimationProgress = 0.5f;
private boolean wasHit = false;
private float nameScrollOffset = 0f;
private long lastScrollTime = 0;
private final float scrollSpeed = 0.5f;
private long damageFlashTimer = 0;
private boolean isFlashing = false;
private float flashProgress = 0f;
private int targetCircleColor;
private int currentCircleColor;
final HUD hud;
@Override
public void render(EventDisplay eventDisplay) {
MatrixStack ms = eventDisplay.getMatrixStack();
entity = getTarget(entity);
boolean out = !allow || stopWatch.isReached(1000);
fadeAnimation.setDuration(out ? 200 : 200);
fadeAnimation.setDirection(out ? Direction.BACKWARDS : Direction.FORWARDS);
fadeAnimation2.setDuration(out ? 255 : 200);
fadeAnimation2.setDirection(out ? Direction.BACKWARDS : Direction.FORWARDS);
currentAlpha = (float) fadeAnimation.getOutput();
if (currentAlpha <= 0.01f) {
entity = null;
displayedHealth = 0f;
targetHealth = 0f;
return;
}
if (entity != null) {
float posX = drag.getX();
float posY = drag.getY();
float width = 175;
float height = 45;
drag.setWidth(width);
drag.setHeight(height);
float maxHp = entity.getMaxHealth();
float hp = entity.getHealth();
float absorption = entity.getAbsorptionAmount();
Score score = mc.world.getScoreboard().getOrCreateScore(entity.getScoreboardName(),
mc.world.getScoreboard().getObjectiveInDisplaySlot(2));
String header = mc.ingameGUI.getTabList().header == null ? " " : mc.ingameGUI.getTabList().header.getString().toLowerCase();
if (mc.getCurrentServerData() != null && mc.getCurrentServerData().serverIP.contains("funtime")
&& (header.contains("анархия") || header.contains("гриферский")) && entity instanceof PlayerEntity) {
hp = score.getScorePoints();
maxHp = 20;
}
if (targetHealth == 0f || entity != getTarget(null)) {
targetHealth = hp;
displayedHealth = hp;
lastHealthUpdateTime = System.currentTimeMillis();
wasHit = false;
}
if (Math.abs(targetHealth - hp) > 0.01f) {
targetHealth = hp;
lastHealthUpdateTime = System.currentTimeMillis();
wasHit = true;
hitAnimationProgress = 0f;
}
long timeSinceUpdate = System.currentTimeMillis() - lastHealthUpdateTime;
float animationDuration = 300f;
if (timeSinceUpdate < animationDuration) {
float progress = Math.min(1f, timeSinceUpdate / animationDuration);
displayedHealth = MathUtil.lerp(displayedHealth, targetHealth, progress * 0.5f);
} else {
displayedHealth = targetHealth;
}
if (wasHit) {
hitAnimationProgress += 0.15f;
if (hitAnimationProgress >= 1f) {
wasHit = false;
}
}
healthAnimation = MathUtil.fast(healthAnimation, MathHelper.clamp(hp / maxHp, 0, 1), 10);
absorptionAnimation = MathUtil.fast(absorptionAnimation, MathHelper.clamp(absorption / maxHp, 0, 1), 10);
if (currentCircleColor == 0) {
currentCircleColor = HUD.getColor(0);
targetCircleColor = HUD.getColor(0);
}
RenderSystem.pushMatrix();
RenderSystem.translatef(posX + width / 2, posY + height / 2, 0);
RenderSystem.scalef(currentAlpha, currentAlpha, 1f);
RenderSystem.translatef(-(posX + width / 2), -(posY + height / 2), 0);
drawStyledRect(ms, posX, posY, width, height, 5);
float headSize = 28;
float spacing = 6;
float hurtPercent = (entity.hurtTime - (entity.hurtTime != 0 ? mc.timer.renderPartialTicks : 0.0f)) / 10.0f;
String rs = EntityType.getKey(entity.getType()).getPath();
ResourceLocation skin = entity instanceof AbstractClientPlayerEntity e ? e.getLocationSkin() : new ResourceLocation("textures/entity/" + rs + ".png");
DisplayUtils.drawHead(skin, posX + spacing, posY + spacing + 1, headSize, headSize, 5f, 1f, hurtPercent);
float scissorX = posX;
float scissorY = posY;
float scissorWidth = width;
float scissorHeight = height;
Scissor.push();
Scissor.setFromComponentCoordinates(scissorX, scissorY, scissorWidth, scissorHeight);
String originalName = entity.getName().getString();
float nameX = posX + headSize + spacing * 2.2f;
float nameY = posY + spacing + 5;
float maxNameWidth = width - headSize - spacing * 3.5f - 30;
String displayName = originalName;
boolean shouldScroll = false;
float nameWidth = Fonts.sfpro.getWidth(originalName, 10);
if (originalName.length() > 16) {
displayName = originalName.substring(0, 16) + "...";
nameWidth = Fonts.sfpro.getWidth(displayName, 10);
shouldScroll = false;
} else {
shouldScroll = nameWidth > maxNameWidth;
}
int textAlpha = (int) (255 * currentAlpha);
Scissor.push();
Scissor.setFromComponentCoordinates(nameX, nameY, maxNameWidth + 5, 12);
if (shouldScroll) {
long currentTime = System.currentTimeMillis();
long delta = currentTime - lastScrollTime;
lastScrollTime = currentTime;
nameScrollOffset += scrollSpeed * (delta / 16f);
if (nameScrollOffset >= nameWidth + 20) {
nameScrollOffset = 0f;
}
Fonts.sfpro.drawText(ms, originalName, nameX - nameScrollOffset, nameY, ColorUtils.rgba(255, 255, 255, textAlpha), 10);
Fonts.sfpro.drawText(ms, originalName, nameX - nameScrollOffset + nameWidth + 20, nameY, ColorUtils.rgba(255, 255, 255, textAlpha), 10);
} else {
Fonts.sfpro.drawText(ms, displayName, nameX, nameY, ColorUtils.rgba(255, 255, 255, textAlpha), 10);
}
Scissor.pop();
Scissor.pop();
float bigCircleRadius = 12;
float bigCircleX = posX + width - bigCircleRadius - spacing - 2;
float bigCircleY = posY + spacing + 16.5f;
float smallCircleRadius = 7;
float smallCircleX = bigCircleX - bigCircleRadius - smallCircleRadius - 5;
float smallCircleY = bigCircleY + 6;
int bgAlpha = (int) (200 * currentAlpha);
int fillAlpha = (int) (255 * currentAlpha);
long currentTime = System.currentTimeMillis();
if (wasHit && !isFlashing) {
isFlashing = true;
damageFlashTimer = currentTime;
targetCircleColor = ColorUtils.rgba(220, 50, 50, fillAlpha);
flashProgress = 0f;
} else if (isFlashing) {
long elapsed = currentTime - damageFlashTimer;
flashProgress = Math.min(1.0f, elapsed / 1000f);
if (flashProgress >= 1.0f) {
isFlashing = false;
targetCircleColor = HUD.getColor(0);
}
}
if (hp > targetHealth && isFlashing) {
isFlashing = false;
targetCircleColor = HUD.getColor(0);
flashProgress = 0f;
}
currentCircleColor = ColorUtils.interpolate(currentCircleColor, targetCircleColor, 0.15f);
float hpPercent = MathHelper.clamp(displayedHealth / maxHp, 0.0f, 1.0f);
DisplayUtils.drawCircleWithFill(bigCircleX, bigCircleY, 0, 360, bigCircleRadius, 3, false, ColorUtils.rgba(40, 40, 40, bgAlpha));
int healthFillColor = displayedHealth >= maxHp ? HUD.getColor(0) : currentCircleColor;
DisplayUtils.drawCircleWithFill(bigCircleX, bigCircleY, 0, 360 * hpPercent, bigCircleRadius, 3, false, healthFillColor);
String hpText = String.valueOf((int) displayedHealth);
Fonts.sfpro.drawCenteredText(ms, hpText, bigCircleX, bigCircleY - 4, ColorUtils.rgba(255, 255, 255, textAlpha), 9);
float absPercent = MathHelper.clamp(absorption / 16.0f, 0.0f, 1.0f);
float absorptionHearts = absorption / 2.0f;
if (absorptionHearts > 0.1f) {
DisplayUtils.drawCircleWithFill(smallCircleX, smallCircleY, 0, 360, smallCircleRadius, 2.5f, false, ColorUtils.rgba(40, 40, 40, bgAlpha));
int absFillColor = ColorUtils.rgba(255, 215, 0, fillAlpha);
DisplayUtils.drawCircleWithFill(smallCircleX, smallCircleY, 0, 360 * absPercent, smallCircleRadius, 2.5f, false, absFillColor);
String absText = String.format("%.0f", absorptionHearts);
Fonts.sfpro.drawCenteredText(ms, absText, smallCircleX - 0.3f, smallCircleY - 3, ColorUtils.rgba(255, 255, 255, textAlpha), 7);
}
Scissor.push();
Scissor.setFromComponentCoordinates(scissorX, scissorY, scissorWidth, scissorHeight);
float armorY = posY + spacing + 17;
float itemSpacing = 2;
float itemScale = 0.80f;
float itemSize = 16 * itemScale;
if (entity instanceof PlayerEntity player) {
float currentX = posX + headSize + spacing * 3.8f - 12;
currentX += 1;
ItemStack mainHand = player.getHeldItemMainhand();
if (!mainHand.isEmpty()) {
renderItem(mainHand, currentX, armorY, itemScale);
currentX += itemSize + itemSpacing;
}
for (int i = 0; i < 4; i++) {
ItemStack armorPiece = player.inventory.armorInventory.get(3 - i);
if (!armorPiece.isEmpty()) {
renderItem(armorPiece, currentX, armorY, itemScale);
}
currentX += itemSize + itemSpacing;
}
}
Scissor.unset();
Scissor.pop();
RenderSystem.popMatrix();
}
}
private void renderItem(ItemStack stack, float x, float y, float scale) {
if (stack.isEmpty()) return;
RenderSystem.pushMatrix();
RenderSystem.translatef(x, y, 0.0f);
RenderSystem.scalef(scale, scale, 1.0f);
mc.getItemRenderer().renderItemAndEffectIntoGUI(stack, 1, 0);
mc.getItemRenderer().renderItemOverlayIntoGUI(mc.fontRenderer, stack, 0, 0, null);
RenderSystem.popMatrix();
}
private void drawStyledRect(MatrixStack ms, float x, float y, float width, float height, float radius) {
DisplayUtils.Rounded.smooth(ms, x, y, width, height, ColorUtils.rgb("#0F0D16"), 10);
if (hud.outlineEnabled.get()) {
float thickness = hud.outlineThickness.get();
int outlineColor = getOutlineColor();
DisplayUtils.Rounded.roundedOutline(ms, x, y, width, height, thickness, outlineColor, Round.of(9));
}
}
private int getOutlineColor() {
return switch (hud.outlineColorMode.get()) {
case "Градиент" -> HUD.getColor(5);
case "Статичный" -> ColorUtils.rgba(35, 35, 35, 255);
case "Акцент" -> HUD.getColor(5);
default -> ColorUtils.rgba(35, 45, 35, 255);
};
}
private LivingEntity getTarget(LivingEntity nullTarget) {
LivingEntity auraTarget = FemboyDLC.getInstance().getFunctionRegistry().getKillAura().getTarget();
LivingEntity target = nullTarget;
if (auraTarget != null) {
stopWatch.reset();
allow = true;
target = auraTarget;
} else if (mc.currentScreen instanceof ChatScreen) {
stopWatch.reset();
allow = true;
target = mc.player;
} else {
allow = false;
}
return target;
}
}