Начинающий
			
			
				
					
				
			
		- Статус
- Оффлайн
- Регистрация
- 27 Май 2024
- Сообщения
- 3
- Реакции
- 0
- Выберите загрузчик игры
- Прочие моды
 
Кароч,это обычный армор худ ева вейра,но с драггингом и с фоном
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
ssПосмотреть вложение 316705
				
			
			
				код:
			
		
		
		package eva.pasta.ui.clienthud.impl;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import eva.pasta.events.EventRender2D;
import eva.pasta.ui.clienthud.updater.ElementRenderer;
import eva.pasta.utils.animations.AnimationUtility;
import eva.pasta.utils.animations.Direction;
import eva.pasta.utils.animations.easing.CompactAnimation;
import eva.pasta.utils.animations.easing.Easing;
import eva.pasta.utils.animations.impl.EaseBackIn;
import eva.pasta.manager.drag.Dragging;
import eva.pasta.utils.math.MathUtility;
import eva.pasta.utils.render.color.ColorUtility;
import eva.pasta.utils.render.engine2d.RenderUtility;
import eva.pasta.utils.text.font.ClientFonts;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.gui.screen.ChatScreen;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.ResourceLocation;
import java.util.Iterator;
@FieldDefaults(level = AccessLevel.PRIVATE)
@RequiredArgsConstructor
public class ArmorHud implements ElementRenderer {
    private static final ResourceLocation TOTEM_TEXTURE = new ResourceLocation("minecraft", "textures/item/totem_of_undying.png");
    final Dragging dragging;
    private final CompactAnimation widthAnimation = new CompactAnimation(Easing.EASE_OUT_QUART, 100);
    private final CompactAnimation heightAnimation = new CompactAnimation(Easing.EASE_OUT_QUART, 100);
    double width;
    float height;
    final AnimationUtility animation = new EaseBackIn(300, 1, 1);
    float armorAnimation;
    float totemAnimation;
    @Override
    public void render(EventRender2D eventRender2D) {
        MatrixStack ms = eventRender2D.getMatrixStack();
        float posX = dragging.getX();
        float posY = dragging.getY();
        float padding = 5;
        boolean shouldShow = shouldShowHud();
        animation.setDirection(shouldShow ? Direction.FORWARDS : Direction.BACKWARDS);
        animation.setDuration(shouldShow ? 300 : 200);
        armorAnimation = MathUtility.lerp(armorAnimation,
                mc.currentScreen instanceof ChatScreen ? window.getScaledHeight() - 33 : window.getScaledHeight() - (16 + 2), 15);
        GlStateManager.pushMatrix();
        RenderUtility.sizeAnimation(posX + (width / 2), (posY + height / 2), animation.getOutput());
        int armorCount = 0;
        for (ItemStack itemStack : mc.player.getArmorInventoryList()) {
            if (!itemStack.isEmpty()) armorCount++;
        }
        int totemCount = countItems(Items.TOTEM_OF_UNDYING) + countItemsInOffhand(Items.TOTEM_OF_UNDYING);
        boolean hasTotems = totemCount > 0;
        float itemSize = 16;
        float spacing = 2;
        float calculatedWidth = (armorCount * (itemSize + spacing)) + (hasTotems ? (itemSize + spacing) : 0);
        float calculatedHeight = itemSize;
        widthAnimation.run(calculatedWidth + padding * 2);
        width = widthAnimation.getValue();
        heightAnimation.run(calculatedHeight + padding * 2);
        height = (float) heightAnimation.getValue();
        // отрисовка фона ф
        RenderUtility.drawRoundedRect(posX, posY, (float) width, height, 4.0f,
                ColorUtility.rgba(25, 25, 35, 220));
        // отрисовка брони
        float startX = posX + padding;
        float startY = posY + padding;
        for (ItemStack itemStack : mc.player.getArmorInventoryList()) {
            if (itemStack.isEmpty()) continue;
            mc.getItemRenderer().renderItemAndEffectIntoGUI(itemStack, (int) startX, (int) startY);
            mc.getItemRenderer().renderItemOverlayIntoGUI(mc.fontRenderer, itemStack, (int) startX, (int) startY, null);
            startX += itemSize + spacing;
        }
        // отрисовк тотема
        if (hasTotems) {
            // анимка тотема
            totemAnimation = MathUtility.lerp(totemAnimation, 1.0f, 15);
            float size = 14;
            String text = totemCount > 99 ? "99+" : String.valueOf(totemCount);
            mc.getTextureManager().bindTexture(TOTEM_TEXTURE);
            AbstractGui.blit(ms, startX, startY + 1, 0.0F, 0.0F, size, size, size, size);
            ClientFonts.tenacityBold[16].drawCenteredStringWithOutline(ms, text,
                    startX + size / 2f, startY + size - 1, -1);
        }
        GlStateManager.popMatrix();
        dragging.setWidth((float) width);
        dragging.setHeight(height);
    }
    private boolean shouldShowHud() {
        if (mc.currentScreen instanceof ChatScreen) return true;
        for (ItemStack itemStack : mc.player.getArmorInventoryList()) {
            if (!itemStack.isEmpty()) return true;
        }
        return (countItems(Items.TOTEM_OF_UNDYING) + countItemsInOffhand(Items.TOTEM_OF_UNDYING)) > 0;
    }
    private int countItems(Item item) {
        int count = 0;
        Iterator<ItemStack> iterator = mc.player.inventory.mainInventory.iterator();
        while(iterator.hasNext()) {
            ItemStack itemStack = iterator.next();
            if (itemStack.getItem() == item) {
                count += itemStack.getCount();
            }
        }
        return count;
    }
    private int countItemsInOffhand(Item item) {
        ItemStack offhand = mc.player.getHeldItemOffhand();
        return offhand.getItem() == item ? offhand.getCount() : 0;
    }
} 
				 
	 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		 
 
		