Начинающий
Начинающий
- Статус
- Оффлайн
- Регистрация
- 24 Ноя 2024
- Сообщения
- 11
- Реакции
- 0
- Выберите загрузчик игры
- Прочие моды
ТаргетХуд на базу Dreamcore
Нейросеть: использовалась
Коментарии от гпт: удалены
Исходник: был спащен
SS:
Нейросеть: использовалась
Коментарии от гпт: удалены
Исходник: был спащен
TargetHUD:
package ru.etc1337.client.modules.impl.render.ui;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.scoreboard.Score;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import ru.etc1337.Client;
import ru.etc1337.api.TempColor;
import ru.etc1337.api.animations.simple.Animation;
import ru.etc1337.api.animations.simple.Easing;
import ru.etc1337.api.color.FixColor;
import ru.etc1337.api.events.Event;
import ru.etc1337.api.events.impl.render.EventRender2D;
import ru.etc1337.api.render.Rect;
import ru.etc1337.api.render.fonts.Fonts;
import ru.etc1337.api.render.shaders.impl.Round;
import ru.etc1337.api.timer.Timer;
import ru.etc1337.client.modules.impl.render.ui.api.ElementInfo;
import ru.etc1337.client.modules.impl.render.ui.api.UIElement;
@ElementInfo(name = "TargetHud", initX = 300.0F, initY = 300.0F, initHeight = 35.0F)
public class TargetHudRenderer extends UIElement {
private final Timer stopWatch = new Timer();
private LivingEntity entity = null;
private boolean allow;
private final Animation animationScale = new Animation(Easing.SINE_IN_OUT, 200);
private float animatedHealth = 0.0f;
private float animatedAbsorption = 0.0f;
@Override
public void onEvent(Event event) {
if (event instanceof EventRender2D eventRender2D) {
render(eventRender2D);
}
}
private void render(EventRender2D eventRender2D) {
MatrixStack ms = eventRender2D.getMatrixStack();
entity = getTarget(entity);
boolean out = !allow || stopWatch.finished(1000);
animationScale.update(out ? 0 : 1);
float scale = animationScale.getValue();
if (scale < 0.05f) return;
if (entity != null) {
float posX = getDraggable().getX();
float posY = getDraggable().getY();
float spacing = 5;
float headSize = 25;
float headBoxSize = headSize + 10;
float width = 120;
float height = 35;
getDraggable().setWidth(width + 5);
getDraggable().setHeight(height);
float hp = entity.getHealth();
float maxHp = entity.getMaxHealth();
float absorption = entity.getAbsorptionAmount();
Score score = mc.world.getScoreboard().getOrCreateScore(
entity.getScoreboardName(),
mc.world.getScoreboard().getObjectiveInDisplaySlot(2)
);
if (entity instanceof PlayerEntity && score.getScorePoints() != 0) {
hp = score.getScorePoints();
}
animatedHealth = lerp(animatedHealth, hp, 40f);
animatedAbsorption = lerp(animatedAbsorption, absorption, 40f);
float alpha = 255 * scale;
float centerX = posX + width / 2f;
float centerY = posY + height / 2f;
ms.push();
ms.translate(centerX, centerY, 0);
ms.scale(scale, scale, 1);
ms.translate(-centerX, -centerY, 0);
Rect headRect = new Rect(posX, posY, headBoxSize, height);
FixColor headBg = new FixColor(0, 0, 0, (int)(180 * scale));
Round.draw(ms, headRect, 5, 5, 5, 5, headBg);
Rect infoRect = new Rect(posX + headBoxSize + 3, posY, width - headBoxSize - 3, height);
FixColor infoBg = new FixColor(0, 0, 0, (int)(180 * scale));
Round.draw(ms, infoRect, 5, 5, 5, 5, infoBg);
float headX = posX + (headBoxSize - headSize) / 2f;
float headY = posY + (height - headSize) / 2f;
if (entity instanceof AbstractClientPlayerEntity player) {
Round.drawFace(new Rect(headX, headY, headSize, headSize), 5f, scale, player);
} else {
float glowSize = 30;
ru.etc1337.api.render.shaders.impl.Glow.draw(ms, new Rect(
headX - 2, headY, headSize + 4, headSize + 4
), glowSize, 1.0f, glowSize / 2,
TempColor.getClientColor().alpha((int)(alpha * 0.3f)),
TempColor.getClientColor().alpha((int)(alpha * 0.3f)),
TempColor.getClientColor().alpha((int)(alpha * 0.3f)),
TempColor.getClientColor().alpha((int)(alpha * 0.3f)));
Fonts.SEMIBOLD_28.drawCenter(ms, "?", headX + headSize / 2f, headY + 4,
TempColor.getClientColor().alpha((int)(255 * scale)).getRGB());
}
String name = entity.getName().getString();
if (name.length() > 12) {
name = name.substring(0, 12) + "...";
}
float nameX = posX + headBoxSize + 8;
Fonts.MEDIUM_13.draw(ms, name, nameX, posY + 5.5f,
new FixColor(TempColor.getFontColor()).alpha((int)(255 * scale)).getRGB());
float barX = nameX;
float barY = posY + 22;
float barWidth = width - headBoxSize - 13;
float barHeight = 7;
Round.draw(ms, new Rect(barX, barY, barWidth, barHeight), 1.75f,
new FixColor(0, 0, 0).alpha((int)(25 * scale)));
float healthPercent = MathHelper.clamp(animatedHealth / maxHp, 0, 1);
Round.draw(ms, new Rect(barX, barY, barWidth * healthPercent, barHeight), 1.75f,
new FixColor(255, 255, 255).alpha((int)(255 * scale)));
if (animatedAbsorption > 0.1f) {
float absorptionPercent = MathHelper.clamp(animatedAbsorption / maxHp, 0, 1);
float absorptionStart = barWidth * healthPercent;
float absorptionWidth = barWidth * absorptionPercent;
if (absorptionStart + absorptionWidth > barWidth) {
absorptionWidth = barWidth - absorptionStart;
}
Round.draw(ms, new Rect(barX + absorptionStart, barY, absorptionWidth, barHeight), 1.75f,
new FixColor(255, 255, 255).alpha((int)(120 * scale)));
}
String healthText = String.format("HP: %.1f", hp + absorption);
Fonts.MEDIUM_12.draw(ms, healthText, barX, posY + height / 2 - 3,
new FixColor(TempColor.getFontColor()).alpha((int)(255 * scale)).getRGB());
ms.pop();
}
}
private LivingEntity getTarget(LivingEntity currentTarget) {
LivingEntity auraTarget = Client.getInstance().getModuleManager().get(
ru.etc1337.client.modules.impl.combat.KillAura.class).getTarget();
LivingEntity target = currentTarget;
if (auraTarget != null) {
stopWatch.reset();
allow = true;
target = auraTarget;
if (currentTarget != auraTarget) {
animatedHealth = auraTarget.getHealth();
animatedAbsorption = auraTarget.getAbsorptionAmount();
}
} else if (mc.currentScreen instanceof ChatScreen) {
stopWatch.reset();
allow = true;
target = mc.player;
if (currentTarget != mc.player) {
animatedHealth = mc.player.getHealth();
animatedAbsorption = mc.player.getAbsorptionAmount();
}
} else {
allow = false;
}
return target;
}
private float lerp(float current, float target, float speed) {
return current + (target - current) / speed;
}
}
