Подписывайтесь на наш Telegram и не пропускайте важные новости! Перейти

Визуальная часть Base Async TargetHud | Skid AlekDLC

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
10 Ноя 2023
Сообщения
261
Реакции
3
Выберите загрузчик игры
  1. Fabric
крутой скид:
Expand Collapse Copy
package itz.async.feature.ui.hud;

import itz.async.Async;
import itz.async.feature.event.impl.Render2DEvent;
import itz.async.feature.ui.hud.drag.DragComponent;
import itz.async.utils.animation.Animation;
import itz.async.utils.animation.Easing;
import itz.async.utils.client.ClientUtility;
import itz.async.utils.render.ColorRGBA;
import itz.async.utils.render.RenderContext;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.SkinTextures;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;

import static itz.async.utils.render.Fonts.sf_pro;

public class TargetHudRenderer extends DragComponent {

    private final Animation animation = new Animation(300, Easing.CUBIC_OUT);
    private LivingEntity lastTarget = null;

    public TargetHudRenderer() {
        super("targethud");
        setDraggable(true);
        setAllowDragX(true);
        setAllowDragY(true);
        setX(10);
        setY(10);

        try {
            Async.getInstance().eventBus.register(this);
        } catch (Exception e) {}
    }

    @Override
    public void render(Render2DEvent event) {
        MinecraftClient mc = MinecraftClient.getInstance();
        if (mc.player == null) return;

        boolean isChatOrScreen = mc.currentScreen != null;
        LivingEntity target = null;

        if (isChatOrScreen) {
            target = mc.player;
        } else if (mc.targetedEntity instanceof LivingEntity living) {
            target = living;
        }

        if (target != null) {
            animation.animate(1);
            lastTarget = target;
        } else {
            animation.animate(0);
        }

        animation.update();

        float animScale = animation.getValue();
        if (animScale <= 0.01f || lastTarget == null) return;

        RenderContext renderContext = event.getContext();
        ColorRGBA themeColor = ClientUtility.getThemePrimaryColorRGBA();

        String name = lastTarget.getName().getString();
        int health = (int) Math.ceil(lastTarget.getHealth());

        float paddingX = 10f;
        float paddingY = 8f;
        float radius = 8f;

        float textSize = 8f;
        float headSize = 22f;
        float circleSize = 22f;
        float gap = 8f;
        float headRadius = 4f;

        float nameWidth = sf_pro.getWidth(name, textSize);
        float nameHeight = sf_pro.getMetrics().lineHeight() * textSize;

        float totalWidth = paddingX + headSize + gap + nameWidth + gap + circleSize + paddingX;
        float totalHeight = Math.max(headSize, circleSize) + paddingY * 2;

        float bgX = getX();
        float bgY = getY();

        setWidth(totalWidth);
        setHeight(totalHeight);

        float scaledWidth = totalWidth * animScale;
        float scaledHeight = totalHeight * animScale;
        float scaledX = bgX + (totalWidth - scaledWidth) / 2f;
        float scaledY = bgY + (totalHeight - scaledHeight) / 2f;

        int alpha = (int)(255 * animScale);


        renderContext.drawBlur(scaledX, scaledY, scaledWidth, scaledHeight, radius, 30, ColorRGBA.of(255, 255, 255, alpha));
        renderContext.drawRect(scaledX, scaledY, scaledWidth, scaledHeight, radius, ColorRGBA.of(0, 0, 0, (int)(180 * animScale)));
        renderContext.drawBorder(scaledX, scaledY, scaledWidth, scaledHeight, radius, 0.5f, ColorRGBA.of(80, 80, 80, (int)(100 * animScale)));

        float centerY = scaledY + scaledHeight / 2f;


        float headX = scaledX + paddingX * animScale;
        float headY = centerY - headSize * animScale / 2f;
        float scaledHeadSize = headSize * animScale;

        if (lastTarget instanceof PlayerEntity playerTarget) {
            try {
                SkinTextures skin = mc.getSkinProvider().getSkinTextures(playerTarget.getGameProfile());
                Identifier skinTexture = skin.texture();
                int textureId = mc.getTextureManager().getTexture(skinTexture).getGlId();

                float u = 8f / 64f;
                float v = 8f / 64f;
                float texW = 8f / 64f;
                float texH = 8f / 64f;

                renderContext.drawTexture(headX, headY, scaledHeadSize, scaledHeadSize, headRadius,
                        ColorRGBA.of(255, 255, 255, alpha), u, v, texW, texH, textureId);

                renderContext.drawTexture(headX, headY, scaledHeadSize, scaledHeadSize, headRadius,
                        ColorRGBA.of(255, 255, 255, alpha), 40f / 64f, v, texW, texH, textureId);
            } catch (Exception e) {
                renderContext.drawRect(headX, headY, scaledHeadSize, scaledHeadSize, headRadius, ColorRGBA.of(60, 60, 60, alpha));
            }
        } else {
            renderContext.drawRect(headX, headY, scaledHeadSize, scaledHeadSize, headRadius, ColorRGBA.of(60, 60, 60, alpha));
        }


        float nameX = scaledX + (paddingX + headSize + gap) * animScale;
        float nameY = centerY - nameHeight * animScale / 2f;
        renderContext.drawText(name, sf_pro, nameX, nameY, textSize * animScale, ColorRGBA.of(255, 255, 255, alpha));


        float circleX = scaledX + scaledWidth - paddingX * animScale - circleSize * animScale;
        float circleY = centerY - circleSize * animScale / 2f;
        float scaledCircle = circleSize * animScale;
        float circleRadius = scaledCircle / 2f;

        renderContext.drawBlur(circleX, circleY, scaledCircle, scaledCircle, circleRadius, 20, ColorRGBA.of(255, 255, 255, alpha));
        renderContext.drawRect(circleX, circleY, scaledCircle, scaledCircle, circleRadius, ColorRGBA.of(30, 30, 30, alpha));
        renderContext.drawBorder(circleX, circleY, scaledCircle, scaledCircle, circleRadius, 1.5f, themeColor.withAlpha(alpha));


        String healthStr = String.valueOf(health);
        float healthTextSize = 7.5f * animScale;
        float healthTextWidth = sf_pro.getWidth(healthStr, healthTextSize);
        float healthTextHeight = sf_pro.getMetrics().lineHeight() * healthTextSize;
        float healthTextX = circleX + (scaledCircle - healthTextWidth) / 2f;
        float healthTextY = circleY + (scaledCircle - healthTextHeight) / 2f;
        renderContext.drawText(healthStr, sf_pro, healthTextX, healthTextY, healthTextSize, ColorRGBA.of(255, 255, 255, alpha));
    }
}
мой скид
1778406864058.png

AlekDLC
1778407027793.png
 
крутой скид:
Expand Collapse Copy
package itz.async.feature.ui.hud;

import itz.async.Async;
import itz.async.feature.event.impl.Render2DEvent;
import itz.async.feature.ui.hud.drag.DragComponent;
import itz.async.utils.animation.Animation;
import itz.async.utils.animation.Easing;
import itz.async.utils.client.ClientUtility;
import itz.async.utils.render.ColorRGBA;
import itz.async.utils.render.RenderContext;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.SkinTextures;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;

import static itz.async.utils.render.Fonts.sf_pro;

public class TargetHudRenderer extends DragComponent {

    private final Animation animation = new Animation(300, Easing.CUBIC_OUT);
    private LivingEntity lastTarget = null;

