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

Визуальная часть Нормальный TargetHud | Zenith Recode

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
30 Май 2025
Сообщения
191
Реакции
3
Выберите загрузчик игры
  1. Fabric
SS -
1771060826434.png

TargetHudComponent:
Expand Collapse Copy
package moscow.oxygen.client.hud.elements.component;
import java.util.Iterator;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.client.util.DefaultSkinHelper;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
import moscow.oxygen.base.animations.base.Animation;
import moscow.oxygen.base.animations.base.Easing;
import moscow.oxygen.base.font.Fonts;
import moscow.oxygen.client.hud.elements.draggable.DraggableHudElement;
import moscow.oxygen.client.modules.impl.combat.Aura;
import moscow.oxygen.client.modules.impl.misc.NameProtect;
import moscow.oxygen.client.modules.impl.misc.ScoreboardHealth;
import moscow.oxygen.utility.game.player.PlayerIntersectionUtil;
import moscow.oxygen.utility.render.display.base.BorderRadius;
import moscow.oxygen.utility.render.display.base.CustomDrawContext;
import moscow.oxygen.utility.render.display.base.color.ColorRGBA;
import moscow.oxygen.utility.render.display.shader.DrawUtil;
public class TargetHudComponent extends DraggableHudElement {
    private final Animation healthAnimation;
    private final Animation outdatedHealthAnimation;
    private final Animation gappleAnimation;
    private final Animation toggleAnimation;
    private final Animation toggleAnimationMetanoise;
    private LivingEntity target;
    public TargetHudComponent(String name, float initialX, float initialY, float windowWidth, float windowHeight, float offsetX, float offsetY, DraggableHudElement.Align align) {
        super(name, initialX, initialY, windowWidth, windowHeight, offsetX, offsetY, align);
        this.healthAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.outdatedHealthAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.gappleAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.toggleAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.toggleAnimationMetanoise = new Animation(250L, Easing.CUBIC_OUT);
    }
    public void render(CustomDrawContext ctx) {
        Aura aura = Aura.INSTANCE;
        LivingEntity target = mc.currentScreen instanceof ChatScreen ? mc.player : aura.getTarget();
        this.setTarget((LivingEntity)target);
        if (this.toggleAnimation.getValue() > 0.001F && this.target != null) {
            this.renderTargetHud(ctx, this.target, this.toggleAnimation.getValue());
        }
    }
    private void renderTargetHud(CustomDrawContext ctx, LivingEntity target, float animation) {
        float posX = this.x;
        float posY = this.y;
        float width = 120.0F;
        float height = 34.0F;
        float hp = ScoreboardHealth.INSTANCE.isEnabled() ? PlayerIntersectionUtil.getHealth(target) : target.getHealth();
        float maxHp = target.getMaxHealth();
        this.healthAnimation.update(hp / maxHp);
        if (this.outdatedHealthAnimation.getValue() < this.healthAnimation.getValue()) {
            this.outdatedHealthAnimation.setValue(this.healthAnimation.getValue());
        } else {
            this.outdatedHealthAnimation.update(hp / maxHp);
        }
        this.gappleAnimation.update(target.getAbsorptionAmount() / maxHp);
        ColorRGBA bgColor = new ColorRGBA(18, 18, 20, 240 * animation);
     
        DrawUtil.drawRoundedRect(ctx.getMatrices(), posX, posY, width, height, BorderRadius.all(7.0F), bgColor);
        Identifier skinTextures = null;
        if (mc.getNetworkHandler() != null) {
            Iterator var11 = mc.getNetworkHandler().getPlayerList().iterator();
            while(var11.hasNext()) {
                PlayerListEntry playerListEntry = (PlayerListEntry)var11.next();
                if (playerListEntry.getProfile().getName().equals(target.getNameForScoreboard())) {
                    skinTextures = playerListEntry.getSkinTextures().texture();
                }
            }
        }
        if (skinTextures == null) {
            skinTextures = DefaultSkinHelper.getSteve().texture();
        }
        float headSize = 22.0F;
     
        DrawUtil.drawPlayerHeadWithRoundedShader(ctx.getMatrices(), skinTextures, posX + 5.0F, posY + (height - headSize) / 2.0F, headSize, BorderRadius.all(4.5F), ColorRGBA.WHITE.withAlpha(animation * 255.0F));
     
        ColorRGBA textColor = new ColorRGBA(255, 255, 255, 255 * animation);
        ColorRGBA grayTextColor = new ColorRGBA(180, 180, 180, 255 * animation);
     
        String name = target == mc.player ? NameProtect.getCustomName() : target.getNameForScoreboard();
        ctx.drawText(Fonts.REGULAR.getFont(7.5F), name, posX + 33.0F, posY + 8.0F, textColor);
        String hpText = String.format("%.0f", hp + target.getAbsorptionAmount());
        float hpTextW = Fonts.REGULAR.getWidth(hpText, 7.5F);
        ctx.drawText(Fonts.REGULAR.getFont(7.5F), hpText, posX + width - 8.0F - hpTextW, posY + 8.0F, grayTextColor);
     
        float barX = posX + 33.0F;
        float barY = posY + 21.0F;
        float barW = width - 33.0F - 8.0F;
        float barH = 4.0F;
     
        ColorRGBA barBgColor = new ColorRGBA(40, 40, 45, 255 * animation);
        ColorRGBA healthBarColor = new ColorRGBA(255, 255, 255, 255 * animation);
        ColorRGBA outdatedBarColor = new ColorRGBA(255, 255, 255, 80 * animation);
     
        DrawUtil.drawRoundedRect(ctx.getMatrices(), barX, barY, barW, barH, BorderRadius.all(2.5F), barBgColor);
        float outdatedW = barW * this.outdatedHealthAnimation.getValue();
        if (outdatedW > 0.1F) {
            DrawUtil.drawRoundedRect(ctx.getMatrices(), barX, barY, outdatedW, barH, BorderRadius.all(2.5F), outdatedBarColor);
        }
        float healthW = barW * this.healthAnimation.getValue();
        if (healthW > 0.1F) {
            DrawUtil.drawRoundedRect(ctx.getMatrices(), barX, barY, healthW, barH, BorderRadius.all(2.5F), healthBarColor);
        }
        this.width = width;
        this.height = height;
    }
    public void setTarget(LivingEntity target) {
        if (target == null) {
            this.toggleAnimation.update(0.0F);
            if (this.toggleAnimation.getValue() < 0.01F) {
                this.target = null;
            }
        } else {
            this.target = target;
            this.toggleAnimation.update(1.0F);
        }
    }
}
 
