Исходник TargetHUD Expensive 4.0 skid | <3 | 3.1 Ready

Воу братишка как тебе таргетхуд?


  • Всего проголосовало
    81
Новичок
Статус
Оффлайн
Регистрация
16 Ноя 2024
Сообщения
1
Реакции[?]
0
Поинты[?]
0
для тупых пастеров вот вам код для exp 3.1
Target hud:
package im.expensive.ui.display.impl;

import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import im.expensive.Expensive;
import im.expensive.events.EventDisplay;
import im.expensive.functions.impl.render.HUD;
import im.expensive.ui.display.ElementRenderer;
import im.expensive.ui.styles.Style;
import im.expensive.utils.animations.Animation;
import im.expensive.utils.animations.Direction;
import im.expensive.utils.animations.impl.EaseBackIn;
import im.expensive.utils.drag.Dragging;
import im.expensive.utils.math.MathUtil;
import im.expensive.utils.math.StopWatch;
import im.expensive.utils.math.Vector4i;
import im.expensive.utils.render.ColorUtils;
import im.expensive.utils.render.DisplayUtils;
import im.expensive.utils.render.Scissor;
import im.expensive.utils.render.Stencil;
import im.expensive.utils.render.font.Fonts;
import lombok.AccessLevel;
import lombok.experimental.FieldDefaults;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.renderer.entity.EntityRenderer;
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 net.minecraft.util.math.vector.Vector4f;
import net.minecraft.util.text.TextFormatting;
import org.lwjgl.opengl.GL11;

@FieldDefaults(level = AccessLevel.PRIVATE)
public class TargetInfoRenderer implements ElementRenderer {
    final StopWatch stopWatch = new StopWatch();
    final Dragging drag;
    LivingEntity entity = null;
    boolean shouldToBack;
    final Animation animation = new EaseBackIn(400, 1, 1);
    float healthAnimation = 0.0f, absorptionAnimation = 0.0f;
    float healthAnimation2 = 0.0f, absorptionAnimation2 = 0.0f;
    float posX, posY;

    static final float width = 102;
    static final float height = 38;
    static final float spacing = 4;
    static final float rounding = 4;
    static final float headSize = 22;

    public TargetInfoRenderer(Dragging drag) {
        this.drag = drag;
    }

    [USER=1367676]@override[/USER]
    public void render(EventDisplay eventDisplay) {
        posX = drag.getX();
        posY = drag.getY();
        entity = getTarget(entity);
        boolean backAnimation = !shouldToBack || stopWatch.isReached(1000);
        animation.setDuration(backAnimation ?500 : 700);
        animation.setDirection(backAnimation ? Direction.BACKWARDS : Direction.FORWARDS);

        if (animation.getOutput() == 0.0f) {
            entity = null;
        }

        if (entity != null) {
            drag.setWidth(width);
            drag.setHeight(height);

            float health = fix1000Health(entity.getHealth());
            float maxHealth = MathHelper.clamp(entity.getMaxHealth(), 0, 24);
            float maxHealth2 = MathHelper.clamp(entity.getMaxHealth(), 0, 26);

            healthAnimation = MathUtil.fast(healthAnimation,
                    MathHelper.clamp(health / maxHealth, 0, 1), 2);
            absorptionAnimation = MathUtil.fast(absorptionAnimation,
                    MathHelper.clamp(entity.getAbsorptionAmount() / maxHealth, 0, 1), 2);

            healthAnimation2 = MathUtil.fast(healthAnimation2,        MathHelper.clamp(health / (maxHealth2 / 8), 0, 1), 1);
            absorptionAnimation2 = MathUtil.fast(absorptionAnimation2,        MathHelper.clamp(entity.getAbsorptionAmount() / (maxHealth2 / 4), 0, 1), 1);

            GlStateManager.pushMatrix();
            setSizeAnimation(animation.getOutput());
            drawBackGround(rounding);
            renderTextThatDisplaysTargetInfo(eventDisplay.getMatrixStack());
            drawTargetHead(entity, posX +  spacing, posY + spacing+2, headSize, headSize);
            renderHealthBar();
            GlStateManager.popMatrix();
        }
    }

    private LivingEntity getTarget(LivingEntity nullTarget) {
        LivingEntity auraTarget = Expensive.getInstance().getFunctionRegistry().getKillAura().getTarget();
        LivingEntity target = nullTarget;
        if (auraTarget != null) {
            stopWatch.reset();
            shouldToBack = true;
            target = auraTarget;
        } else if (mc.currentScreen instanceof ChatScreen) {
            stopWatch.reset();
            shouldToBack = true;
            target = mc.player;
        } else {
            shouldToBack = false;
        }
        return target;
    }

    public void drawTargetHead(LivingEntity entity, float x, float y, float width, float height) {
        if (entity != null) {
            EntityRenderer<? super LivingEntity> rendererManager = mc.getRenderManager().getRenderer(entity);
            drawFace(rendererManager.getEntityTexture(entity), x, y-3, 8F, 8F, 8F, 8F, width, height, 64F, 64F, entity);
        }
    }
    private void renderHealthBar() {
        Style style = Expensive.getInstance().getStyleManager().getCurrentStyle();
        Vector4i vector4i = new Vector4i(HUD.getColor(0), HUD.getColor(90), HUD.getColor(180), HUD.getColor(170));
        DisplayUtils.drawRoundedRect(posX + 34 + headSize + spacing -32 + spacing, posY - 5.5f + height - spacing * 1 - 2, (width - 36) * healthAnimation, 2, new Vector4f(3,3,3,3), ColorUtils.rgba(120, 120, 240, 250));
    }