    public TargetHudRenderer() {
        super("targethud");
        setDraggable(true);
        setAllowDragX(true);
        setAllowDragY(true);
        setX(10);
        setY(10);

        try {
            Async.getInstance().eventBus.register(this);
        } catch (Exception e) {}
    }

    @Override
    public void render(Render2DEvent event) {
        MinecraftClient mc = MinecraftClient.getInstance();
        if (mc.player == null) return;

        boolean isChatOrScreen = mc.currentScreen != null;
        LivingEntity target = null;

        if (isChatOrScreen) {
            target = mc.player;
        } else if (mc.targetedEntity instanceof LivingEntity living) {
            target = living;
        }

        if (target != null) {
            animation.animate(1);
            lastTarget = target;
        } else {
            animation.animate(0);
        }

        animation.update();

        float animScale = animation.getValue();
        if (animScale <= 0.01f || lastTarget == null) return;

        RenderContext renderContext = event.getContext();
        ColorRGBA themeColor = ClientUtility.getThemePrimaryColorRGBA();

        String name = lastTarget.getName().getString();
        int health = (int) Math.ceil(lastTarget.getHealth());

        float paddingX = 10f;
        float paddingY = 8f;
        float radius = 8f;

        float textSize = 8f;
        float headSize = 22f;
        float circleSize = 22f;
        float gap = 8f;
        float headRadius = 4f;

        float nameWidth = sf_pro.getWidth(name, textSize);
        float nameHeight = sf_pro.getMetrics().lineHeight() * textSize;

        float totalWidth = paddingX + headSize + gap + nameWidth + gap + circleSize + paddingX;
        float totalHeight = Math.max(headSize, circleSize) + paddingY * 2;

        float bgX = getX();
        float bgY = getY();

        setWidth(totalWidth);
        setHeight(totalHeight);

        float scaledWidth = totalWidth * animScale;
        float scaledHeight = totalHeight * animScale;
        float scaledX = bgX + (totalWidth - scaledWidth) / 2f;
        float scaledY = bgY + (totalHeight - scaledHeight) / 2f;

        int alpha = (int)(255 * animScale);


        renderContext.drawBlur(scaledX, scaledY, scaledWidth, scaledHeight, radius, 30, ColorRGBA.of(255, 255, 255, alpha));
        renderContext.drawRect(scaledX, scaledY, scaledWidth, scaledHeight, radius, ColorRGBA.of(0, 0, 0, (int)(180 * animScale)));
        renderContext.drawBorder(scaledX, scaledY, scaledWidth, scaledHeight, radius, 0.5f, ColorRGBA.of(80, 80, 80, (int)(100 * animScale)));

        float centerY = scaledY + scaledHeight / 2f;


        float headX = scaledX + paddingX * animScale;
        float headY = centerY - headSize * animScale / 2f;
        float scaledHeadSize = headSize * animScale;

        if (lastTarget instanceof PlayerEntity playerTarget) {
            try {
                SkinTextures skin = mc.getSkinProvider().getSkinTextures(playerTarget.getGameProfile());
                Identifier skinTexture = skin.texture();
                int textureId = mc.getTextureManager().getTexture(skinTexture).getGlId();

                float u = 8f / 64f;
                float v = 8f / 64f;
                float texW = 8f / 64f;
                float texH = 8f / 64f;

                renderContext.drawTexture(headX, headY, scaledHeadSize, scaledHeadSize, headRadius,
                        ColorRGBA.of(255, 255, 255, alpha), u, v, texW, texH, textureId);

                renderContext.drawTexture(headX, headY, scaledHeadSize, scaledHeadSize, headRadius,
                        ColorRGBA.of(255, 255, 255, alpha), 40f / 64f, v, texW, texH, textureId);
            } catch (Exception e) {
                renderContext.drawRect(headX, headY, scaledHeadSize, scaledHeadSize, headRadius, ColorRGBA.of(60, 60, 60, alpha));
            }
        } else {
            renderContext.drawRect(headX, headY, scaledHeadSize, scaledHeadSize, headRadius, ColorRGBA.of(60, 60, 60, alpha));
        }


        float nameX = scaledX + (paddingX + headSize + gap) * animScale;
        float nameY = centerY - nameHeight * animScale / 2f;
        renderContext.drawText(name, sf_pro, nameX, nameY, textSize * animScale, ColorRGBA.of(255, 255, 255, alpha));


        float circleX = scaledX + scaledWidth - paddingX * animScale - circleSize * animScale;
        float circleY = centerY - circleSize * animScale / 2f;
        float scaledCircle = circleSize * animScale;
        float circleRadius = scaledCircle / 2f;

        renderContext.drawBlur(circleX, circleY, scaledCircle, scaledCircle, circleRadius, 20, ColorRGBA.of(255, 255, 255, alpha));
        renderContext.drawRect(circleX, circleY, scaledCircle, scaledCircle, circleRadius, ColorRGBA.of(30, 30, 30, alpha));
        renderContext.drawBorder(circleX, circleY, scaledCircle, scaledCircle, circleRadius, 1.5f, themeColor.withAlpha(alpha));


        String healthStr = String.valueOf(health);
        float healthTextSize = 7.5f * animScale;
        float healthTextWidth = sf_pro.getWidth(healthStr, healthTextSize);
        float healthTextHeight = sf_pro.getMetrics().lineHeight() * healthTextSize;
        float healthTextX = circleX + (scaledCircle - healthTextWidth) / 2f;
        float healthTextY = circleY + (scaledCircle - healthTextHeight) / 2f;
        renderContext.drawText(healthStr, sf_pro, healthTextX, healthTextY, healthTextSize, ColorRGBA.of(255, 255, 255, alpha));
    }
}
мой скид
Посмотреть вложение 335504
AlekDLC
Посмотреть вложение 335505
имба
 
крутой скид:
Expand Collapse Copy
package itz.async.feature.ui.hud;

import itz.async.Async;
import itz.async.feature.event.impl.Render2DEvent;
import itz.async.feature.ui.hud.drag.DragComponent;
import itz.async.utils.animation.Animation;
import itz.async.utils.animation.Easing;
import itz.async.utils.client.ClientUtility;
import itz.async.utils.render.ColorRGBA;
import itz.async.utils.render.RenderContext;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.SkinTextures;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;

import static itz.async.utils.render.Fonts.sf_pro;

public class TargetHudRenderer extends DragComponent {

    private final Animation animation = new Animation(300, Easing.CUBIC_OUT);
    private LivingEntity lastTarget = null;

    public TargetHudRenderer() {
        super("targethud");
        setDraggable(true);
        setAllowDragX(true);
        setAllowDragY(true);
        setX(10);
        setY(10);

        try {
            Async.getInstance().eventBus.register(this);
        } catch (Exception e) {}
    }