SS -
Посмотреть вложение 327519
TargetHudComponent:
Expand Collapse Copy
package moscow.oxygen.client.hud.elements.component;
import java.util.Iterator;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.client.util.DefaultSkinHelper;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
import moscow.oxygen.base.animations.base.Animation;
import moscow.oxygen.base.animations.base.Easing;
import moscow.oxygen.base.font.Fonts;
import moscow.oxygen.client.hud.elements.draggable.DraggableHudElement;
import moscow.oxygen.client.modules.impl.combat.Aura;
import moscow.oxygen.client.modules.impl.misc.NameProtect;
import moscow.oxygen.client.modules.impl.misc.ScoreboardHealth;
import moscow.oxygen.utility.game.player.PlayerIntersectionUtil;
import moscow.oxygen.utility.render.display.base.BorderRadius;
import moscow.oxygen.utility.render.display.base.CustomDrawContext;
import moscow.oxygen.utility.render.display.base.color.ColorRGBA;
import moscow.oxygen.utility.render.display.shader.DrawUtil;
public class TargetHudComponent extends DraggableHudElement {
    private final Animation healthAnimation;
    private final Animation outdatedHealthAnimation;
    private final Animation gappleAnimation;
    private final Animation toggleAnimation;
    private final Animation toggleAnimationMetanoise;
    private LivingEntity target;
    public TargetHudComponent(String name, float initialX, float initialY, float windowWidth, float windowHeight, float offsetX, float offsetY, DraggableHudElement.Align align) {
        super(name, initialX, initialY, windowWidth, windowHeight, offsetX, offsetY, align);
        this.healthAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.outdatedHealthAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.gappleAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.toggleAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.toggleAnimationMetanoise = new Animation(250L, Easing.CUBIC_OUT);
    }
    public void render(CustomDrawContext ctx) {
        Aura aura = Aura.INSTANCE;
        LivingEntity target = mc.currentScreen instanceof ChatScreen ? mc.player : aura.getTarget();
        this.setTarget((LivingEntity)target);
        if (this.toggleAnimation.getValue() > 0.001F && this.target != null) {
            this.renderTargetHud(ctx, this.target, this.toggleAnimation.getValue());
        }
    }
    private void renderTargetHud(CustomDrawContext ctx, LivingEntity target, float animation) {
        float posX = this.x;
        float posY = this.y;
        float width = 120.0F;
        float height = 34.0F;
        float hp = ScoreboardHealth.INSTANCE.isEnabled() ? PlayerIntersectionUtil.getHealth(target) : target.getHealth();
        float maxHp = target.getMaxHealth();
        this.healthAnimation.update(hp / maxHp);
        if (this.outdatedHealthAnimation.getValue() < this.healthAnimation.getValue()) {
            this.outdatedHealthAnimation.setValue(this.healthAnimation.getValue());
        } else {
            this.outdatedHealthAnimation.update(hp / maxHp);
        }
        this.gappleAnimation.update(target.getAbsorptionAmount() / maxHp);
        ColorRGBA bgColor = new ColorRGBA(18, 18, 20, 240 * animation);
    
        DrawUtil.drawRoundedRect(ctx.getMatrices(), posX, posY, width, height, BorderRadius.all(7.0F), bgColor);
        Identifier skinTextures = null;
        if (mc.getNetworkHandler() != null) {
            Iterator var11 = mc.getNetworkHandler().getPlayerList().iterator();
            while(var11.hasNext()) {
                PlayerListEntry playerListEntry = (PlayerListEntry)var11.next();
                if (playerListEntry.getProfile().getName().equals(target.getNameForScoreboard())) {
                    skinTextures = playerListEntry.getSkinTextures().texture();
                }
            }
        }
        if (skinTextures == null) {
            skinTextures = DefaultSkinHelper.getSteve().texture();
        }
        float headSize = 22.0F;
    
        DrawUtil.drawPlayerHeadWithRoundedShader(ctx.getMatrices(), skinTextures, posX + 5.0F, posY + (height - headSize) / 2.0F, headSize, BorderRadius.all(4.5F), ColorRGBA.WHITE.withAlpha(animation * 255.0F));
    
        ColorRGBA textColor = new ColorRGBA(255, 255, 255, 255 * animation);
        ColorRGBA grayTextColor = new ColorRGBA(180, 180, 180, 255 * animation);
    
        String name = target == mc.player ? NameProtect.getCustomName() : target.getNameForScoreboard();
        ctx.drawText(Fonts.REGULAR.getFont(7.5F), name, posX + 33.0F, posY + 8.0F, textColor);
        String hpText = String.format("%.0f", hp + target.getAbsorptionAmount());
        float hpTextW = Fonts.REGULAR.getWidth(hpText, 7.5F);
        ctx.drawText(Fonts.REGULAR.getFont(7.5F), hpText, posX + width - 8.0F - hpTextW, posY + 8.0F, grayTextColor);
    
        float barX = posX + 33.0F;
        float barY = posY + 21.0F;
        float barW = width - 33.0F - 8.0F;
        float barH = 4.0F;
    
        ColorRGBA barBgColor = new ColorRGBA(40, 40, 45, 255 * animation);
        ColorRGBA healthBarColor = new ColorRGBA(255, 255, 255, 255 * animation);
        ColorRGBA outdatedBarColor = new ColorRGBA(255, 255, 255, 80 * animation);
    
        DrawUtil.drawRoundedRect(ctx.getMatrices(), barX, barY, barW, barH, BorderRadius.all(2.5F), barBgColor);
        float outdatedW = barW * this.outdatedHealthAnimation.getValue();
        if (outdatedW > 0.1F) {
            DrawUtil.drawRoundedRect(ctx.getMatrices(), barX, barY, outdatedW, barH, BorderRadius.all(2.5F), outdatedBarColor);
        }
        float healthW = barW * this.healthAnimation.getValue();
        if (healthW > 0.1F) {
            DrawUtil.drawRoundedRect(ctx.getMatrices(), barX, barY, healthW, barH, BorderRadius.all(2.5F), healthBarColor);
        }
        this.width = width;
        this.height = height;
    }
    public void setTarget(LivingEntity target) {
        if (target == null) {
            this.toggleAnimation.update(0.0F);
            if (this.toggleAnimation.getValue() < 0.01F) {
                this.target = null;
            }
        } else {
            this.target = target;
            this.toggleAnimation.update(1.0F);
        }
    }
}
точно нормальный?
 
