Начинающий
Начинающий
- Статус
- Оффлайн
- Регистрация
- 23 Мар 2025
- Сообщения
- 78
- Реакции
- 0
- Выберите загрузчик игры
- Fabric
Вообщем так как у меня сегодня день рождения решил слить свой таргет худ
Пожалуйста, авторизуйтесь для просмотра ссылки.
Код:
package sweetie.evaware.client.ui.widget.overlay;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.gui.screen.ingame.InventoryScreen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.MathHelper;
import org.joml.Quaternionf;
import org.joml.Vector3f;
import sweetie.evaware.api.utils.animation.AnimationUtil;
import sweetie.evaware.api.utils.color.ColorUtil;
import sweetie.evaware.api.utils.color.UIColors;
import sweetie.evaware.api.utils.math.MathUtil;
import sweetie.evaware.api.utils.render.RenderUtil;
import sweetie.evaware.api.utils.render.ScissorUtil;
import sweetie.evaware.api.utils.render.fonts.Font;
import sweetie.evaware.api.utils.render.fonts.Fonts;
import sweetie.evaware.client.features.modules.combat.AuraModule;
import sweetie.evaware.client.ui.widget.Widget;
import javax.annotation.Nullable;
import java.awt.*;
import java.time.Duration;
public class TargetInfoWidget extends Widget {
@Override
public String getName() {
return "Target info";
}
@Override
public String getEmptyName() {
return "Еще нету активного таргета";
}
public TargetInfoWidget() {
super(30f, 30f);
}
private final AnimationUtil showAnimation = new AnimationUtil();
private float healthAnimation = 0f;
private LivingEntity target;
@Override
public void render(MatrixStack matrixStack) {
update();
LivingEntity pretendTarget = getTarget();
if (pretendTarget != null) {
target = pretendTarget;
}
if (showAnimation.getValue() <= 0.0 || target == null) return;
float anim = (float) showAnimation.getValue();
int fullAlpha = (int) (anim * 255f);
healthAnimation = MathHelper.clamp(
MathUtil.interpolate(healthAnimation, target.getHealth() / target.getMaxHealth(), 0.3f),
0f, 1f
);
float x = getDraggable().getX();
float y = getDraggable().getY();
Font font = Fonts.SF_BOLD;
Font hpfont = Fonts.SF_REGULAR;
float[] headProperties = headProperties(x, y);
float headX = headProperties[0];
float headY = headProperties[1];
float headSize = headProperties[2];
float bigFontSize = headSize * 0.35f;
float smallFontSize = (headSize * 0.4f) * 0.7f;
String targetName = target.getName().getString();
String healthText = String.format("%.1f", target.getHealth() + target.getAbsorptionAmount()) + "HP";
float healthTextWidth = font.getWidth(healthText, smallFontSize);
float offset = getGap() * 3f;
float margin = getGap() * 2f;
float width = headSize * 3.7f + margin * 2f;
float height = headSize + getGap() * 2f;
float backgroundRound = offset * 0.7f;
float[] healthBarProperties = healthBarProperties();
float healthBarHeight = healthBarProperties[0];
float healthBarRound = healthBarProperties[1];
float healthBarY = y + height - healthBarHeight - margin;
float healthBarX = x + headSize + margin;
float healthBarWidth = width - margin * 2.5f - headSize - healthTextWidth;
float diffHealth = Math.abs(smallFontSize - healthBarHeight) / 2f;
float nameDiffToHealthBar = Math.abs((y + margin) - (healthBarY - margin / 2f));
float nameY = y + margin + nameDiffToHealthBar / 2f - bigFontSize / 2f;
RenderUtil.RECT.draw(matrixStack, x, y, width, height, backgroundRound, new Color(35, 34, 34, fullAlpha));
Color textColor = UIColors.textColorWhite(fullAlpha);
font.drawWrap(matrixStack, targetName, healthBarX, nameY,
width - headSize - margin, bigFontSize, textColor,
scaled(9f), Duration.ofMillis(2500), Duration.ofMillis(1700));
font.drawText(matrixStack, healthText,
x + width - healthTextWidth - margin,
healthBarY - diffHealth,
smallFontSize, textColor);
RenderUtil.RECT.draw(matrixStack, healthBarX, healthBarY,
healthBarWidth, healthBarHeight, healthBarRound,
UIColors.backgroundBlur(fullAlpha));
Color color1 = UIColors.gradient(0, fullAlpha);
Color color2 = UIColors.gradient(90, fullAlpha);
RenderUtil.GRADIENT_RECT.draw(matrixStack, healthBarX, healthBarY,
healthBarWidth * healthAnimation, healthBarHeight,
healthBarRound, color1, color2, color1, color2);
if (target instanceof PlayerEntity player) {
if (anim >= 0.50f) {
RenderSystem.setShaderColor(1.12f, 1.08f, 1.02f, 1.0f);
float prevYaw = player.getYaw();
float prevBodyYaw = player.bodyYaw;
float prevHeadYaw = player.headYaw;
player.setYaw(340);
player.bodyYaw = 340;
player.headYaw = 340;
Quaternionf quaternion = new Quaternionf().rotateX((float) Math.toRadians(180));
DrawContext context = new DrawContext(mc, mc.getBufferBuilders().getEntityVertexConsumers());
ScissorUtil.start(matrixStack, headX, headY, headSize, headSize);
InventoryScreen.drawEntity(context, (int) headX + 15, (int) headY + 52, (int) (headSize - 4), new Vector3f(0, 0, 0), quaternion, null, player);
ScissorUtil.stop(matrixStack);
player.setYaw(prevYaw);
player.bodyYaw = prevBodyYaw;
player.headYaw = prevHeadYaw;
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
}
} else {
float headFontSize = headSize * 0.8f;
font.drawCenteredText(matrixStack, "?",
headX + headSize / 2f,
headY + headSize / 2f - headFontSize / 2f,
headFontSize, UIColors.textColorWhite(fullAlpha));
}
getDraggable().setWidth(width);
getDraggable().setHeight(height);
}
private float[] healthBarProperties() {
float height = scaled(5f);
float round = height * 0.3f;
return new float[]{height, round};
}
private float[] headProperties(float xPos, float yPos) {
float x = xPos + getGap();
float y = yPos + getGap();
float size = scaled(25f);
return new float[]{x, y, size};
}
private void update() {
showAnimation.update();
showAnimation.run(getTarget() != null ? 1.0 : 0.0, getDuration(), getEasing());
}
private LivingEntity getTarget() {
AuraModule aura = AuraModule.getInstance();
if (aura.isEnabled() && aura.target != null && aura.target.isAlive() && !aura.target.isRemoved()) {
return aura.target;
}
if (mc.currentScreen instanceof ChatScreen) {
return mc.player;
}
return null;
}
}