    @Override
    public void render(Render2DEvent event) {
        MinecraftClient mc = MinecraftClient.getInstance();
        if (mc.player == null) return;

        boolean isChatOrScreen = mc.currentScreen != null;
        LivingEntity target = null;

        if (isChatOrScreen) {
            target = mc.player;
        } else if (mc.targetedEntity instanceof LivingEntity living) {
            target = living;
        }

        if (target != null) {
            animation.animate(1);
            lastTarget = target;
        } else {
            animation.animate(0);
        }

        animation.update();

        float animScale = animation.getValue();
        if (animScale <= 0.01f || lastTarget == null) return;

        RenderContext renderContext = event.getContext();
        ColorRGBA themeColor = ClientUtility.getThemePrimaryColorRGBA();

        String name = lastTarget.getName().getString();
        int health = (int) Math.ceil(lastTarget.getHealth());

        float paddingX = 10f;
        float paddingY = 8f;
        float radius = 8f;

        float textSize = 8f;
        float headSize = 22f;
        float circleSize = 22f;
        float gap = 8f;
        float headRadius = 4f;

        float nameWidth = sf_pro.getWidth(name, textSize);
        float nameHeight = sf_pro.getMetrics().lineHeight() * textSize;

        float totalWidth = paddingX + headSize + gap + nameWidth + gap + circleSize + paddingX;
        float totalHeight = Math.max(headSize, circleSize) + paddingY * 2;

        float bgX = getX();
        float bgY = getY();

        setWidth(totalWidth);
        setHeight(totalHeight);

        float scaledWidth = totalWidth * animScale;
        float scaledHeight = totalHeight * animScale;
        float scaledX = bgX + (totalWidth - scaledWidth) / 2f;
        float scaledY = bgY + (totalHeight - scaledHeight) / 2f;

        int alpha = (int)(255 * animScale);


        renderContext.drawBlur(scaledX, scaledY, scaledWidth, scaledHeight, radius, 30, ColorRGBA.of(255, 255, 255, alpha));
        renderContext.drawRect(scaledX, scaledY, scaledWidth, scaledHeight, radius, ColorRGBA.of(0, 0, 0, (int)(180 * animScale)));
        renderContext.drawBorder(scaledX, scaledY, scaledWidth, scaledHeight, radius, 0.5f, ColorRGBA.of(80, 80, 80, (int)(100 * animScale)));

        float centerY = scaledY + scaledHeight / 2f;


        float headX = scaledX + paddingX * animScale;
        float headY = centerY - headSize * animScale / 2f;
        float scaledHeadSize = headSize * animScale;

        if (lastTarget instanceof PlayerEntity playerTarget) {
            try {
                SkinTextures skin = mc.getSkinProvider().getSkinTextures(playerTarget.getGameProfile());
                Identifier skinTexture = skin.texture();
                int textureId = mc.getTextureManager().getTexture(skinTexture).getGlId();

                float u = 8f / 64f;
                float v = 8f / 64f;
                float texW = 8f / 64f;
                float texH = 8f / 64f;

                renderContext.drawTexture(headX, headY, scaledHeadSize, scaledHeadSize, headRadius,
                        ColorRGBA.of(255, 255, 255, alpha), u, v, texW, texH, textureId);

                renderContext.drawTexture(headX, headY, scaledHeadSize, scaledHeadSize, headRadius,
                        ColorRGBA.of(255, 255, 255, alpha), 40f / 64f, v, texW, texH, textureId);
            } catch (Exception e) {
                renderContext.drawRect(headX, headY, scaledHeadSize, scaledHeadSize, headRadius, ColorRGBA.of(60, 60, 60, alpha));
            }
        } else {
            renderContext.drawRect(headX, headY, scaledHeadSize, scaledHeadSize, headRadius, ColorRGBA.of(60, 60, 60, alpha));
        }


        float nameX = scaledX + (paddingX + headSize + gap) * animScale;
        float nameY = centerY - nameHeight * animScale / 2f;
        renderContext.drawText(name, sf_pro, nameX, nameY, textSize * animScale, ColorRGBA.of(255, 255, 255, alpha));


        float circleX = scaledX + scaledWidth - paddingX * animScale - circleSize * animScale;
        float circleY = centerY - circleSize * animScale / 2f;
        float scaledCircle = circleSize * animScale;
        float circleRadius = scaledCircle / 2f;

        renderContext.drawBlur(circleX, circleY, scaledCircle, scaledCircle, circleRadius, 20, ColorRGBA.of(255, 255, 255, alpha));
        renderContext.drawRect(circleX, circleY, scaledCircle, scaledCircle, circleRadius, ColorRGBA.of(30, 30, 30, alpha));
        renderContext.drawBorder(circleX, circleY, scaledCircle, scaledCircle, circleRadius, 1.5f, themeColor.withAlpha(alpha));


        String healthStr = String.valueOf(health);
        float healthTextSize = 7.5f * animScale;
        float healthTextWidth = sf_pro.getWidth(healthStr, healthTextSize);
        float healthTextHeight = sf_pro.getMetrics().lineHeight() * healthTextSize;
        float healthTextX = circleX + (scaledCircle - healthTextWidth) / 2f;
        float healthTextY = circleY + (scaledCircle - healthTextHeight) / 2f;
        renderContext.drawText(healthStr, sf_pro, healthTextX, healthTextY, healthTextSize, ColorRGBA.of(255, 255, 255, alpha));
    }
}
мой скид
Посмотреть вложение 335504
AlekDLC
Посмотреть вложение 335505
не похоже от слова совсем сходства максимум блюр
 
крутой скид:
Expand Collapse Copy
package itz.async.feature.ui.hud;

import itz.async.Async;
import itz.async.feature.event.impl.Render2DEvent;
import itz.async.feature.ui.hud.drag.DragComponent;
import itz.async.utils.animation.Animation;
import itz.async.utils.animation.Easing;
import itz.async.utils.client.ClientUtility;
import itz.async.utils.render.ColorRGBA;
import itz.async.utils.render.RenderContext;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.SkinTextures;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;

import static itz.async.utils.render.Fonts.sf_pro;

public class TargetHudRenderer extends DragComponent {

    private final Animation animation = new Animation(300, Easing.CUBIC_OUT);
    private LivingEntity lastTarget = null;

    public TargetHudRenderer() {
        super("targethud");
        setDraggable(true);
        setAllowDragX(true);
        setAllowDragY(true);
        setX(10);
        setY(10);

        try {
            Async.getInstance().eventBus.register(this);
        } catch (Exception e) {}
    }