SS -
Посмотреть вложение 327519
TargetHudComponent:
Expand Collapse Copy
package moscow.oxygen.client.hud.elements.component;
import java.util.Iterator;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.client.util.DefaultSkinHelper;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
import moscow.oxygen.base.animations.base.Animation;
import moscow.oxygen.base.animations.base.Easing;
import moscow.oxygen.base.font.Fonts;
import moscow.oxygen.client.hud.elements.draggable.DraggableHudElement;
import moscow.oxygen.client.modules.impl.combat.Aura;
import moscow.oxygen.client.modules.impl.misc.NameProtect;
import moscow.oxygen.client.modules.impl.misc.ScoreboardHealth;
import moscow.oxygen.utility.game.player.PlayerIntersectionUtil;
import moscow.oxygen.utility.render.display.base.BorderRadius;
import moscow.oxygen.utility.render.display.base.CustomDrawContext;
import moscow.oxygen.utility.render.display.base.color.ColorRGBA;
import moscow.oxygen.utility.render.display.shader.DrawUtil;
public class TargetHudComponent extends DraggableHudElement {
    private final Animation healthAnimation;
    private final Animation outdatedHealthAnimation;
    private final Animation gappleAnimation;
    private final Animation toggleAnimation;
    private final Animation toggleAnimationMetanoise;
    private LivingEntity target;
    public TargetHudComponent(String name, float initialX, float initialY, float windowWidth, float windowHeight, float offsetX, float offsetY, DraggableHudElement.Align align) {
        super(name, initialX, initialY, windowWidth, windowHeight, offsetX, offsetY, align);
        this.healthAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.outdatedHealthAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.gappleAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.toggleAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.toggleAnimationMetanoise = new Animation(250L, Easing.CUBIC_OUT);
    }
    public void render(CustomDrawContext ctx) {
        Aura aura = Aura.INSTANCE;
        LivingEntity target = mc.currentScreen instanceof ChatScreen ? mc.player : aura.getTarget();
        this.setTarget((LivingEntity)target);
        if (this.toggleAnimation.getValue() > 0.001F && this.target != null) {
            this.renderTargetHud(ctx, this.target, this.toggleAnimation.getValue());
        }
    }
    private void renderTargetHud(CustomDrawContext ctx, LivingEntity target, float animation) {
        float posX = this.x;
        float posY = this.y;
        float width = 120.0F;
        float height = 34.0F;
        float hp = ScoreboardHealth.INSTANCE.isEnabled() ? PlayerIntersectionUtil.getHealth(target) : target.getHealth();
        float maxHp = target.getMaxHealth();
        this.healthAnimation.update(hp / maxHp);
        if (this.outdatedHealthAnimation.getValue() < this.healthAnimation.getValue()) {
            this.outdatedHealthAnimation.setValue(this.healthAnimation.getValue());
        } else {
            this.outdatedHealthAnimation.update(hp / maxHp);
        }
        this.gappleAnimation.update(target.getAbsorptionAmount() / maxHp);
        ColorRGBA bgColor = new ColorRGBA(18, 18, 20, 240 * animation);
    
        DrawUtil.drawRoundedRect(ctx.getMatrices(), posX, posY, width, height, BorderRadius.all(7.0F), bgColor);
        Identifier skinTextures = null;
        if (mc.getNetworkHandler() != null) {
            Iterator var11 = mc.getNetworkHandler().getPlayerList().iterator();
            while(var11.hasNext()) {
                PlayerListEntry playerListEntry = (PlayerListEntry)var11.next();
                if (playerListEntry.getProfile().getName().equals(target.getNameForScoreboard())) {
                    skinTextures = playerListEntry.getSkinTextures().texture();
                }
            }
        }
        if (skinTextures == null) {
            skinTextures = DefaultSkinHelper.getSteve().texture();
        }
        float headSize = 22.0F;
    
        DrawUtil.drawPlayerHeadWithRoundedShader(ctx.getMatrices(), skinTextures, posX + 5.0F, posY + (height - headSize) / 2.0F, headSize, BorderRadius.all(4.5F), ColorRGBA.WHITE.withAlpha(animation * 255.0F));
    
        ColorRGBA textColor = new ColorRGBA(255, 255, 255, 255 * animation);
        ColorRGBA grayTextColor = new ColorRGBA(180, 180, 180, 255 * animation);
    
        String name = target == mc.player ? NameProtect.getCustomName() : target.getNameForScoreboard();
        ctx.drawText(Fonts.REGULAR.getFont(7.5F), name, posX + 33.0F, posY + 8.0F, textColor);
        String hpText = String.format("%.0f", hp + target.getAbsorptionAmount());
        float hpTextW = Fonts.REGULAR.getWidth(hpText, 7.5F);
        ctx.drawText(Fonts.REGULAR.getFont(7.5F), hpText, posX + width - 8.0F - hpTextW, posY + 8.0F, grayTextColor);
    
        float barX = posX + 33.0F;
        float barY = posY + 21.0F;
        float barW = width - 33.0F - 8.0F;
        float barH = 4.0F;
    
        ColorRGBA barBgColor = new ColorRGBA(40, 40, 45, 255 * animation);
        ColorRGBA healthBarColor = new ColorRGBA(255, 255, 255, 255 * animation);
        ColorRGBA outdatedBarColor = new ColorRGBA(255, 255, 255, 80 * animation);
    
        DrawUtil.drawRoundedRect(ctx.getMatrices(), barX, barY, barW, barH, BorderRadius.all(2.5F), barBgColor);
        float outdatedW = barW * this.outdatedHealthAnimation.getValue();
        if (outdatedW > 0.1F) {
            DrawUtil.drawRoundedRect(ctx.getMatrices(), barX, barY, outdatedW, barH, BorderRadius.all(2.5F), outdatedBarColor);
        }
        float healthW = barW * this.healthAnimation.getValue();
        if (healthW > 0.1F) {
            DrawUtil.drawRoundedRect(ctx.getMatrices(), barX, barY, healthW, barH, BorderRadius.all(2.5F), healthBarColor);
        }
        this.width = width;
        this.height = height;
    }
    public void setTarget(LivingEntity target) {
        if (target == null) {
            this.toggleAnimation.update(0.0F);
            if (this.toggleAnimation.getValue() < 0.01F) {
                this.target = null;
            }
        } else {
            this.target = target;
            this.toggleAnimation.update(1.0F);
        }
    }
}
изуродовал
 