    private void renderTextThatDisplaysTargetInfo(MatrixStack matrixStack) {
        Style style = Expensive.getInstance().getStyleManager().getCurrentStyle();
        float animationValue = (float) animation.getOutput();
        float halfAnimationValueRest = (1 - animationValue) / 2f;
        float testX = posX + (width * halfAnimationValueRest);
        float testY = posY + (height * halfAnimationValueRest);
        float testW = width * animationValue;
        float testH = height * animationValue;
        drawStyledRect(posX, posY, width, height, rounding, 195);
        //рендерится голова
        Stencil.initStencilToWrite();
        DisplayUtils.drawRoundedRect(posX + spacing, posY + spacing + 1, headSize, headSize,2, style.getSecondColor().getRGB() );
        Stencil.readStencilBuffer(1);
        drawTargetHead(entity, posX + spacing, posY + spacing + 2, headSize, headSize);
        Stencil.uninitStencilBuffer();
        Scissor.push();
        Scissor.setFromComponentCoordinates(testX, testY, testW - 1, testH);
        String hpText = "";
        if (entity.isInvisible() && userConnectedToFunTimeAndEntityIsPlayer()) {
            hpText = "Неизвестно";
        } else {
            float health = (float) MathUtil.round(healthAnimation * 20.0f, 0.1f);
            hpText = health * 5 + "";
}

        Fonts.sfMedium.drawText(matrixStack, TextFormatting.getTextWithoutFormattingCodes(entity.getName().getString()), posX + 2 + headSize + spacing + spacing, posY + 2 + spacing + 1, -1, 8);
        Fonts.sfMedium.drawText(matrixStack, hpText, posX + 2 + headSize + spacing + spacing,
                posY + 5 + spacing + 1 + spacing + spacing, ColorUtils.rgba(120, 120, 240, 255), 6.5F);
        DisplayUtils.drawImage(new ResourceLocation("expensive/images/hud/health.png"), posX + 136 * healthAnimation2 / 1.5f , posY + 17 , 7, 7,ColorUtils.rgba(255,255,255,255));

        Scissor.unset();
        Scissor.pop();
    }


    public void setSizeAnimation(double scale) {
        GlStateManager.translated(posX + (width / 2), posY + (height / 2), 0);
        GlStateManager.scaled(scale, scale, scale);
        GlStateManager.translated(-(posX + (width / 2)), -(posY + (height / 2)), 0);
    }

    public void drawFace(ResourceLocation res, float d,
                         float y,
                         float u,
                         float v,
                         float uWidth,
                         float vHeight,
                         float width,
                         float height,
                         float tileWidth,
                         float tileHeight,
                         LivingEntity target) {
        GL11.glPushMatrix();
        GL11.glEnable(GL11.GL_BLEND);
        mc.getTextureManager().bindTexture(res);
        float hurtPercent = (target.hurtTime - (target.hurtTime != 0 ? mc.timer.renderPartialTicks : 0.0f)) / 8.0f;
        GL11.glColor4f(1, 1 - hurtPercent, 1 - hurtPercent, 1);
        DisplayUtils.drawImage(new ResourceLocation("expensive/images/hud/steve.png"), posX + 6 , posY + 6 , 24, 25,ColorUtils.rgba(255,255,255,255));
        GL11.glColor4f(1, 1, 1, 1);
        GL11.glPopMatrix();
    }

    private float fix1000Health(float original) {
        Score score = mc.world.getScoreboard().getOrCreateScore(entity.getScoreboardName(),
                mc.world.getScoreboard().getObjectiveInDisplaySlot(2));

        return userConnectedToFunTimeAndEntityIsPlayer() ? score.getScorePoints() : original;
    }


    private boolean userConnectedToFunTimeAndEntityIsPlayer() {
        String header = mc.ingameGUI.getTabList().header == null ? " " : mc.ingameGUI.getTabList().header.getString().toLowerCase();
        return (mc.getCurrentServerData() != null && mc.getCurrentServerData().serverIP.contains("funtime")
                && (header.contains("анархия") || header.contains("гриферский")) && entity instanceof PlayerEntity);
    }

    private void drawBackGround(float radius) {
        Vector4i vector4i = new Vector4i(HUD.getColor(50), HUD.getColor(160), HUD.getColor(100), HUD.getColor(80));
        DisplayUtils.drawRoundedRect(posX - 1.5f, posY - 1.5f, width + 3, height + 3, radius + 2, ColorUtils.rgba(60, 70, 80, 255));
        DisplayUtils.drawRoundedRect(posX, posY, width, height, radius + 2, ColorUtils.rgba(30, 35, 40, 255));
}
    private void drawStyledRect(float x,
                                float y,
                                float width,
                                float height,
                                float radius, int alpha) {


    }
}
 
Сверху Снизу