    @Override
    public void render(Render2DEvent event) {
        MinecraftClient mc = MinecraftClient.getInstance();
        if (mc.player == null) return;

        boolean isChatOrScreen = mc.currentScreen != null;
        LivingEntity target = null;

        if (isChatOrScreen) {
            target = mc.player;
        } else if (mc.targetedEntity instanceof LivingEntity living) {
            target = living;
        }

        if (target != null) {
            animation.animate(1);
            lastTarget = target;
        } else {
            animation.animate(0);
        }

        animation.update();

        float animScale = animation.getValue();
        if (animScale <= 0.01f || lastTarget == null) return;

        RenderContext renderContext = event.getContext();
        ColorRGBA themeColor = ClientUtility.getThemePrimaryColorRGBA();

        String name = lastTarget.getName().getString();
        int health = (int) Math.ceil(lastTarget.getHealth());

        float paddingX = 10f;
        float paddingY = 8f;
        float radius = 8f;

        float textSize = 8f;
        float headSize = 22f;
        float circleSize = 22f;
        float gap = 8f;
        float headRadius = 4f;

        float nameWidth = sf_pro.getWidth(name, textSize);
        float nameHeight = sf_pro.getMetrics().lineHeight() * textSize;

        float totalWidth = paddingX + headSize + gap + nameWidth + gap + circleSize + paddingX;
        float totalHeight = Math.max(headSize, circleSize) + paddingY * 2;

        float bgX = getX();
        float bgY = getY();

        setWidth(totalWidth);
        setHeight(totalHeight);

        float scaledWidth = totalWidth * animScale;
        float scaledHeight = totalHeight * animScale;
        float scaledX = bgX + (totalWidth - scaledWidth) / 2f;
        float scaledY = bgY + (totalHeight - scaledHeight) / 2f;

        int alpha = (int)(255 * animScale);


        renderContext.drawBlur(scaledX, scaledY, scaledWidth, scaledHeight, radius, 30, ColorRGBA.of(255, 255, 255, alpha));
        renderContext.drawRect(scaledX, scaledY, scaledWidth, scaledHeight, radius, ColorRGBA.of(0, 0, 0, (int)(180 * animScale)));
        renderContext.drawBorder(scaledX, scaledY, scaledWidth, scaledHeight, radius, 0.5f, ColorRGBA.of(80, 80, 80, (int)(100 * animScale)));

        float centerY = scaledY + scaledHeight / 2f;


        float headX = scaledX + paddingX * animScale;
        float headY = centerY - headSize * animScale / 2f;
        float scaledHeadSize = headSize * animScale;

        if (lastTarget instanceof PlayerEntity playerTarget) {
            try {
                SkinTextures skin = mc.getSkinProvider().getSkinTextures(playerTarget.getGameProfile());
                Identifier skinTexture = skin.texture();
                int textureId = mc.getTextureManager().getTexture(skinTexture).getGlId();

                float u = 8f / 64f;
                float v = 8f / 64f;
                float texW = 8f / 64f;
                float texH = 8f / 64f;

                renderContext.drawTexture(headX, headY, scaledHeadSize, scaledHeadSize, headRadius,
                        ColorRGBA.of(255, 255, 255, alpha), u, v, texW, texH, textureId);

                renderContext.drawTexture(headX, headY, scaledHeadSize, scaledHeadSize, headRadius,
                        ColorRGBA.of(255, 255, 255, alpha), 40f / 64f, v, texW, texH, textureId);
            } catch (Exception e) {
                renderContext.drawRect(headX, headY, scaledHeadSize, scaledHeadSize, headRadius, ColorRGBA.of(60, 60, 60, alpha));
            }
        } else {
            renderContext.drawRect(headX, headY, scaledHeadSize, scaledHeadSize, headRadius, ColorRGBA.of(60, 60, 60, alpha));
        }


        float nameX = scaledX + (paddingX + headSize + gap) * animScale;
        float nameY = centerY - nameHeight * animScale / 2f;
        renderContext.drawText(name, sf_pro, nameX, nameY, textSize * animScale, ColorRGBA.of(255, 255, 255, alpha));


        float circleX = scaledX + scaledWidth - paddingX * animScale - circleSize * animScale;
        float circleY = centerY - circleSize * animScale / 2f;
        float scaledCircle = circleSize * animScale;
        float circleRadius = scaledCircle / 2f;

        renderContext.drawBlur(circleX, circleY, scaledCircle, scaledCircle, circleRadius, 20, ColorRGBA.of(255, 255, 255, alpha));
        renderContext.drawRect(circleX, circleY, scaledCircle, scaledCircle, circleRadius, ColorRGBA.of(30, 30, 30, alpha));
        renderContext.drawBorder(circleX, circleY, scaledCircle, scaledCircle, circleRadius, 1.5f, themeColor.withAlpha(alpha));


        String healthStr = String.valueOf(health);
        float healthTextSize = 7.5f * animScale;
        float healthTextWidth = sf_pro.getWidth(healthStr, healthTextSize);
        float healthTextHeight = sf_pro.getMetrics().lineHeight() * healthTextSize;
        float healthTextX = circleX + (scaledCircle - healthTextWidth) / 2f;
        float healthTextY = circleY + (scaledCircle - healthTextHeight) / 2f;
        renderContext.drawText(healthStr, sf_pro, healthTextX, healthTextY, healthTextSize, ColorRGBA.of(255, 255, 255, alpha));
    }
}
мой скид
Посмотреть вложение 335504
AlekDLC
Посмотреть вложение 335505
Шрифты, Размер, Круг всё хуйня
 
крутой скид:
Expand Collapse Copy
package itz.async.feature.ui.hud;

import itz.async.Async;
import itz.async.feature.event.impl.Render2DEvent;
import itz.async.feature.ui.hud.drag.DragComponent;
import itz.async.utils.animation.Animation;
import itz.async.utils.animation.Easing;
import itz.async.utils.client.ClientUtility;
import itz.async.utils.render.ColorRGBA;
import itz.async.utils.render.RenderContext;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.SkinTextures;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;

import static itz.async.utils.render.Fonts.sf_pro;

public class TargetHudRenderer extends DragComponent {

    private final Animation animation = new Animation(300, Easing.CUBIC_OUT);
    private LivingEntity lastTarget = null;

    public TargetHudRenderer() {
        super("targethud");
        setDraggable(true);
        setAllowDragX(true);
        setAllowDragY(true);
        setX(10);
        setY(10);

        try {
            Async.getInstance().eventBus.register(this);
        } catch (Exception e) {}
    }