SS -
Посмотреть вложение 327519
TargetHudComponent:
Expand Collapse Copy
package moscow.oxygen.client.hud.elements.component;
import java.util.Iterator;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.client.util.DefaultSkinHelper;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
import moscow.oxygen.base.animations.base.Animation;
import moscow.oxygen.base.animations.base.Easing;
import moscow.oxygen.base.font.Fonts;
import moscow.oxygen.client.hud.elements.draggable.DraggableHudElement;
import moscow.oxygen.client.modules.impl.combat.Aura;
import moscow.oxygen.client.modules.impl.misc.NameProtect;
import moscow.oxygen.client.modules.impl.misc.ScoreboardHealth;
import moscow.oxygen.utility.game.player.PlayerIntersectionUtil;
import moscow.oxygen.utility.render.display.base.BorderRadius;
import moscow.oxygen.utility.render.display.base.CustomDrawContext;
import moscow.oxygen.utility.render.display.base.color.ColorRGBA;
import moscow.oxygen.utility.render.display.shader.DrawUtil;
public class TargetHudComponent extends DraggableHudElement {
    private final Animation healthAnimation;
    private final Animation outdatedHealthAnimation;
    private final Animation gappleAnimation;
    private final Animation toggleAnimation;
    private final Animation toggleAnimationMetanoise;
    private LivingEntity target;
    public TargetHudComponent(String name, float initialX, float initialY, float windowWidth, float windowHeight, float offsetX, float offsetY, DraggableHudElement.Align align) {
        super(name, initialX, initialY, windowWidth, windowHeight, offsetX, offsetY, align);
        this.healthAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.outdatedHealthAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.gappleAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.toggleAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.toggleAnimationMetanoise = new Animation(250L, Easing.CUBIC_OUT);
    }
    public void render(CustomDrawContext ctx) {
        Aura aura = Aura.INSTANCE;
        LivingEntity target = mc.currentScreen instanceof ChatScreen ? mc.player : aura.getTarget();
        this.setTarget((LivingEntity)target);
        if (this.toggleAnimation.getValue() > 0.001F && this.target != null) {
            this.renderTargetHud(ctx, this.target, this.toggleAnimation.getValue());
        }
    }
    private void renderTargetHud(CustomDrawContext ctx, LivingEntity target, float animation) {
        float posX = this.x;
        float posY = this.y;
        float width = 120.0F;
        float height = 34.0F;
        float hp = ScoreboardHealth.INSTANCE.isEnabled() ? PlayerIntersectionUtil.getHealth(target) : target.getHealth();
        float maxHp = target.getMaxHealth();
        this.healthAnimation.update(hp / maxHp);
        if (this.outdatedHealthAnimation.getValue() < this.healthAnimation.getValue()) {
            this.outdatedHealthAnimation.setValue(this.healthAnimation.getValue());
        } else {
            this.outdatedHealthAnimation.update(hp / maxHp);
        }
        this.gappleAnimation.update(target.getAbsorptionAmount() / maxHp);
        ColorRGBA bgColor = new ColorRGBA(18, 18, 20, 240 * animation);
    
        DrawUtil.drawRoundedRect(ctx.getMatrices(), posX, posY, width, height, BorderRadius.all(7.0F), bgColor);
        Identifier skinTextures = null;
        if (mc.getNetworkHandler() != null) {
            Iterator var11 = mc.getNetworkHandler().getPlayerList().iterator();
            while(var11.hasNext()) {
                PlayerListEntry playerListEntry = (PlayerListEntry)var11.next();
                if (playerListEntry.getProfile().getName().equals(target.getNameForScoreboard())) {
                    skinTextures = playerListEntry.getSkinTextures().texture();
                }
            }
        }
        if (skinTextures == null) {
            skinTextures = DefaultSkinHelper.getSteve().texture();
        }
        float headSize = 22.0F;
    
        DrawUtil.drawPlayerHeadWithRoundedShader(ctx.getMatrices(), skinTextures, posX + 5.0F, posY + (height - headSize) / 2.0F, headSize, BorderRadius.all(4.5F), ColorRGBA.WHITE.withAlpha(animation * 255.0F));
    
        ColorRGBA textColor = new ColorRGBA(255, 255, 255, 255 * animation);
        ColorRGBA grayTextColor = new ColorRGBA(180, 180, 180, 255 * animation);
    
        String name = target == mc.player ? NameProtect.getCustomName() : target.getNameForScoreboard();
        ctx.drawText(Fonts.REGULAR.getFont(7.5F), name, posX + 33.0F, posY + 8.0F, textColor);
        String hpText = String.format("%.0f", hp + target.getAbsorptionAmount());
        float hpTextW = Fonts.REGULAR.getWidth(hpText, 7.5F);
        ctx.drawText(Fonts.REGULAR.getFont(7.5F), hpText, posX + width - 8.0F - hpTextW, posY + 8.0F, grayTextColor);
    
        float barX = posX + 33.0F;
        float barY = posY + 21.0F;
        float barW = width - 33.0F - 8.0F;
        float barH = 4.0F;
    
        ColorRGBA barBgColor = new ColorRGBA(40, 40, 45, 255 * animation);
        ColorRGBA healthBarColor = new ColorRGBA(255, 255, 255, 255 * animation);
        ColorRGBA outdatedBarColor = new ColorRGBA(255, 255, 255, 80 * animation);
    
        DrawUtil.drawRoundedRect(ctx.getMatrices(), barX, barY, barW, barH, BorderRadius.all(2.5F), barBgColor);
        float outdatedW = barW * this.outdatedHealthAnimation.getValue();
        if (outdatedW > 0.1F) {
            DrawUtil.drawRoundedRect(ctx.getMatrices(), barX, barY, outdatedW, barH, BorderRadius.all(2.5F), outdatedBarColor);
        }
        float healthW = barW * this.healthAnimation.getValue();
        if (healthW > 0.1F) {
            DrawUtil.drawRoundedRect(ctx.getMatrices(), barX, barY, healthW, barH, BorderRadius.all(2.5F), healthBarColor);
        }
        this.width = width;
        this.height = height;
    }
    public void setTarget(LivingEntity target) {
        if (target == null) {
            this.toggleAnimation.update(0.0F);
            if (this.toggleAnimation.getValue() < 0.01F) {
                this.target = null;
            }
        } else {
            this.target = target;
            this.toggleAnimation.update(1.0F);
        }
    }
}
ну годненько
 
