package im.negr.display.display.impl;
import com.mojang.blaze3d.matrix.MatrixStack;
import im.negr.Negr;
import im.negr.client.events.EventDisplay;
import im.negr.client.events.EventUpdate;
import im.negr.display.display.ElementRenderer;
import im.negr.display.styles.Style;
import im.negr.system.drag.Dragging;
import im.negr.system.math.MathUtil;
import im.negr.system.render.*;
import im.negr.system.render.font.Fonts;
import im.negr.system.text.GradientUtil;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.EffectUtils;
import net.minecraft.util.text.ITextComponent;
import java.util.Iterator;
@FieldDefaults(level = AccessLevel.PRIVATE)
@RequiredArgsConstructor
public class PotionRenderer implements ElementRenderer {
private final Dragging dragging;
private float width;
private float height;
private float animation;
[USER=1367676]@override[/USER]
public void update(EventUpdate e) {
}
public void render(EventDisplay eventDisplay) {
MatrixStack ms = eventDisplay.getMatrixStack();
float posX = this.dragging.getX();
float posY = this.dragging.getY();
float fontSize = 6.5F;
float padding = 5.0F;
float textPosX = posX + 7.5F;
float textPosY = posY + 9.5F;
ITextComponent name = GradientUtil.gradient("Active potions");
Style style = Negr.getInstance().getStyleManager().getCurrentStyle();
DisplayUtils.drawShadow(posX - 1, posY + 1, this.animation - 15, this.height - 4, 10, (ColorUtils.setAlpha(ColorUtils.getColor(10), 185)));
DisplayUtils.drawShadow(posX + 65, posY + 1, this.animation - 65, this.height - 4, 10, (ColorUtils.setAlpha(ColorUtils.getColor(10), 185)));
{
//DisplayUtils.drawShadow(posX , posY + 1,this.animation, -4, 10, (ColorUtils.setAlpha(ColorUtils.getColor(10), 185)));
DisplayUtils.drawRoundedRect(posX, dragging.getY() + 1.0F, this.animation - 15, 15.5F, 3.0F, ColorUtils.rgba(10, 15, 13, 195));
DisplayUtils.drawRoundedRect(posX + this.animation - 15, dragging.getY() + 1.0F, 15, 15.5F, 3.0F, ColorUtils.rgba(10, 15, 13, 195));
};
Fonts.sfui.drawText(ms, "Potions", posX + 5.0F, posY + 5.0F + 0.5F, ColorUtils.rgb(255, 255, 255), 7.0F);
Fonts.icons2.drawText(ms, "E", textPosX - 20.0F + this.animation, textPosY - 4.2F, style.getSecondColor().getRGB(), 9.0F);
posY += 16.5F;
float maxWidth = Fonts.sfui.getWidth(name, 6.5F) + 10.0F;
float localHeight = 16.5F;
posY += 0.4F;
Minecraft var10000 = mc;
for(Iterator var14 = Minecraft.player.getActivePotionEffects().iterator(); var14.hasNext(); localHeight += 11.5F) {
EffectInstance ef = (EffectInstance)var14.next();
int amp = ef.getAmplifier();
String ampStr = "";
String var24;
if (amp >= 1 && amp <= 9) {
var24 = "enchantment.level." + (amp + 1);
ampStr = " " + I18n.format(var24, new Object[0]);
}
var24 = I18n.format(ef.getEffectName(), new Object[0]);
String nameText = var24 + ampStr;
float nameWidth = Fonts.sfui.getWidth(nameText, 6.5F);
String bindText = EffectUtils.getPotionDurationString(ef, 1.0F);
float bindWidth = Fonts.sfui.getWidth(bindText, 6.5F);
float localWidth = nameWidth + bindWidth + 15.0F;
DisplayUtils.drawRoundedRect(posX, posY, this.animation, 11.0F, 2.5F, ColorUtils.rgba(17, 17, 17, 215));
Fonts.sfui.drawText(ms, nameText, posX + 3.4F, posY + 2.5F, ColorUtils.rgba(255, 255, 255, 255), 6.5F);
Fonts.sfui.drawText(ms, bindText, posX + this.animation - 4.0F - bindWidth, posY + 2.5F, ColorUtils.rgba(255, 255, 255, 255), 6.5F);
DisplayUtils.drawRectVerticalW((double)(posX + 58.0F), (double)(posY + 2.8F), (double)(this.width - 1.0F), 5.099999904632568, 3, ColorUtils.rgba(255, 255, 255, 52));
if (localWidth > maxWidth) {
maxWidth = localWidth;
}
posY += 11.3F;
}
this.animation = MathUtil.lerp(this.animation, Math.max(maxWidth, 80.0F), 10.0F);
this.height = localHeight + 2.5F;
this.dragging.setWidth(this.animation);
this.dragging.setHeight(this.height);
}
private void drawStyledRect(float x, float y, float width, float height, float radius) {
DisplayUtils.drawRoundedRect(x, y, width, height, radius, ColorUtils.rgba(17, 17, 17, 195));
}
}