    @Override
    public void render(Render2DEvent event) {
        MinecraftClient mc = MinecraftClient.getInstance();
        if (mc.player == null) return;

        boolean isChatOrScreen = mc.currentScreen != null;
        LivingEntity target = null;

        if (isChatOrScreen) {
            target = mc.player;
        } else if (mc.targetedEntity instanceof LivingEntity living) {
            target = living;
        }

        if (target != null) {
            animation.animate(1);
            lastTarget = target;
        } else {
            animation.animate(0);
        }

        animation.update();

        float animScale = animation.getValue();
        if (animScale <= 0.01f || lastTarget == null) return;

        RenderContext renderContext = event.getContext();
        ColorRGBA themeColor = ClientUtility.getThemePrimaryColorRGBA();

        String name = lastTarget.getName().getString();
        int health = (int) Math.ceil(lastTarget.getHealth());

        float paddingX = 10f;
        float paddingY = 8f;
        float radius = 8f;

        float textSize = 8f;
        float headSize = 22f;
        float circleSize = 22f;
        float gap = 8f;
        float headRadius = 4f;

        float nameWidth = sf_pro.getWidth(name, textSize);
        float nameHeight = sf_pro.getMetrics().lineHeight() * textSize;

        float totalWidth = paddingX + headSize + gap + nameWidth + gap + circleSize + paddingX;
        float totalHeight = Math.max(headSize, circleSize) + paddingY * 2;

        float bgX = getX();
        float bgY = getY();

        setWidth(totalWidth);
        setHeight(totalHeight);

        float scaledWidth = totalWidth * animScale;
        float scaledHeight = totalHeight * animScale;
        float scaledX = bgX + (totalWidth - scaledWidth) / 2f;
        float scaledY = bgY + (totalHeight - scaledHeight) / 2f;

        int alpha = (int)(255 * animScale);


        renderContext.drawBlur(scaledX, scaledY, scaledWidth, scaledHeight, radius, 30, ColorRGBA.of(255, 255, 255, alpha));
        renderContext.drawRect(scaledX, scaledY, scaledWidth, scaledHeight, radius, ColorRGBA.of(0, 0, 0, (int)(180 * animScale)));
        renderContext.drawBorder(scaledX, scaledY, scaledWidth, scaledHeight, radius, 0.5f, ColorRGBA.of(80, 80, 80, (int)(100 * animScale)));

        float centerY = scaledY + scaledHeight / 2f;


        float headX = scaledX + paddingX * animScale;
        float headY = centerY - headSize * animScale / 2f;
        float scaledHeadSize = headSize * animScale;

        if (lastTarget instanceof PlayerEntity playerTarget) {
            try {
                SkinTextures skin = mc.getSkinProvider().getSkinTextures(playerTarget.getGameProfile());
                Identifier skinTexture = skin.texture();
                int textureId = mc.getTextureManager().getTexture(skinTexture).getGlId();

                float u = 8f / 64f;
                float v = 8f / 64f;
                float texW = 8f / 64f;
                float texH = 8f / 64f;

                renderContext.drawTexture(headX, headY, scaledHeadSize, scaledHeadSize, headRadius,
                        ColorRGBA.of(255, 255, 255, alpha), u, v, texW, texH, textureId);

                renderContext.drawTexture(headX, headY, scaledHeadSize, scaledHeadSize, headRadius,
                        ColorRGBA.of(255, 255, 255, alpha), 40f / 64f, v, texW, texH, textureId);
            } catch (Exception e) {
                renderContext.drawRect(headX, headY, scaledHeadSize, scaledHeadSize, headRadius, ColorRGBA.of(60, 60, 60, alpha));
            }
        } else {
            renderContext.drawRect(headX, headY, scaledHeadSize, scaledHeadSize, headRadius, ColorRGBA.of(60, 60, 60, alpha));
        }


        float nameX = scaledX + (paddingX + headSize + gap) * animScale;
        float nameY = centerY - nameHeight * animScale / 2f;
        renderContext.drawText(name, sf_pro, nameX, nameY, textSize * animScale, ColorRGBA.of(255, 255, 255, alpha));


        float circleX = scaledX + scaledWidth - paddingX * animScale - circleSize * animScale;
        float circleY = centerY - circleSize * animScale / 2f;
        float scaledCircle = circleSize * animScale;
        float circleRadius = scaledCircle / 2f;

        renderContext.drawBlur(circleX, circleY, scaledCircle, scaledCircle, circleRadius, 20, ColorRGBA.of(255, 255, 255, alpha));
        renderContext.drawRect(circleX, circleY, scaledCircle, scaledCircle, circleRadius, ColorRGBA.of(30, 30, 30, alpha));
        renderContext.drawBorder(circleX, circleY, scaledCircle, scaledCircle, circleRadius, 1.5f, themeColor.withAlpha(alpha));


        String healthStr = String.valueOf(health);
        float healthTextSize = 7.5f * animScale;
        float healthTextWidth = sf_pro.getWidth(healthStr, healthTextSize);
        float healthTextHeight = sf_pro.getMetrics().lineHeight() * healthTextSize;
        float healthTextX = circleX + (scaledCircle - healthTextWidth) / 2f;
        float healthTextY = circleY + (scaledCircle - healthTextHeight) / 2f;
        renderContext.drawText(healthStr, sf_pro, healthTextX, healthTextY, healthTextSize, ColorRGBA.of(255, 255, 255, alpha));
    }
}
мой скид
Посмотреть вложение 335504
AlekDLC
Посмотреть вложение 335505
1778420020437.png
мой лучше))
 
крутой скид:
Expand Collapse Copy
package itz.async.feature.ui.hud;

import itz.async.Async;
import itz.async.feature.event.impl.Render2DEvent;
import itz.async.feature.ui.hud.drag.DragComponent;
import itz.async.utils.animation.Animation;
import itz.async.utils.animation.Easing;
import itz.async.utils.client.ClientUtility;
import itz.async.utils.render.ColorRGBA;
import itz.async.utils.render.RenderContext;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.SkinTextures;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;

import static itz.async.utils.render.Fonts.sf_pro;

public class TargetHudRenderer extends DragComponent {

    private final Animation animation = new Animation(300, Easing.CUBIC_OUT);
    private LivingEntity lastTarget = null;

    public TargetHudRenderer() {
        super("targethud");
        setDraggable(true);
        setAllowDragX(true);
        setAllowDragY(true);
        setX(10);
        setY(10);

        try {
            Async.getInstance().eventBus.register(this);
        } catch (Exception e) {}
    }

    @Override
    public void render(Render2DEvent event) {
        MinecraftClient mc = MinecraftClient.getInstance();
        if (mc.player == null) return;

        boolean isChatOrScreen = mc.currentScreen != null;
        LivingEntity target = null;

        if (isChatOrScreen) {
            target = mc.player;
        } else if (mc.targetedEntity instanceof LivingEntity living) {
            target = living;
        }

        if (target != null) {
            animation.animate(1);
            lastTarget = target;
        } else {
            animation.animate(0);
        }

        animation.update();

        float animScale = animation.getValue();
        if (animScale <= 0.01f || lastTarget == null) return;

        RenderContext renderContext = event.getContext();
        ColorRGBA themeColor = ClientUtility.getThemePrimaryColorRGBA();

        String name = lastTarget.getName().getString();
        int health = (int) Math.ceil(lastTarget.getHealth());

        float paddingX = 10f;
        float paddingY = 8f;
        float radius = 8f;

        float textSize = 8f;
        float headSize = 22f;
        float circleSize = 22f;
        float gap = 8f;
        float headRadius = 4f;

        float nameWidth = sf_pro.getWidth(name, textSize);
        float nameHeight = sf_pro.getMetrics().lineHeight() * textSize;

        float totalWidth = paddingX + headSize + gap + nameWidth + gap + circleSize + paddingX;
        float totalHeight = Math.max(headSize, circleSize) + paddingY * 2;

        float bgX = getX();
        float bgY = getY();

        setWidth(totalWidth);
        setHeight(totalHeight);

        float scaledWidth = totalWidth * animScale;
        float scaledHeight = totalHeight * animScale;
        float scaledX = bgX + (totalWidth - scaledWidth) / 2f;
        float scaledY = bgY + (totalHeight - scaledHeight) / 2f;

        int alpha = (int)(255 * animScale);


        renderContext.drawBlur(scaledX, scaledY, scaledWidth, scaledHeight, radius, 30, ColorRGBA.of(255, 255, 255, alpha));
        renderContext.drawRect(scaledX, scaledY, scaledWidth, scaledHeight, radius, ColorRGBA.of(0, 0, 0, (int)(180 * animScale)));
        renderContext.drawBorder(scaledX, scaledY, scaledWidth, scaledHeight, radius, 0.5f, ColorRGBA.of(80, 80, 80, (int)(100 * animScale)));

        float centerY = scaledY + scaledHeight / 2f;


        float headX = scaledX + paddingX * animScale;
        float headY = centerY - headSize * animScale / 2f;
        float scaledHeadSize = headSize * animScale;

        if (lastTarget instanceof PlayerEntity playerTarget) {
            try {
                SkinTextures skin = mc.getSkinProvider().getSkinTextures(playerTarget.getGameProfile());
                Identifier skinTexture = skin.texture();
                int textureId = mc.getTextureManager().getTexture(skinTexture).getGlId();

                float u = 8f / 64f;
                float v = 8f / 64f;
                float texW = 8f / 64f;
                float texH = 8f / 64f;

                renderContext.drawTexture(headX, headY, scaledHeadSize, scaledHeadSize, headRadius,
                        ColorRGBA.of(255, 255, 255, alpha), u, v, texW, texH, textureId);

                renderContext.drawTexture(headX, headY, scaledHeadSize, scaledHeadSize, headRadius,
                        ColorRGBA.of(255, 255, 255, alpha), 40f / 64f, v, texW, texH, textureId);
            } catch (Exception e) {
                renderContext.drawRect(headX, headY, scaledHeadSize, scaledHeadSize, headRadius, ColorRGBA.of(60, 60, 60, alpha));
            }
        } else {
            renderContext.drawRect(headX, headY, scaledHeadSize, scaledHeadSize, headRadius, ColorRGBA.of(60, 60, 60, alpha));
        }


        float nameX = scaledX + (paddingX + headSize + gap) * animScale;
        float nameY = centerY - nameHeight * animScale / 2f;
        renderContext.drawText(name, sf_pro, nameX, nameY, textSize * animScale, ColorRGBA.of(255, 255, 255, alpha));


        float circleX = scaledX + scaledWidth - paddingX * animScale - circleSize * animScale;
        float circleY = centerY - circleSize * animScale / 2f;
        float scaledCircle = circleSize * animScale;
        float circleRadius = scaledCircle / 2f;

        renderContext.drawBlur(circleX, circleY, scaledCircle, scaledCircle, circleRadius, 20, ColorRGBA.of(255, 255, 255, alpha));
        renderContext.drawRect(circleX, circleY, scaledCircle, scaledCircle, circleRadius, ColorRGBA.of(30, 30, 30, alpha));
        renderContext.drawBorder(circleX, circleY, scaledCircle, scaledCircle, circleRadius, 1.5f, themeColor.withAlpha(alpha));


        String healthStr = String.valueOf(health);
        float healthTextSize = 7.5f * animScale;
        float healthTextWidth = sf_pro.getWidth(healthStr, healthTextSize);
        float healthTextHeight = sf_pro.getMetrics().lineHeight() * healthTextSize;
        float healthTextX = circleX + (scaledCircle - healthTextWidth) / 2f;
        float healthTextY = circleY + (scaledCircle - healthTextHeight) / 2f;
        renderContext.drawText(healthStr, sf_pro, healthTextX, healthTextY, healthTextSize, ColorRGBA.of(255, 255, 255, alpha));
    }
}
мой скид
Посмотреть вложение 335504
AlekDLC
Посмотреть вложение 335505
дай пж MinecraftClient и LivingEntity
 