SS -
Посмотреть вложение 327519
TargetHudComponent:
Expand Collapse Copy
package moscow.oxygen.client.hud.elements.component;
import java.util.Iterator;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.client.util.DefaultSkinHelper;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
import moscow.oxygen.base.animations.base.Animation;
import moscow.oxygen.base.animations.base.Easing;
import moscow.oxygen.base.font.Fonts;
import moscow.oxygen.client.hud.elements.draggable.DraggableHudElement;
import moscow.oxygen.client.modules.impl.combat.Aura;
import moscow.oxygen.client.modules.impl.misc.NameProtect;
import moscow.oxygen.client.modules.impl.misc.ScoreboardHealth;
import moscow.oxygen.utility.game.player.PlayerIntersectionUtil;
import moscow.oxygen.utility.render.display.base.BorderRadius;
import moscow.oxygen.utility.render.display.base.CustomDrawContext;
import moscow.oxygen.utility.render.display.base.color.ColorRGBA;
import moscow.oxygen.utility.render.display.shader.DrawUtil;
public class TargetHudComponent extends DraggableHudElement {
    private final Animation healthAnimation;
    private final Animation outdatedHealthAnimation;
    private final Animation gappleAnimation;
    private final Animation toggleAnimation;
    private final Animation toggleAnimationMetanoise;
    private LivingEntity target;
    public TargetHudComponent(String name, float initialX, float initialY, float windowWidth, float windowHeight, float offsetX, float offsetY, DraggableHudElement.Align align) {
        super(name, initialX, initialY, windowWidth, windowHeight, offsetX, offsetY, align);
        this.healthAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.outdatedHealthAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.gappleAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.toggleAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.toggleAnimationMetanoise = new Animation(250L, Easing.CUBIC_OUT);
    }
    public void render(CustomDrawContext ctx) {
        Aura aura = Aura.INSTANCE;
        LivingEntity target = mc.currentScreen instanceof ChatScreen ? mc.player : aura.getTarget();
        this.setTarget((LivingEntity)target);
        if (this.toggleAnimation.getValue() > 0.001F && this.target != null) {
            this.renderTargetHud(ctx, this.target, this.toggleAnimation.getValue());
        }
    }
    private void renderTargetHud(CustomDrawContext ctx, LivingEntity target, float animation) {
        float posX = this.x;
        float posY = this.y;
        float width = 120.0F;
        float height = 34.0F;
        float hp = ScoreboardHealth.INSTANCE.isEnabled() ? PlayerIntersectionUtil.getHealth(target) : target.getHealth();
        float maxHp = target.getMaxHealth();
        this.healthAnimation.update(hp / maxHp);
        if (this.outdatedHealthAnimation.getValue() < this.healthAnimation.getValue()) {
            this.outdatedHealthAnimation.setValue(this.healthAnimation.getValue());
        } else {
            this.outdatedHealthAnimation.update(hp / maxHp);
        }
        this.gappleAnimation.update(target.getAbsorptionAmount() / maxHp);
        ColorRGBA bgColor = new ColorRGBA(18, 18, 20, 240 * animation);
    
        DrawUtil.drawRoundedRect(ctx.getMatrices(), posX, posY, width, height, BorderRadius.all(7.0F), bgColor);
        Identifier skinTextures = null;
        if (mc.getNetworkHandler() != null) {
            Iterator var11 = mc.getNetworkHandler().getPlayerList().iterator();
            while(var11.hasNext()) {
                PlayerListEntry playerListEntry = (PlayerListEntry)var11.next();
                if (playerListEntry.getProfile().getName().equals(target.getNameForScoreboard())) {
                    skinTextures = playerListEntry.getSkinTextures().texture();
                }
            }
        }
        if (skinTextures == null) {
            skinTextures = DefaultSkinHelper.getSteve().texture();
        }
        float headSize = 22.0F;
    
        DrawUtil.drawPlayerHeadWithRoundedShader(ctx.getMatrices(), skinTextures, posX + 5.0F, posY + (height - headSize) / 2.0F, headSize, BorderRadius.all(4.5F), ColorRGBA.WHITE.withAlpha(animation * 255.0F));
    
        ColorRGBA textColor = new ColorRGBA(255, 255, 255, 255 * animation);
        ColorRGBA grayTextColor = new ColorRGBA(180, 180, 180, 255 * animation);
    
        String name = target == mc.player ? NameProtect.getCustomName() : target.getNameForScoreboard();
        ctx.drawText(Fonts.REGULAR.getFont(7.5F), name, posX + 33.0F, posY + 8.0F, textColor);
        String hpText = String.format("%.0f", hp + target.getAbsorptionAmount());
        float hpTextW = Fonts.REGULAR.getWidth(hpText, 7.5F);
        ctx.drawText(Fonts.REGULAR.getFont(7.5F), hpText, posX + width - 8.0F - hpTextW, posY + 8.0F, grayTextColor);
    
        float barX = posX + 33.0F;
        float barY = posY + 21.0F;
        float barW = width - 33.0F - 8.0F;
        float barH = 4.0F;
    
        ColorRGBA barBgColor = new ColorRGBA(40, 40, 45, 255 * animation);
        ColorRGBA healthBarColor = new ColorRGBA(255, 255, 255, 255 * animation);
        ColorRGBA outdatedBarColor = new ColorRGBA(255, 255, 255, 80 * animation);
    
        DrawUtil.drawRoundedRect(ctx.getMatrices(), barX, barY, barW, barH, BorderRadius.all(2.5F), barBgColor);
        float outdatedW = barW * this.outdatedHealthAnimation.getValue();
        if (outdatedW > 0.1F) {
            DrawUtil.drawRoundedRect(ctx.getMatrices(), barX, barY, outdatedW, barH, BorderRadius.all(2.5F), outdatedBarColor);
        }
        float healthW = barW * this.healthAnimation.getValue();
        if (healthW > 0.1F) {
            DrawUtil.drawRoundedRect(ctx.getMatrices(), barX, barY, healthW, barH, BorderRadius.all(2.5F), healthBarColor);
        }
        this.width = width;
        this.height = height;
    }
    public void setTarget(LivingEntity target) {
        if (target == null) {
            this.toggleAnimation.update(0.0F);
            if (this.toggleAnimation.getValue() < 0.01F) {
                this.target = null;
            }
        } else {
            this.target = target;
            this.toggleAnimation.update(1.0F);
        }
    }
}
а что тут адекватного?
 
