Начинающий
- Статус
- Оффлайн
- Регистрация
- 23 Сен 2024
- Сообщения
- 315
- Реакции
- 0
- Выберите загрузчик игры
- Прочие моды
Решил заскидить таргет худ катлавана на экспу 3.1, кто сможет тот перенесёт
SS:
DW:
SS:
DW:
TargetHUD:
package vesencePackage.display.hud.impl;
import net.minecraft.util.math.vector.Vector3d;
import org.json.XML;
import vesencePackage.events.AttackEvent;
import vesencePackage.main.Client;
import vesencePackage.main.module.impl.combat.TriggerBot;
import vesencePackage.main.module.impl.misc.Theme;
import vesencePackage.util.display.animations.newanim.Animation;
import com.google.common.eventbus.Subscribe;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import net.minecraft.client.entity.player.AbstractClientPlayerEntity;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
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 vesencePackage.events.EventRenderer2D;
import vesencePackage.main.module.impl.visuals.HUD;
import vesencePackage.display.hud.ElementRenderer;
import vesencePackage.util.client.ClientUtil;
import vesencePackage.util.display.text.ColorFormatting;
import vesencePackage.util.drag.Dragging;
import vesencePackage.util.math.MathUtil;
import vesencePackage.util.math.StopWatch;
import vesencePackage.util.display.render.*;
import vesencePackage.util.display.render.font.Fonts;
import ru.hogoshi.util.Easings;
import vesencePackage.util.normalFont.ExcFonts;
import java.util.concurrent.ThreadLocalRandom;
@FieldDefaults(level = AccessLevel.PRIVATE)
@RequiredArgsConstructor
public class TargetInfoRenderer implements ElementRenderer {
final StopWatch stopWatch = new StopWatch();
final Dragging drag;
LivingEntity entity = null;
boolean allow;
private static final ru.hogoshi.Animation globalAnim = new ru.hogoshi.Animation();
private static final ru.hogoshi.Animation blurAnim = new ru.hogoshi.Animation();
private final Animation animationScale = new Animation();
float healthAnimation = 0.0f;
float healthTrailAnimation = 0.0f;
float absorptionAnimation = 0.0f;
float absorptionTrailAnimation = 0.0f;
int headSize = 28;
float spacing = 5;
float health = 0;
float displayedHealth = 0;
public void onAttack(AttackEvent e) {
if (e.entity == mc.player) {
return;
}
if (entity == null) {
return;
}
if (e.entity instanceof LivingEntity) {
for (int i = 0; i < 7; ++i) {
Client.getInstance().getModuleManager().getHud().getParticles().add(new TargetInfoRenderer.HeadParticle(new Vector3d(drag.getX() + spacing + headSize / 2f, drag.getY() + spacing + headSize / 2f, 0.0)));
}
}
}
@Subscribe
public void render(EventRenderer2D EventRenderer2D) {
MatrixStack ms = EventRenderer2D.getMatrixStack();
float size;
entity = getTarget(entity);
boolean out = !allow || stopWatch.isReached(1000);
globalAnim.update();
blurAnim.update();
globalAnim.animate(out ? 0: 1, 0.9f, Easings.EXPO_OUT);
blurAnim.animate(out ? 0: 1, 0, Easings.EXPO_OUT);
animationScale.update();
animationScale.run(
out ? 0 : 1,
0.2,
out
? vesencePackage.util.display.animations.newanim.util.Easings.BACK_IN
: vesencePackage.util.display.animations.newanim.util.Easings.BACK_OUT,
true
);
FloatFormatter formatter = new FloatFormatter();
if (entity != null) {
boolean showAbsorptionBar = Client.getInstance().getModuleManager().getHud().gHP.get();
final int GOLD_COLOR = ColorUtil.rgb(255, 162, 23);
float posX = drag.getX();
float posY = drag.getY();
float spacing = 5;
float width = 105;
float height = 35;
drag.setWidth(width + 5);
drag.setRound(5);
drag.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 && Client.getInstance().getModuleManager().getScoreboardHP().isEnabled()) {
if (score.getScorePoints() != 0){
hp = score.getScorePoints();
}
}
float totalMaxHP = maxHp;
float targetHealth;
if (showAbsorptionBar) {
targetHealth = MathHelper.clamp(hp / totalMaxHP, 0, 1);
} else {
targetHealth = MathHelper.clamp((hp + absorption) / totalMaxHP, 0, 1);
}
float targetAbsorption = MathHelper.clamp(absorption / totalMaxHP, 0, 1);
healthAnimation = MathUtil.fast(healthAnimation, targetHealth, 2);
healthTrailAnimation = MathUtil.fast(healthTrailAnimation, targetHealth, targetHealth < healthTrailAnimation ? 2 : 5);
absorptionAnimation = MathUtil.fast(absorptionAnimation, targetAbsorption, 5);
absorptionTrailAnimation = MathUtil.fast(absorptionTrailAnimation, targetAbsorption, targetAbsorption < absorptionTrailAnimation ? 2 : 5);
float finalHp;
if (ClientUtil.isConnectedToServer("funtime") || ClientUtil.isConnectedToServer("mc.reallyworld.ru") || ClientUtil.isConnectedToServer("play.saturn-x.space")) {
finalHp = formatter.format(hp);
} else if (showAbsorptionBar) {
finalHp = formatter.format(hp);
} else {
finalHp = formatter.format((hp + absorption));
}
String absorptionText = "";
if (showAbsorptionBar && absorption > 0.0) {
absorptionText = " (" + ColorFormatting.getColor(ColorUtil.getColor(255,201,94, (int) (255 * globalAnim.getValue()))) + formatter.format(absorption) + ColorFormatting.reset() + ")";
}
String fullHealthText1 = "HP: " + ColorFormatting.getColor(ColorUtil.setAlpha(Theme.ClientColor(),(int) (255 * globalAnim.getValue()))) + finalHp + ColorFormatting.reset() + absorptionText;
int healthColor = getHealthColor(hp, maxHp);
GlStateManager.pushMatrix();
float scale = animationScale.get();
float centerX = posX + width / 2f;
float centerY = posY + height / 2f;
GlStateManager.translatef(centerX, centerY, 0);
GlStateManager.scalef(scale, scale, 1);
GlStateManager.translatef(-centerX, -centerY, 0);
HUD.drawStyledTargetRect(posX, posY, 35, height,5, (float) globalAnim.getValue());
HUD.drawStyledOtherRect(posX + 40, posY, width - 35, height,5, (float) globalAnim.getValue());
float hurtPercent = (entity.hurtTime - (entity.hurtTime != 0 ? mc.timer.renderPartialTicks : 0.0f)) / 10.0f;
hurtPercent = MathHelper.clamp(hurtPercent, 0.0f, 1.0f);
float redIntensity = 0.4f * hurtPercent;
float eased = (float) Easings.QUAD_OUT.ease(hurtPercent);
String rs = EntityType.getKey(((Entity) entity).getType()).getPath();
ResourceLocation skin = entity instanceof AbstractClientPlayerEntity e ? e.getLocationSkin() : new ResourceLocation("textures/entity/" + rs + ".png");
RenderSystem.pushMatrix();
RenderSystem.translatef(posX + 0.5f + headSize / 2f, posY + 1 + headSize / 2f, 0);
RenderSystem.translatef(-headSize / 2f, -headSize / 2f, 0);
float alpha = 1.0f - hurtPercent * 0.5f;
RenderUtil.drawHead(skin, 1, 0.5f, 28, 28, 3, (float) (alpha * globalAnim.getValue()), redIntensity);
RenderSystem.popMatrix();
float circleY = posY + height / 2;
float barX = posX + spacing + spacing + 35;
float barY = posY + 24;
float barWidth = width - 45;
float barHeight = 7;
float roundBar = 1.75f;
int barColor = HUD.HPcolor.is("От темы") ? Theme.ClientColorSecondary() : healthColor;
int barColor2 = HUD.HPcolor.is("От темы") ? Theme.ClientColorOne() : ColorUtil.multDark(healthColor, 0.8f);
RenderUtil.Rounded.smooth(ms, barX, barY, barWidth, barHeight,
ColorUtil.setAlpha(ColorUtil.getColor(0), (int) (25 * globalAnim.getValue())), Round.of(roundBar));
if(HUD.HPtrail.get()) RenderUtil.Rounded.smooth(ms, barX, barY, barWidth * healthTrailAnimation, barHeight,
ColorUtil.setAlpha(barColor, (int) (25 * globalAnim.getValue())),
ColorUtil.setAlpha(barColor2, (int) (75 * globalAnim.getValue())), Round.of(roundBar));
RenderUtil.Rounded.smooth(ms, barX, barY, barWidth * healthAnimation, barHeight,
ColorUtil.setAlpha(barColor, (int) (190 * globalAnim.getValue())),
ColorUtil.setAlpha(barColor2, (int) (190 * globalAnim.getValue())), Round.of(roundBar));
if (showAbsorptionBar && absorption > 0.0) {
float absorptionEnd = barWidth * absorptionTrailAnimation;
RenderUtil.Rounded.smooth(ms, barX, barY, absorptionEnd, barHeight,
ColorUtil.setAlpha(GOLD_COLOR, (int) (25 * globalAnim.getValue())),
ColorUtil.setAlpha(GOLD_COLOR, (int) (75 * globalAnim.getValue())), Round.of(roundBar));
float absorptionFinal = barWidth * absorptionAnimation;
RenderUtil.Rounded.smooth(ms, barX, barY, absorptionFinal, barHeight,
ColorUtil.setAlpha(ColorUtil.multDark(GOLD_COLOR,0.3f), (int) (255 * globalAnim.getValue())),
ColorUtil.setAlpha(GOLD_COLOR, (int) (255 * globalAnim.getValue())), Round.of(roundBar));
}
ExcFonts.SFUI.draw(ms, fullHealthText1, posX + spacing + spacing + 35, circleY - 3,
ColorUtil.reAlphaInt(-1, (int) (255 * globalAnim.getValue())), 7.5f);
Stencil.uninitStencilBuffer();
Scissor.push();
Scissor.setFromComponentCoordinates(posX,posY,width - 5,height);
ExcFonts.SFUI.draw(EventRenderer2D.getMatrixStack(), entity.getName().getString(), posX + spacing + spacing + 35, (float) (posY + 5.5f), ColorUtil.reAlphaInt(-1,(int) (255 * globalAnim.getValue())), 7.5f);
Scissor.unset();
Scissor.pop();
if (Client.getInstance().getModuleManager().getHud().particlesOnTarget.getValue()) {
for (HeadParticle p : Client.getInstance().getModuleManager().getHud().getParticles()) {
if (System.currentTimeMillis() - p.time > 2000L) {
Client.getInstance().getModuleManager().getHud().getParticles().remove(p);
}
p.update();
size = 1.0f - (float)(System.currentTimeMillis() - p.time) / 2000.0f;
RenderUtil.drawImage(new ResourceLocation("vesence/particle/glow.png"),(float)p.pos.x - 6, (float)p.pos.y - 4, 8,8, ColorUtil.setAlpha(Theme.ClientColor(), (int)(125 * p.alpha * size * globalAnim.getValue())));
}
}
GlStateManager.popMatrix();
}
}
private int getHealthColor(float health, float maxHealth) {
float percent = health / maxHealth;
if (percent > 0.7f) {
return ColorUtil.rgb(89, 171, 77);
} else if (percent > 0.3f) {
return ColorUtil.rgb(171, 155, 77);
} else {
return ColorUtil.rgb(171, 77, 77);
}
}
private LivingEntity getTarget(LivingEntity currentTarget) {
// Получаем цель из Aura
LivingEntity auraTarget = Client.getInstance().getModuleManager().getAura().target;
// Получаем цель из TriggerBot
LivingEntity triggerBotTarget = getTriggerBotTarget();
LivingEntity target = currentTarget;
if (auraTarget != null) {
stopWatch.reset();
allow = true;
target = auraTarget;
} else if (triggerBotTarget != null) {
stopWatch.reset();
allow = true;
target = triggerBotTarget;
} else if (mc.currentScreen instanceof ChatScreen) {
stopWatch.reset();
allow = true;
target = mc.player;
} else {
allow = false;
}
return target;
}
// Новый метод для получения цели из TriggerBot
private LivingEntity getTriggerBotTarget() {
TriggerBot triggerBot = Client.getInstance().getModuleManager().getTriggerBot();
if (triggerBot != null && triggerBot.isEnabled()) {
// Получаем текущую цель триггер-бота
Entity entity = triggerBot.getCurrentTarget();
if (entity instanceof LivingEntity) {
return (LivingEntity) entity;
}
}
return null;
}
public static class HeadParticle {
private Vector3d pos;
private final Vector3d end;
private final long time;
private float alpha;
public HeadParticle(Vector3d pos) {
this.pos = pos;
this.end = pos.add((double)(-ThreadLocalRandom.current().nextFloat(-80.0F, 80.0F)), (double)(-ThreadLocalRandom.current().nextFloat(-80.0F, 80.0F)), (double)(-ThreadLocalRandom.current().nextFloat(-80.0F, 80.0F)));
this.time = System.currentTimeMillis();
}
public void update() {
this.alpha = MathUtil.lerp(this.alpha, 1.0F, 10.0F);
this.pos = MathUtil.fast(this.pos, this.end, 0.5F);
}
}
public class FloatFormatter {
public float format(float value) {
float multiplier = 10.0f;
return Math.round(value * multiplier) / multiplier;
}
}
}