крутой скид:
Expand Collapse Copy
package itz.async.feature.ui.hud;

import itz.async.Async;
import itz.async.feature.event.impl.Render2DEvent;
import itz.async.feature.ui.hud.drag.DragComponent;
import itz.async.utils.animation.Animation;
import itz.async.utils.animation.Easing;
import itz.async.utils.client.ClientUtility;
import itz.async.utils.render.ColorRGBA;
import itz.async.utils.render.RenderContext;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.SkinTextures;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;

import static itz.async.utils.render.Fonts.sf_pro;

public class TargetHudRenderer extends DragComponent {

    private final Animation animation = new Animation(300, Easing.CUBIC_OUT);
    private LivingEntity lastTarget = null;

    public TargetHudRenderer() {
        super("targethud");
        setDraggable(true);
        setAllowDragX(true);
        setAllowDragY(true);
        setX(10);
        setY(10);

        try {
            Async.getInstance().eventBus.register(this);
        } catch (Exception e) {}
    }

    @Override
    public void render(Render2DEvent event) {
        MinecraftClient mc = MinecraftClient.getInstance();
        if (mc.player == null) return;

        boolean isChatOrScreen = mc.currentScreen != null;
        LivingEntity target = null;

        if (isChatOrScreen) {
            target = mc.player;
        } else if (mc.targetedEntity instanceof LivingEntity living) {
            target = living;
        }

        if (target != null) {
            animation.animate(1);
            lastTarget = target;
        } else {
            animation.animate(0);
        }

        animation.update();

        float animScale = animation.getValue();
        if (animScale <= 0.01f || lastTarget == null) return;

        RenderContext renderContext = event.getContext();
        ColorRGBA themeColor = ClientUtility.getThemePrimaryColorRGBA();

        String name = lastTarget.getName().getString();
        int health = (int) Math.ceil(lastTarget.getHealth());

        float paddingX = 10f;
        float paddingY = 8f;
        float radius = 8f;

        float textSize = 8f;
        float headSize = 22f;
        float circleSize = 22f;
        float gap = 8f;
        float headRadius = 4f;

        float nameWidth = sf_pro.getWidth(name, textSize);
        float nameHeight = sf_pro.getMetrics().lineHeight() * textSize;

        float totalWidth = paddingX + headSize + gap + nameWidth + gap + circleSize + paddingX;
        float totalHeight = Math.max(headSize, circleSize) + paddingY * 2;

        float bgX = getX();
        float bgY = getY();

        setWidth(totalWidth);
        setHeight(totalHeight);

        float scaledWidth = totalWidth * animScale;
        float scaledHeight = totalHeight * animScale;
        float scaledX = bgX + (totalWidth - scaledWidth) / 2f;
        float scaledY = bgY + (totalHeight - scaledHeight) / 2f;

        int alpha = (int)(255 * animScale);


        renderContext.drawBlur(scaledX, scaledY, scaledWidth, scaledHeight, radius, 30, ColorRGBA.of(255, 255, 255, alpha));
        renderContext.drawRect(scaledX, scaledY, scaledWidth, scaledHeight, radius, ColorRGBA.of(0, 0, 0, (int)(180 * animScale)));
        renderContext.drawBorder(scaledX, scaledY, scaledWidth, scaledHeight, radius, 0.5f, ColorRGBA.of(80, 80, 80, (int)(100 * animScale)));

        float centerY = scaledY + scaledHeight / 2f;


        float headX = scaledX + paddingX * animScale;
        float headY = centerY - headSize * animScale / 2f;
        float scaledHeadSize = headSize * animScale;

        if (lastTarget instanceof PlayerEntity playerTarget) {
            try {
                SkinTextures skin = mc.getSkinProvider().getSkinTextures(playerTarget.getGameProfile());
                Identifier skinTexture = skin.texture();
                int textureId = mc.getTextureManager().getTexture(skinTexture).getGlId();

                float u = 8f / 64f;
                float v = 8f / 64f;
                float texW = 8f / 64f;
                float texH = 8f / 64f;

                renderContext.drawTexture(headX, headY, scaledHeadSize, scaledHeadSize, headRadius,
                        ColorRGBA.of(255, 255, 255, alpha), u, v, texW, texH, textureId);

                renderContext.drawTexture(headX, headY, scaledHeadSize, scaledHeadSize, headRadius,
                        ColorRGBA.of(255, 255, 255, alpha), 40f / 64f, v, texW, texH, textureId);
            } catch (Exception e) {
                renderContext.drawRect(headX, headY, scaledHeadSize, scaledHeadSize, headRadius, ColorRGBA.of(60, 60, 60, alpha));
            }
        } else {
            renderContext.drawRect(headX, headY, scaledHeadSize, scaledHeadSize, headRadius, ColorRGBA.of(60, 60, 60, alpha));
        }


        float nameX = scaledX + (paddingX + headSize + gap) * animScale;
        float nameY = centerY - nameHeight * animScale / 2f;
        renderContext.drawText(name, sf_pro, nameX, nameY, textSize * animScale, ColorRGBA.of(255, 255, 255, alpha));


        float circleX = scaledX + scaledWidth - paddingX * animScale - circleSize * animScale;
        float circleY = centerY - circleSize * animScale / 2f;
        float scaledCircle = circleSize * animScale;
        float circleRadius = scaledCircle / 2f;

        renderContext.drawBlur(circleX, circleY, scaledCircle, scaledCircle, circleRadius, 20, ColorRGBA.of(255, 255, 255, alpha));
        renderContext.drawRect(circleX, circleY, scaledCircle, scaledCircle, circleRadius, ColorRGBA.of(30, 30, 30, alpha));
        renderContext.drawBorder(circleX, circleY, scaledCircle, scaledCircle, circleRadius, 1.5f, themeColor.withAlpha(alpha));


        String healthStr = String.valueOf(health);
        float healthTextSize = 7.5f * animScale;
        float healthTextWidth = sf_pro.getWidth(healthStr, healthTextSize);
        float healthTextHeight = sf_pro.getMetrics().lineHeight() * healthTextSize;
        float healthTextX = circleX + (scaledCircle - healthTextWidth) / 2f;
        float healthTextY = circleY + (scaledCircle - healthTextHeight) / 2f;
        renderContext.drawText(healthStr, sf_pro, healthTextX, healthTextY, healthTextSize, ColorRGBA.of(255, 255, 255, alpha));
    }
}
мой скид
Посмотреть вложение 335504
AlekDLC
Посмотреть вложение 335505
привет давай я тебе дам оригинальный код таргет худа чтобы ты на югейм больше подобное дерьмо не постил
 