SS -
Посмотреть вложение 327519
TargetHudComponent:
Expand Collapse Copy
package moscow.oxygen.client.hud.elements.component;
import java.util.Iterator;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.client.util.DefaultSkinHelper;
import net.minecraft.entity.LivingEntity;
import net.minecraft.util.Identifier;
import moscow.oxygen.base.animations.base.Animation;
import moscow.oxygen.base.animations.base.Easing;
import moscow.oxygen.base.font.Fonts;
import moscow.oxygen.client.hud.elements.draggable.DraggableHudElement;
import moscow.oxygen.client.modules.impl.combat.Aura;
import moscow.oxygen.client.modules.impl.misc.NameProtect;
import moscow.oxygen.client.modules.impl.misc.ScoreboardHealth;
import moscow.oxygen.utility.game.player.PlayerIntersectionUtil;
import moscow.oxygen.utility.render.display.base.BorderRadius;
import moscow.oxygen.utility.render.display.base.CustomDrawContext;
import moscow.oxygen.utility.render.display.base.color.ColorRGBA;
import moscow.oxygen.utility.render.display.shader.DrawUtil;
public class TargetHudComponent extends DraggableHudElement {
    private final Animation healthAnimation;
    private final Animation outdatedHealthAnimation;
    private final Animation gappleAnimation;
    private final Animation toggleAnimation;
    private final Animation toggleAnimationMetanoise;
    private LivingEntity target;
    public TargetHudComponent(String name, float initialX, float initialY, float windowWidth, float windowHeight, float offsetX, float offsetY, DraggableHudElement.Align align) {
        super(name, initialX, initialY, windowWidth, windowHeight, offsetX, offsetY, align);
        this.healthAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.outdatedHealthAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.gappleAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.toggleAnimation = new Animation(250L, Easing.CUBIC_OUT);
        this.toggleAnimationMetanoise = new Animation(250L, Easing.CUBIC_OUT);
    }
    public void render(CustomDrawContext ctx) {
        Aura aura = Aura.INSTANCE;
        LivingEntity target = mc.currentScreen instanceof ChatScreen ? mc.player : aura.getTarget();
        this.setTarget((LivingEntity)target);
        if (this.toggleAnimation.getValue() > 0.001F && this.target != null) {
            this.renderTargetHud(ctx, this.target, this.toggleAnimation.getValue());
        }
    }
    private void renderTargetHud(CustomDrawContext ctx, LivingEntity target, float animation) {
        float posX = this.x;
        float posY = this.y;
        float width = 120.0F;
        float height = 34.0F;
        float hp = ScoreboardHealth.INSTANCE.isEnabled() ? PlayerIntersectionUtil.getHealth(target) : target.getHealth();
        float maxHp = target.getMaxHealth();
        this.healthAnimation.update(hp / maxHp);
        if (this.outdatedHealthAnimation.getValue() < this.healthAnimation.getValue()) {
            this.outdatedHealthAnimation.setValue(this.healthAnimation.getValue());
        } else {
            this.outdatedHealthAnimation.update(hp / maxHp);
        }
        this.gappleAnimation.update(target.getAbsorptionAmount() / maxHp);
        ColorRGBA bgColor = new ColorRGBA(18, 18, 20, 240 * animation);
    
        DrawUtil.drawRoundedRect(ctx.getMatrices(), posX, posY, width, height, BorderRadius.all(7.0F), bgColor);
        Identifier skinTextures = null;
        if (mc.getNetworkHandler() != null) {
            Iterator var11 = mc.getNetworkHandler().getPlayerList().iterator();
            while(var11.hasNext()) {
                PlayerListEntry playerListEntry = (PlayerListEntry)var11.next();
                if (playerListEntry.getProfile().getName().equals(target.getNameForScoreboard())) {
                    skinTextures = playerListEntry.getSkinTextures().texture();
                }
            }
        }
        if (skinTextures == null) {
            skinTextures = DefaultSkinHelper.getSteve().texture();
        }
        float headSize = 22.0F;
    
        DrawUtil.drawPlayerHeadWithRoundedShader(ctx.getMatrices(), skinTextures, posX + 5.0F, posY + (height - headSize) / 2.0F, headSize, BorderRadius.all(4.5F), ColorRGBA.WHITE.withAlpha(animation * 255.0F));
    
        ColorRGBA textColor = new ColorRGBA(255, 255, 255, 255 * animation);
        ColorRGBA grayTextColor = new ColorRGBA(180, 180, 180, 255 * animation);
    
        String name = target == mc.player ? NameProtect.getCustomName() : target.getNameForScoreboard();
        ctx.drawText(Fonts.REGULAR.getFont(7.5F), name, posX + 33.0F, posY + 8.0F, textColor);
        String hpText = String.format("%.0f", hp + target.getAbsorptionAmount());
        float hpTextW = Fonts.REGULAR.getWidth(hpText, 7.5F);
        ctx.drawText(Fonts.REGULAR.getFont(7.5F), hpText, posX + width - 8.0F - hpTextW, posY + 8.0F, grayTextColor);
    
        float barX = posX + 33.0F;
        float barY = posY + 21.0F;
        float barW = width - 33.0F - 8.0F;
        float barH = 4.0F;
    
        ColorRGBA barBgColor = new ColorRGBA(40, 40, 45, 255 * animation);
        ColorRGBA healthBarColor = new ColorRGBA(255, 255, 255, 255 * animation);
        ColorRGBA outdatedBarColor = new ColorRGBA(255, 255, 255, 80 * animation);
    
        DrawUtil.drawRoundedRect(ctx.getMatrices(), barX, barY, barW, barH, BorderRadius.all(2.5F), barBgColor);
        float outdatedW = barW * this.outdatedHealthAnimation.getValue();
        if (outdatedW > 0.1F) {
            DrawUtil.drawRoundedRect(ctx.getMatrices(), barX, barY, outdatedW, barH, BorderRadius.all(2.5F), outdatedBarColor);
        }
        float healthW = barW * this.healthAnimation.getValue();
        if (healthW > 0.1F) {
            DrawUtil.drawRoundedRect(ctx.getMatrices(), barX, barY, healthW, barH, BorderRadius.all(2.5F), healthBarColor);
        }
        this.width = width;
        this.height = height;
    }
    public void setTarget(LivingEntity target) {
        if (target == null) {
            this.toggleAnimation.update(0.0F);
            if (this.toggleAnimation.getValue() < 0.01F) {
                this.target = null;
            }
        } else {
            this.target = target;
            this.toggleAnimation.update(1.0F);
        }
    }
}
пиздец что с округлением /del
 
Назад
Сверху Снизу