крутой скид:
Expand Collapse Copy
package itz.async.feature.ui.hud;

import itz.async.Async;
import itz.async.feature.event.impl.Render2DEvent;
import itz.async.feature.ui.hud.drag.DragComponent;
import itz.async.utils.animation.Animation;
import itz.async.utils.animation.Easing;
import itz.async.utils.client.ClientUtility;
import itz.async.utils.render.ColorRGBA;
import itz.async.utils.render.RenderContext;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.SkinTextures;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;

import static itz.async.utils.render.Fonts.sf_pro;

public class TargetHudRenderer extends DragComponent {

    private final Animation animation = new Animation(300, Easing.CUBIC_OUT);
    private LivingEntity lastTarget = null;

    public TargetHudRenderer() {
        super("targethud");
        setDraggable(true);
        setAllowDragX(true);
        setAllowDragY(true);
        setX(10);
        setY(10);

        try {
            Async.getInstance().eventBus.register(this);
        } catch (Exception e) {}
    }

    @Override
    public void render(Render2DEvent event) {
        MinecraftClient mc = MinecraftClient.getInstance();
        if (mc.player == null) return;

        boolean isChatOrScreen = mc.currentScreen != null;
        LivingEntity target = null;

        if (isChatOrScreen) {
            target = mc.player;
        } else if (mc.targetedEntity instanceof LivingEntity living) {
            target = living;
        }

        if (target != null) {
            animation.animate(1);
            lastTarget = target;
        } else {
            animation.animate(0);
        }

        animation.update();

        float animScale = animation.getValue();
        if (animScale <= 0.01f || lastTarget == null) return;

        RenderContext renderContext = event.getContext();
        ColorRGBA themeColor = ClientUtility.getThemePrimaryColorRGBA();

        String name = lastTarget.getName().getString();
        int health = (int) Math.ceil(lastTarget.getHealth());

        float paddingX = 10f;
        float paddingY = 8f;
        float radius = 8f;

        float textSize = 8f;
        float headSize = 22f;
        float circleSize = 22f;
        float gap = 8f;
        float headRadius = 4f;

        float nameWidth = sf_pro.getWidth(name, textSize);
        float nameHeight = sf_pro.getMetrics().lineHeight() * textSize;

        float totalWidth = paddingX + headSize + gap + nameWidth + gap + circleSize + paddingX;
        float totalHeight = Math.max(headSize, circleSize) + paddingY * 2;

        float bgX = getX();
        float bgY = getY();

        setWidth(totalWidth);
        setHeight(totalHeight);

        float scaledWidth = totalWidth * animScale;
        float scaledHeight = totalHeight * animScale;
        float scaledX = bgX + (totalWidth - scaledWidth) / 2f;
        float scaledY = bgY + (totalHeight - scaledHeight) / 2f;

        int alpha = (int)(255 * animScale);


        renderContext.drawBlur(scaledX, scaledY, scaledWidth, scaledHeight, radius, 30, ColorRGBA.of(255, 255, 255, alpha));
        renderContext.drawRect(scaledX, scaledY, scaledWidth, scaledHeight, radius, ColorRGBA.of(0, 0, 0, (int)(180 * animScale)));
        renderContext.drawBorder(scaledX, scaledY, scaledWidth, scaledHeight, radius, 0.5f, ColorRGBA.of(80, 80, 80, (int)(100 * animScale)));

        float centerY = scaledY + scaledHeight / 2f;


        float headX = scaledX + paddingX * animScale;
        float headY = centerY - headSize * animScale / 2f;
        float scaledHeadSize = headSize * animScale;

        if (lastTarget instanceof PlayerEntity playerTarget) {
            try {
                SkinTextures skin = mc.getSkinProvider().getSkinTextures(playerTarget.getGameProfile());
                Identifier skinTexture = skin.texture();
                int textureId = mc.getTextureManager().getTexture(skinTexture).getGlId();

                float u = 8f / 64f;
                float v = 8f / 64f;
                float texW = 8f / 64f;
                float texH = 8f / 64f;

                renderContext.drawTexture(headX, headY, scaledHeadSize, scaledHeadSize, headRadius,
                        ColorRGBA.of(255, 255, 255, alpha), u, v, texW, texH, textureId);

                renderContext.drawTexture(headX, headY, scaledHeadSize, scaledHeadSize, headRadius,
                        ColorRGBA.of(255, 255, 255, alpha), 40f / 64f, v, texW, texH, textureId);
            } catch (Exception e) {
                renderContext.drawRect(headX, headY, scaledHeadSize, scaledHeadSize, headRadius, ColorRGBA.of(60, 60, 60, alpha));
            }
        } else {
            renderContext.drawRect(headX, headY, scaledHeadSize, scaledHeadSize, headRadius, ColorRGBA.of(60, 60, 60, alpha));
        }


        float nameX = scaledX + (paddingX + headSize + gap) * animScale;
        float nameY = centerY - nameHeight * animScale / 2f;
        renderContext.drawText(name, sf_pro, nameX, nameY, textSize * animScale, ColorRGBA.of(255, 255, 255, alpha));


        float circleX = scaledX + scaledWidth - paddingX * animScale - circleSize * animScale;
        float circleY = centerY - circleSize * animScale / 2f;
        float scaledCircle = circleSize * animScale;
        float circleRadius = scaledCircle / 2f;

        renderContext.drawBlur(circleX, circleY, scaledCircle, scaledCircle, circleRadius, 20, ColorRGBA.of(255, 255, 255, alpha));
        renderContext.drawRect(circleX, circleY, scaledCircle, scaledCircle, circleRadius, ColorRGBA.of(30, 30, 30, alpha));
        renderContext.drawBorder(circleX, circleY, scaledCircle, scaledCircle, circleRadius, 1.5f, themeColor.withAlpha(alpha));


        String healthStr = String.valueOf(health);
        float healthTextSize = 7.5f * animScale;
        float healthTextWidth = sf_pro.getWidth(healthStr, healthTextSize);
        float healthTextHeight = sf_pro.getMetrics().lineHeight() * healthTextSize;
        float healthTextX = circleX + (scaledCircle - healthTextWidth) / 2f;
        float healthTextY = circleY + (scaledCircle - healthTextHeight) / 2f;
        renderContext.drawText(healthStr, sf_pro, healthTextX, healthTextY, healthTextSize, ColorRGBA.of(255, 255, 255, alpha));
    }
}
мой скид
Посмотреть вложение 335504
AlekDLC
Посмотреть вложение 335505
1778514637193.png
даже мой скид выглядить лучше вашего
 
крутой скид:
Expand Collapse Copy
package itz.async.feature.ui.hud;

import itz.async.Async;
import itz.async.feature.event.impl.Render2DEvent;
import itz.async.feature.ui.hud.drag.DragComponent;
import itz.async.utils.animation.Animation;
import itz.async.utils.animation.Easing;
import itz.async.utils.client.ClientUtility;
import itz.async.utils.render.ColorRGBA;
import itz.async.utils.render.RenderContext;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.SkinTextures;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.Identifier;

import static itz.async.utils.render.Fonts.sf_pro;

public class TargetHudRenderer extends DragComponent {

    private final Animation animation = new Animation(300, Easing.CUBIC_OUT);
    private LivingEntity lastTarget = null;

    public TargetHudRenderer() {
        super("targethud");
        setDraggable(true);
        setAllowDragX(true);
        setAllowDragY(true);
        setX(10);
        setY(10);

        try {
            Async.getInstance().eventBus.register(this);
        } catch (Exception e) {}
    }

    @Override
    public void render(Render2DEvent event) {
        MinecraftClient mc = MinecraftClient.getInstance();
        if (mc.player == null) return;

        boolean isChatOrScreen = mc.currentScreen != null;
        LivingEntity target = null;

        if (isChatOrScreen) {
            target = mc.player;
        } else if (mc.targetedEntity instanceof LivingEntity living) {
            target = living;
        }

        if (target != null) {
            animation.animate(1);
            lastTarget = target;
        } else {
            animation.animate(0);
        }

        animation.update();

        float animScale = animation.getValue();
        if (animScale <= 0.01f || lastTarget == null) return;

        RenderContext renderContext = event.getContext();
        ColorRGBA themeColor = ClientUtility.getThemePrimaryColorRGBA();

        String name = lastTarget.getName().getString();
        int health = (int) Math.ceil(lastTarget.getHealth());

        float paddingX = 10f;
        float paddingY = 8f;
        float radius = 8f;

        float textSize = 8f;
        float headSize = 22f;
        float circleSize = 22f;
        float gap = 8f;
        float headRadius = 4f;

        float nameWidth = sf_pro.getWidth(name, textSize);
        float nameHeight = sf_pro.getMetrics().lineHeight() * textSize;

        float totalWidth = paddingX + headSize + gap + nameWidth + gap + circleSize + paddingX;
        float totalHeight = Math.max(headSize, circleSize) + paddingY * 2;

        float bgX = getX();
        float bgY = getY();

        setWidth(totalWidth);
        setHeight(totalHeight);

        float scaledWidth = totalWidth * animScale;
        float scaledHeight = totalHeight * animScale;
        float scaledX = bgX + (totalWidth - scaledWidth) / 2f;
        float scaledY = bgY + (totalHeight - scaledHeight) / 2f;

        int alpha = (int)(255 * animScale);


        renderContext.drawBlur(scaledX, scaledY, scaledWidth, scaledHeight, radius, 30, ColorRGBA.of(255, 255, 255, alpha));
        renderContext.drawRect(scaledX, scaledY, scaledWidth, scaledHeight, radius, ColorRGBA.of(0, 0, 0, (int)(180 * animScale)));
        renderContext.drawBorder(scaledX, scaledY, scaledWidth, scaledHeight, radius, 0.5f, ColorRGBA.of(80, 80, 80, (int)(100 * animScale)));

        float centerY = scaledY + scaledHeight / 2f;


        float headX = scaledX + paddingX * animScale;
        float headY = centerY - headSize * animScale / 2f;
        float scaledHeadSize = headSize * animScale;

        if (lastTarget instanceof PlayerEntity playerTarget) {
            try {
                SkinTextures skin = mc.getSkinProvider().getSkinTextures(playerTarget.getGameProfile());
                Identifier skinTexture = skin.texture();
                int textureId = mc.getTextureManager().getTexture(skinTexture).getGlId();

                float u = 8f / 64f;
                float v = 8f / 64f;
                float texW = 8f / 64f;
                float texH = 8f / 64f;

                renderContext.drawTexture(headX, headY, scaledHeadSize, scaledHeadSize, headRadius,
                        ColorRGBA.of(255, 255, 255, alpha), u, v, texW, texH, textureId);

                renderContext.drawTexture(headX, headY, scaledHeadSize, scaledHeadSize, headRadius,
                        ColorRGBA.of(255, 255, 255, alpha), 40f / 64f, v, texW, texH, textureId);
            } catch (Exception e) {
                renderContext.drawRect(headX, headY, scaledHeadSize, scaledHeadSize, headRadius, ColorRGBA.of(60, 60, 60, alpha));
            }
        } else {
            renderContext.drawRect(headX, headY, scaledHeadSize, scaledHeadSize, headRadius, ColorRGBA.of(60, 60, 60, alpha));
        }


        float nameX = scaledX + (paddingX + headSize + gap) * animScale;
        float nameY = centerY - nameHeight * animScale / 2f;
        renderContext.drawText(name, sf_pro, nameX, nameY, textSize * animScale, ColorRGBA.of(255, 255, 255, alpha));


        float circleX = scaledX + scaledWidth - paddingX * animScale - circleSize * animScale;
        float circleY = centerY - circleSize * animScale / 2f;
        float scaledCircle = circleSize * animScale;
        float circleRadius = scaledCircle / 2f;

        renderContext.drawBlur(circleX, circleY, scaledCircle, scaledCircle, circleRadius, 20, ColorRGBA.of(255, 255, 255, alpha));
        renderContext.drawRect(circleX, circleY, scaledCircle, scaledCircle, circleRadius, ColorRGBA.of(30, 30, 30, alpha));
        renderContext.drawBorder(circleX, circleY, scaledCircle, scaledCircle, circleRadius, 1.5f, themeColor.withAlpha(alpha));


        String healthStr = String.valueOf(health);
        float healthTextSize = 7.5f * animScale;
        float healthTextWidth = sf_pro.getWidth(healthStr, healthTextSize);
        float healthTextHeight = sf_pro.getMetrics().lineHeight() * healthTextSize;
        float healthTextX = circleX + (scaledCircle - healthTextWidth) / 2f;
        float healthTextY = circleY + (scaledCircle - healthTextHeight) / 2f;
        renderContext.drawText(healthStr, sf_pro, healthTextX, healthTextY, healthTextSize, ColorRGBA.of(255, 255, 255, alpha));
    }
}
мой скид
Посмотреть вложение 335504
AlekDLC
Посмотреть вложение 335505
ты чо глупый? надо делать через opengl... /del ужас
 
Назад
Сверху Снизу