package net.minecraft.client.gui;

import java.util.UUID;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.world.level.border.WorldBorder;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.Tesselator;
import net.minecraft.world.food.FoodData;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.tags.Tag;
import net.minecraft.tags.FluidTags;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.Util;
import net.minecraft.world.entity.Entity;
import com.mojang.datafixers.util.Pair;
import net.minecraft.world.scores.Team;
import com.google.common.collect.Iterables;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import net.minecraft.world.scores.Score;
import net.minecraft.util.StringUtil;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.entity.HumanoidArm;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.world.effect.MobEffect;
import java.util.Iterator;
import net.minecraft.client.resources.MobEffectTextureManager;
import java.util.Collection;
import net.minecraft.world.effect.MobEffectInstance;
import com.google.common.collect.Ordering;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.world.level.Level;
import net.minecraft.core.BlockPos;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.EntityHitResult;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.phys.HitResult;
import net.minecraft.client.Camera;
import net.minecraft.client.Options;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.client.AttackIndicatorStatus;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.util.FastColor;
import net.minecraft.world.scores.PlayerTeam;
import net.minecraft.world.scores.Objective;
import net.minecraft.world.scores.Scoreboard;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.world.level.GameType;
import net.minecraft.util.Mth;
import net.minecraft.world.effect.MobEffects;
import net.minecraft.world.level.block.Blocks;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.chat.OverlayChatListener;
import net.minecraft.client.gui.chat.StandardChatListener;
import net.minecraft.client.gui.chat.NarratorChatListener;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.minecraft.client.gui.chat.ChatListener;
import java.util.List;
import net.minecraft.network.chat.ChatType;
import java.util.Map;
import net.minecraft.client.gui.components.BossHealthOverlay;
import net.minecraft.client.gui.components.PlayerTabOverlay;
import net.minecraft.client.gui.components.spectator.SpectatorGui;
import net.minecraft.client.gui.components.SubtitleOverlay;
import net.minecraft.client.gui.components.DebugScreenOverlay;
import net.minecraft.world.item.ItemStack;
import javax.annotation.Nullable;
import net.minecraft.network.chat.Component;
import net.minecraft.client.gui.components.ChatComponent;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.client.Minecraft;
import java.util.Random;
import net.minecraft.resources.ResourceLocation;

public class Gui extends GuiComponent {
    private static final ResourceLocation VIGNETTE_LOCATION;
    private static final ResourceLocation WIDGETS_LOCATION;
    private static final ResourceLocation PUMPKIN_BLUR_LOCATION;
    private final Random random;
    private final Minecraft minecraft;
    private final ItemRenderer itemRenderer;
    private final ChatComponent chat;
    private int tickCount;
    @Nullable
    private Component overlayMessageString;
    private int overlayMessageTime;
    private boolean animateOverlayMessageColor;
    public float vignetteBrightness;
    private int toolHighlightTimer;
    private ItemStack lastToolHighlight;
    private final DebugScreenOverlay debugScreen;
    private final SubtitleOverlay subtitleOverlay;
    private final SpectatorGui spectatorGui;
    private final PlayerTabOverlay tabList;
    private final BossHealthOverlay bossOverlay;
    private int titleTime;
    @Nullable
    private Component title;
    @Nullable
    private Component subtitle;
    private int titleFadeInTime;
    private int titleStayTime;
    private int titleFadeOutTime;
    private int lastHealth;
    private int displayHealth;
    private long lastHealthTime;
    private long healthBlinkTime;
    private int screenWidth;
    private int screenHeight;
    private final Map<ChatType, List<ChatListener>> chatListeners;
    
    public Gui(final Minecraft dlx) {
        this.random = new Random();
        this.vignetteBrightness = 1.0f;
        this.lastToolHighlight = ItemStack.EMPTY;
        this.chatListeners = Maps.newHashMap();
        this.minecraft = dlx;
        this.itemRenderer = dlx.getItemRenderer();
        this.debugScreen = new DebugScreenOverlay(dlx);
        this.spectatorGui = new SpectatorGui(dlx);
        this.chat = new ChatComponent(dlx);
        this.tabList = new PlayerTabOverlay(dlx, this);
        this.bossOverlay = new BossHealthOverlay(dlx);
        this.subtitleOverlay = new SubtitleOverlay(dlx);
        for (final ChatType mo6 : ChatType.values()) {
            this.chatListeners.put(mo6, Lists.newArrayList());
        }
        final ChatListener dmx3 = NarratorChatListener.INSTANCE;
        this.chatListeners.get(ChatType.CHAT).add(new StandardChatListener(dlx));
        this.chatListeners.get(ChatType.CHAT).add(dmx3);
        this.chatListeners.get(ChatType.SYSTEM).add(new StandardChatListener(dlx));
        this.chatListeners.get(ChatType.SYSTEM).add(dmx3);
        this.chatListeners.get(ChatType.GAME_INFO).add(new OverlayChatListener(dlx));
        this.resetTitleTimes();
    }
    
    public void resetTitleTimes() {
        this.titleFadeInTime = 10;
        this.titleStayTime = 70;
        this.titleFadeOutTime = 20;
    }
    
    public void render(final PoseStack dhl, final float float2) {
        this.screenWidth = this.minecraft.getWindow().getGuiScaledWidth();
        this.screenHeight = this.minecraft.getWindow().getGuiScaledHeight();
        final Font dmt4 = this.getFont();
        RenderSystem.enableBlend();
        if (Minecraft.useFancyGraphics()) {
            this.renderVignette(this.minecraft.getCameraEntity());
        }
        else {
            RenderSystem.enableDepthTest();
            RenderSystem.defaultBlendFunc();
        }
        final ItemStack bki5 = this.minecraft.player.inventory.getArmor(3);
        if (this.minecraft.options.thirdPersonView == 0 && bki5.getItem() == Blocks.CARVED_PUMPKIN.asItem()) {
            this.renderPumpkin();
        }
        if (!this.minecraft.player.hasEffect(MobEffects.CONFUSION)) {
            final float float3 = Mth.lerp(float2, this.minecraft.player.oPortalTime, this.minecraft.player.portalTime);
            if (float3 > 0.0f) {
                this.renderPortalOverlay(float3);
            }
        }
        if (this.minecraft.gameMode.getPlayerMode() == GameType.SPECTATOR) {
            this.spectatorGui.renderHotbar(dhl, float2);
        }
        else if (!this.minecraft.options.hideGui) {
            this.renderHotbar(float2, dhl);
        }
        if (!this.minecraft.options.hideGui) {
            RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
            this.minecraft.getTextureManager().bind(Gui.GUI_ICONS_LOCATION);
            RenderSystem.enableBlend();
            RenderSystem.enableAlphaTest();
            this.renderCrosshair(dhl);
            RenderSystem.defaultBlendFunc();
            this.minecraft.getProfiler().push("bossHealth");
            this.bossOverlay.render(dhl);
            this.minecraft.getProfiler().pop();
            RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
            this.minecraft.getTextureManager().bind(Gui.GUI_ICONS_LOCATION);
            if (this.minecraft.gameMode.canHurtPlayer()) {
                this.renderPlayerHealth(dhl);
            }
            this.renderVehicleHealth(dhl);
            RenderSystem.disableBlend();
            final int integer6 = this.screenWidth / 2 - 91;
            if (this.minecraft.player.isRidingJumpable()) {
                this.renderJumpMeter(dhl, integer6);
            }
            else if (this.minecraft.gameMode.hasExperience()) {
                this.renderExperienceBar(dhl, integer6);
            }
            if (this.minecraft.options.heldItemTooltips && this.minecraft.gameMode.getPlayerMode() != GameType.SPECTATOR) {
                this.renderSelectedItemName(dhl);
            }
            else if (this.minecraft.player.isSpectator()) {
                this.spectatorGui.renderTooltip(dhl);
            }
        }
        if (this.minecraft.player.getSleepTimer() > 0) {
            this.minecraft.getProfiler().push("sleep");
            RenderSystem.disableDepthTest();
            RenderSystem.disableAlphaTest();
            final float float3 = (float)this.minecraft.player.getSleepTimer();
            float float4 = float3 / 100.0f;
            if (float4 > 1.0f) {
                float4 = 1.0f - (float3 - 100.0f) / 10.0f;
            }
            final int integer7 = (int)(220.0f * float4) << 24 | 0x101020;
            GuiComponent.fill(dhl, 0, 0, this.screenWidth, this.screenHeight, integer7);
            RenderSystem.enableAlphaTest();
            RenderSystem.enableDepthTest();
            this.minecraft.getProfiler().pop();
            RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
        }
        if (this.minecraft.isDemo()) {
            this.renderDemoOverlay(dhl);
        }
        this.renderEffects(dhl);
        if (this.minecraft.options.renderDebug) {
            this.debugScreen.render(dhl);
        }
        if (!this.minecraft.options.hideGui) {
            if (this.overlayMessageString != null && this.overlayMessageTime > 0) {
                this.minecraft.getProfiler().push("overlayMessage");
                final float float3 = this.overlayMessageTime - float2;
                int integer8 = (int)(float3 * 255.0f / 20.0f);
                if (integer8 > 255) {
                    integer8 = 255;
                }
                if (integer8 > 8) {
                    RenderSystem.pushMatrix();
                    RenderSystem.translatef((float)(this.screenWidth / 2), (float)(this.screenHeight - 68), 0.0f);
                    RenderSystem.enableBlend();
                    RenderSystem.defaultBlendFunc();
                    int integer7 = 16777215;
                    if (this.animateOverlayMessageColor) {
                        integer7 = (Mth.hsvToRgb(float3 / 50.0f, 0.7f, 0.6f) & 0xFFFFFF);
                    }
                    final int integer9 = integer8 << 24 & 0xFF000000;
                    final int integer10 = dmt4.width(this.overlayMessageString);
                    this.drawBackdrop(dhl, dmt4, -4, integer10, 0xFFFFFF | integer9);
                    dmt4.draw(dhl, this.overlayMessageString, (float)(-integer10 / 2), -4.0f, integer7 | integer9);
                    RenderSystem.disableBlend();
                    RenderSystem.popMatrix();
                }
                this.minecraft.getProfiler().pop();
            }
            if (this.title != null && this.titleTime > 0) {
                this.minecraft.getProfiler().push("titleAndSubtitle");
                final float float3 = this.titleTime - float2;
                int integer8 = 255;
                if (this.titleTime > this.titleFadeOutTime + this.titleStayTime) {
                    final float float5 = this.titleFadeInTime + this.titleStayTime + this.titleFadeOutTime - float3;
                    integer8 = (int)(float5 * 255.0f / this.titleFadeInTime);
                }
                if (this.titleTime <= this.titleFadeOutTime) {
                    integer8 = (int)(float3 * 255.0f / this.titleFadeOutTime);
                }
                integer8 = Mth.clamp(integer8, 0, 255);
                if (integer8 > 8) {
                    RenderSystem.pushMatrix();
                    RenderSystem.translatef((float)(this.screenWidth / 2), (float)(this.screenHeight / 2), 0.0f);
                    RenderSystem.enableBlend();
                    RenderSystem.defaultBlendFunc();
                    RenderSystem.pushMatrix();
                    RenderSystem.scalef(4.0f, 4.0f, 4.0f);
                    final int integer7 = integer8 << 24 & 0xFF000000;
                    final int integer9 = dmt4.width(this.title);
                    this.drawBackdrop(dhl, dmt4, -10, integer9, 0xFFFFFF | integer7);
                    dmt4.drawShadow(dhl, this.title, (float)(-integer9 / 2), -10.0f, 0xFFFFFF | integer7);
                    RenderSystem.popMatrix();
                    if (this.subtitle != null) {
                        RenderSystem.pushMatrix();
                        RenderSystem.scalef(2.0f, 2.0f, 2.0f);
                        final int integer10 = dmt4.width(this.subtitle);
                        this.drawBackdrop(dhl, dmt4, 5, integer10, 0xFFFFFF | integer7);
                        dmt4.drawShadow(dhl, this.subtitle, (float)(-integer10 / 2), 5.0f, 0xFFFFFF | integer7);
                        RenderSystem.popMatrix();
                    }
                    RenderSystem.disableBlend();
                    RenderSystem.popMatrix();
                }
                this.minecraft.getProfiler().pop();
            }
            this.subtitleOverlay.render(dhl);
            final Scoreboard dfm6 = this.minecraft.level.getScoreboard();
            Objective dfj7 = null;
            final PlayerTeam dfk8 = dfm6.getPlayersTeam(this.minecraft.player.getScoreboardName());
            if (dfk8 != null) {
                final int integer9 = dfk8.getColor().getId();
                if (integer9 >= 0) {
                    dfj7 = dfm6.getDisplayObjective(3 + integer9);
                }
            }
            Objective dfj8 = (dfj7 != null) ? dfj7 : dfm6.getDisplayObjective(1);
            if (dfj8 != null) {
                this.displayScoreboardSidebar(dhl, dfj8);
            }
            RenderSystem.enableBlend();
            RenderSystem.defaultBlendFunc();
            RenderSystem.disableAlphaTest();
            RenderSystem.pushMatrix();
            RenderSystem.translatef(0.0f, (float)(this.screenHeight - 48), 0.0f);
            this.minecraft.getProfiler().push("chat");
            this.chat.render(dhl, this.tickCount);
            this.minecraft.getProfiler().pop();
            RenderSystem.popMatrix();
            dfj8 = dfm6.getDisplayObjective(0);
            if (this.minecraft.options.keyPlayerList.isDown() && (!this.minecraft.isLocalServer() || this.minecraft.player.connection.getOnlinePlayers().size() > 1 || dfj8 != null)) {
                this.tabList.setVisible(true);
                this.tabList.render(dhl, this.screenWidth, dfm6, dfj8);
            }
            else {
                this.tabList.setVisible(false);
            }
        }
        RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
        RenderSystem.enableAlphaTest();
    }
    
    private void drawBackdrop(final PoseStack dhl, final Font dmt, final int integer3, final int integer4, final int integer5) {
        final int integer6 = this.minecraft.options.getBackgroundColor(0.0f);
        if (integer6 != 0) {
            final int integer7 = -integer4 / 2;
            final int integer8 = integer7 - 2;
            final int integer9 = integer3 - 2;
            final int integer10 = integer7 + integer4 + 2;
            dmt.getClass();
            GuiComponent.fill(dhl, integer8, integer9, integer10, integer3 + 9 + 2, FastColor.ARGB32.multiply(integer6, integer5));
        }
    }
    
    private void renderCrosshair(final PoseStack dhl) {
        final Options dmb3 = this.minecraft.options;
        if (dmb3.thirdPersonView != 0) {
            return;
        }
        if (this.minecraft.gameMode.getPlayerMode() == GameType.SPECTATOR && !this.canRenderCrosshairForSpectator(this.minecraft.hitResult)) {
            return;
        }
        if (dmb3.renderDebug && !dmb3.hideGui && !this.minecraft.player.isReducedDebugInfo() && !dmb3.reducedDebugInfo) {
            RenderSystem.pushMatrix();
            RenderSystem.translatef((float)(this.screenWidth / 2), (float)(this.screenHeight / 2), (float)this.getBlitOffset());
            final Camera dlj4 = this.minecraft.gameRenderer.getMainCamera();
            RenderSystem.rotatef(dlj4.getXRot(), -1.0f, 0.0f, 0.0f);
            RenderSystem.rotatef(dlj4.getYRot(), 0.0f, 1.0f, 0.0f);
            RenderSystem.scalef(-1.0f, -1.0f, -1.0f);
            RenderSystem.renderCrosshair(10);
            RenderSystem.popMatrix();
        }
        else {
            RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.ONE_MINUS_DST_COLOR, GlStateManager.DestFactor.ONE_MINUS_SRC_COLOR, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
            final int integer4 = 15;
            this.blit(dhl, (this.screenWidth - 15) / 2, (this.screenHeight - 15) / 2, 0, 0, 15, 15);
            if (this.minecraft.options.attackIndicator == AttackIndicatorStatus.CROSSHAIR) {
                final float float5 = this.minecraft.player.getAttackStrengthScale(0.0f);
                boolean boolean6 = false;
                if (this.minecraft.crosshairPickEntity != null && this.minecraft.crosshairPickEntity instanceof LivingEntity && float5 >= 1.0f) {
                    boolean6 = (this.minecraft.player.getCurrentItemAttackStrengthDelay() > 5.0f);
                    boolean6 &= this.minecraft.crosshairPickEntity.isAlive();
                }
                final int integer5 = this.screenHeight / 2 - 7 + 16;
                final int integer6 = this.screenWidth / 2 - 8;
                if (boolean6) {
                    this.blit(dhl, integer6, integer5, 68, 94, 16, 16);
                }
                else if (float5 < 1.0f) {
                    final int integer7 = (int)(float5 * 17.0f);
                    this.blit(dhl, integer6, integer5, 36, 94, 16, 4);
                    this.blit(dhl, integer6, integer5, 52, 94, integer7, 4);
                }
            }
        }
    }
    
    private boolean canRenderCrosshairForSpectator(final HitResult dej) {
        if (dej == null) {
            return false;
        }
        if (dej.getType() == HitResult.Type.ENTITY) {
            return ((EntityHitResult)dej).getEntity() instanceof MenuProvider;
        }
        if (dej.getType() == HitResult.Type.BLOCK) {
            final BlockPos fu3 = ((BlockHitResult)dej).getBlockPos();
            final Level bqb4 = this.minecraft.level;
            return bqb4.getBlockState(fu3).getMenuProvider(bqb4, fu3) != null;
        }
        return false;
    }
    
    protected void renderEffects(final PoseStack dhl) {
        final Collection<MobEffectInstance> collection3 = this.minecraft.player.getActiveEffects();
        if (collection3.isEmpty()) {
            return;
        }
        RenderSystem.enableBlend();
        int integer4 = 0;
        int integer5 = 0;
        final MobEffectTextureManager emi6 = this.minecraft.getMobEffectTextures();
        final List<Runnable> list7 = Lists.newArrayListWithExpectedSize(collection3.size());
        this.minecraft.getTextureManager().bind(AbstractContainerScreen.INVENTORY_LOCATION);
        for (final MobEffectInstance aog9 : Ordering.<Comparable>natural().reverse().<MobEffectInstance>sortedCopy(collection3)) {
            final MobEffect aoe10 = aog9.getEffect();
            if (aog9.showIcon()) {
                int integer6 = this.screenWidth;
                int integer7 = 1;
                if (this.minecraft.isDemo()) {
                    integer7 += 15;
                }
                if (aoe10.isBeneficial()) {
                    ++integer4;
                    integer6 -= 25 * integer4;
                }
                else {
                    ++integer5;
                    integer6 -= 25 * integer5;
                    integer7 += 26;
                }
                RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
                float float13 = 1.0f;
                if (aog9.isAmbient()) {
                    this.blit(dhl, integer6, integer7, 165, 166, 24, 24);
                }
                else {
                    this.blit(dhl, integer6, integer7, 141, 166, 24, 24);
                    if (aog9.getDuration() <= 200) {
                        final int integer8 = 10 - aog9.getDuration() / 20;
                        float13 = Mth.clamp(aog9.getDuration() / 10.0f / 5.0f * 0.5f, 0.0f, 0.5f) + Mth.cos(aog9.getDuration() * 3.1415927f / 5.0f) * Mth.clamp(integer8 / 10.0f * 0.25f, 0.0f, 0.25f);
                    }
                }
                final TextureAtlasSprite elv14 = emi6.get(aoe10);
                final int integer9 = integer6;
                final int integer10 = integer7;
                final float float14 = float13;
                final TextureAtlasSprite elv15;
                final float float15;
                final int n;
                final int n2;
                list7.add(() -> {
                    this.minecraft.getTextureManager().bind(elv15.atlas().location());
                    RenderSystem.color4f(1.0f, 1.0f, 1.0f, float15);
                    GuiComponent.blit(dhl, n + 3, n2 + 3, this.getBlitOffset(), 18, 18, elv15);
                    return;
                });
            }
        }
        list7.forEach(Runnable::run);
    }
    
    protected void renderHotbar(final float float1, final PoseStack dhl) {
        final Player bec4 = this.getCameraPlayer();
        if (bec4 == null) {
            return;
        }
        RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
        this.minecraft.getTextureManager().bind(Gui.WIDGETS_LOCATION);
        final ItemStack bki5 = bec4.getOffhandItem();
        final HumanoidArm aou6 = bec4.getMainArm().getOpposite();
        final int integer7 = this.screenWidth / 2;
        final int integer8 = this.getBlitOffset();
        final int integer9 = 182;
        final int integer10 = 91;
        this.setBlitOffset(-90);
        this.blit(dhl, integer7 - 91, this.screenHeight - 22, 0, 0, 182, 22);
        this.blit(dhl, integer7 - 91 - 1 + bec4.inventory.selected * 20, this.screenHeight - 22 - 1, 0, 22, 24, 22);
        if (!bki5.isEmpty()) {
            if (aou6 == HumanoidArm.LEFT) {
                this.blit(dhl, integer7 - 91 - 29, this.screenHeight - 23, 24, 22, 29, 24);
            }
            else {
                this.blit(dhl, integer7 + 91, this.screenHeight - 23, 53, 22, 29, 24);
            }
        }
        this.setBlitOffset(integer8);
        RenderSystem.enableRescaleNormal();
        RenderSystem.enableBlend();
        RenderSystem.defaultBlendFunc();
        for (int integer11 = 0; integer11 < 9; ++integer11) {
            final int integer12 = integer7 - 90 + integer11 * 20 + 2;
            final int integer13 = this.screenHeight - 16 - 3;
            this.renderSlot(integer12, integer13, float1, bec4, bec4.inventory.items.get(integer11));
        }
        if (!bki5.isEmpty()) {
            final int integer11 = this.screenHeight - 16 - 3;
            if (aou6 == HumanoidArm.LEFT) {
                this.renderSlot(integer7 - 91 - 26, integer11, float1, bec4, bki5);
            }
            else {
                this.renderSlot(integer7 + 91 + 10, integer11, float1, bec4, bki5);
            }
        }
        if (this.minecraft.options.attackIndicator == AttackIndicatorStatus.HOTBAR) {
            final float float2 = this.minecraft.player.getAttackStrengthScale(0.0f);
            if (float2 < 1.0f) {
                final int integer12 = this.screenHeight - 20;
                int integer13 = integer7 + 91 + 6;
                if (aou6 == HumanoidArm.RIGHT) {
                    integer13 = integer7 - 91 - 22;
                }
                this.minecraft.getTextureManager().bind(GuiComponent.GUI_ICONS_LOCATION);
                final int integer14 = (int)(float2 * 19.0f);
                RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
                this.blit(dhl, integer13, integer12, 0, 94, 18, 18);
                this.blit(dhl, integer13, integer12 + 18 - integer14, 18, 112 - integer14, 18, integer14);
            }
        }
        RenderSystem.disableRescaleNormal();
        RenderSystem.disableBlend();
    }
    
    public void renderJumpMeter(final PoseStack dhl, final int integer) {
        this.minecraft.getProfiler().push("jumpBar");
        this.minecraft.getTextureManager().bind(GuiComponent.GUI_ICONS_LOCATION);
        final float float4 = this.minecraft.player.getJumpRidingScale();
        final int integer2 = 182;
        final int integer3 = (int)(float4 * 183.0f);
        final int integer4 = this.screenHeight - 32 + 3;
        this.blit(dhl, integer, integer4, 0, 84, 182, 5);
        if (integer3 > 0) {
            this.blit(dhl, integer, integer4, 0, 89, integer3, 5);
        }
        this.minecraft.getProfiler().pop();
    }
    
    public void renderExperienceBar(final PoseStack dhl, final int integer) {
        this.minecraft.getProfiler().push("expBar");
        this.minecraft.getTextureManager().bind(GuiComponent.GUI_ICONS_LOCATION);
        final int integer2 = this.minecraft.player.getXpNeededForNextLevel();
        if (integer2 > 0) {
            final int integer3 = 182;
            final int integer4 = (int)(this.minecraft.player.experienceProgress * 183.0f);
            final int integer5 = this.screenHeight - 32 + 3;
            this.blit(dhl, integer, integer5, 0, 64, 182, 5);
            if (integer4 > 0) {
                this.blit(dhl, integer, integer5, 0, 69, integer4, 5);
            }
        }
        this.minecraft.getProfiler().pop();
        if (this.minecraft.player.experienceLevel > 0) {
            this.minecraft.getProfiler().push("expLevel");
            final String string5 = "" + this.minecraft.player.experienceLevel;
            final int integer4 = (this.screenWidth - this.getFont().width(string5)) / 2;
            final int integer5 = this.screenHeight - 31 - 4;
            this.getFont().draw(dhl, string5, (float)(integer4 + 1), (float)integer5, 0);
            this.getFont().draw(dhl, string5, (float)(integer4 - 1), (float)integer5, 0);
            this.getFont().draw(dhl, string5, (float)integer4, (float)(integer5 + 1), 0);
            this.getFont().draw(dhl, string5, (float)integer4, (float)(integer5 - 1), 0);
            this.getFont().draw(dhl, string5, (float)integer4, (float)integer5, 8453920);
            this.minecraft.getProfiler().pop();
        }
    }
    
    public void renderSelectedItemName(final PoseStack dhl) {
        this.minecraft.getProfiler().push("selectedItemName");
        if (this.toolHighlightTimer > 0 && !this.lastToolHighlight.isEmpty()) {
            final MutableComponent mx3 = new TextComponent("").append(this.lastToolHighlight.getHoverName()).withStyle(this.lastToolHighlight.getRarity().color);
            if (this.lastToolHighlight.hasCustomHoverName()) {
                mx3.withStyle(ChatFormatting.ITALIC);
            }
            final int integer4 = this.getFont().width(mx3);
            final int integer5 = (this.screenWidth - integer4) / 2;
            int integer6 = this.screenHeight - 59;
            if (!this.minecraft.gameMode.canHurtPlayer()) {
                integer6 += 14;
            }
            int integer7 = (int)(this.toolHighlightTimer * 256.0f / 10.0f);
            if (integer7 > 255) {
                integer7 = 255;
            }
            if (integer7 > 0) {
                RenderSystem.pushMatrix();
                RenderSystem.enableBlend();
                RenderSystem.defaultBlendFunc();
                final int integer8 = integer5 - 2;
                final int integer9 = integer6 - 2;
                final int integer10 = integer5 + integer4 + 2;
                final int n = integer6;
                this.getFont().getClass();
                GuiComponent.fill(dhl, integer8, integer9, integer10, n + 9 + 2, this.minecraft.options.getBackgroundColor(0));
                this.getFont().drawShadow(dhl, mx3, (float)integer5, (float)integer6, 16777215 + (integer7 << 24));
                RenderSystem.disableBlend();
                RenderSystem.popMatrix();
            }
        }
        this.minecraft.getProfiler().pop();
    }
    
    public void renderDemoOverlay(final PoseStack dhl) {
        this.minecraft.getProfiler().push("demo");
        String string3;
        if (this.minecraft.level.getGameTime() >= 120500L) {
            string3 = I18n.get("demo.demoExpired");
        }
        else {
            string3 = I18n.get("demo.remainingTime", StringUtil.formatTickDuration((int)(120500L - this.minecraft.level.getGameTime())));
        }
        final int integer4 = this.getFont().width(string3);
        this.getFont().drawShadow(dhl, string3, (float)(this.screenWidth - integer4 - 10), 5.0f, 16777215);
        this.minecraft.getProfiler().pop();
    }
    
    private void displayScoreboardSidebar(final PoseStack dhl, final Objective dfj) {
        final Scoreboard dfm4 = dfj.getScoreboard();
        Collection<Score> collection5 = dfm4.getPlayerScores(dfj);
        final List<Score> list6 = collection5.stream().filter(dfl -> dfl.getOwner() != null && !dfl.getOwner().startsWith("#")).collect(Collectors.toList());
        if (list6.size() > 15) {
            collection5 = Lists.newArrayList(Iterables.skip(list6, collection5.size() - 15));
        }
        else {
            collection5 = list6;
        }
        final List<Pair<Score, Component>> list7 = Lists.newArrayListWithCapacity(collection5.size());
        final Component mr8 = dfj.getDisplayName();
        int integer10;
        final int integer9 = integer10 = this.getFont().width(mr8);
        final int integer11 = this.getFont().width(": ");
        for (final Score dfl2 : collection5) {
            final PlayerTeam dfk14 = dfm4.getPlayersTeam(dfl2.getOwner());
            final Component mr9 = PlayerTeam.formatNameForTeam(dfk14, new TextComponent(dfl2.getOwner()));
            list7.add((Pair<Score, Component>)Pair.of(dfl2, mr9));
            integer10 = Math.max(integer10, this.getFont().width(mr9) + integer11 + this.getFont().width(Integer.toString(dfl2.getScore())));
        }
        final int size = collection5.size();
        this.getFont().getClass();
        final int integer12 = size * 9;
        final int integer13 = this.screenHeight / 2 + integer12 / 3;
        final int integer14 = 3;
        final int integer15 = this.screenWidth - integer10 - 3;
        int integer16 = 0;
        final int integer17 = this.minecraft.options.getBackgroundColor(0.3f);
        final int integer18 = this.minecraft.options.getBackgroundColor(0.4f);
        for (final Pair<Score, Component> pair20 : list7) {
            ++integer16;
            final Score dfl3 = (Score)pair20.getFirst();
            final Component mr10 = (Component)pair20.getSecond();
            final String string23 = ChatFormatting.RED + "" + dfl3.getScore();
            final int integer19 = integer15;
            final int n = integer13;
            final int n2 = integer16;
            this.getFont().getClass();
            final int integer20 = n - n2 * 9;
            final int integer21 = this.screenWidth - 3 + 2;
            final int integer22 = integer19 - 2;
            final int integer23 = integer20;
            final int integer24 = integer21;
            final int n3 = integer20;
            this.getFont().getClass();
            GuiComponent.fill(dhl, integer22, integer23, integer24, n3 + 9, integer17);
            this.getFont().draw(dhl, mr10, (float)integer19, (float)integer20, -1);
            this.getFont().draw(dhl, string23, (float)(integer21 - this.getFont().width(string23)), (float)integer20, -1);
            if (integer16 == collection5.size()) {
                final int integer25 = integer19 - 2;
                final int n4 = integer20;
                this.getFont().getClass();
                GuiComponent.fill(dhl, integer25, n4 - 9 - 1, integer21, integer20 - 1, integer18);
                GuiComponent.fill(dhl, integer19 - 2, integer20 - 1, integer21, integer20, integer17);
                final Font font = this.getFont();
                final Component mu = mr8;
                final float float3 = (float)(integer19 + integer10 / 2 - integer9 / 2);
                final int n5 = integer20;
                this.getFont().getClass();
                font.draw(dhl, mu, float3, (float)(n5 - 9), -1);
            }
        }
    }
    
    private Player getCameraPlayer() {
        if (!(this.minecraft.getCameraEntity() instanceof Player)) {
            return null;
        }
        return (Player)this.minecraft.getCameraEntity();
    }
    
    private LivingEntity getPlayerVehicleWithHealth() {
        final Player bec2 = this.getCameraPlayer();
        if (bec2 != null) {
            final Entity aom3 = bec2.getVehicle();
            if (aom3 == null) {
                return null;
            }
            if (aom3 instanceof LivingEntity) {
                return (LivingEntity)aom3;
            }
        }
        return null;
    }
    
    private int getVehicleMaxHearts(final LivingEntity aoy) {
        if (aoy == null || !aoy.showVehicleHealth()) {
            return 0;
        }
        final float float3 = aoy.getMaxHealth();
        int integer4 = (int)(float3 + 0.5f) / 2;
        if (integer4 > 30) {
            integer4 = 30;
        }
        return integer4;
    }
    
    private int getVisibleVehicleHeartRows(final int integer) {
        return (int)Math.ceil(integer / 10.0);
    }
    
    private void renderPlayerHealth(final PoseStack dhl) {
        final Player bec3 = this.getCameraPlayer();
        if (bec3 == null) {
            return;
        }
        final int integer4 = Mth.ceil(bec3.getHealth());
        final boolean boolean5 = this.healthBlinkTime > this.tickCount && (this.healthBlinkTime - this.tickCount) / 3L % 2L == 1L;
        final long long6 = Util.getMillis();
        if (integer4 < this.lastHealth && bec3.invulnerableTime > 0) {
            this.lastHealthTime = long6;
            this.healthBlinkTime = this.tickCount + 20;
        }
        else if (integer4 > this.lastHealth && bec3.invulnerableTime > 0) {
            this.lastHealthTime = long6;
            this.healthBlinkTime = this.tickCount + 10;
        }
        if (long6 - this.lastHealthTime > 1000L) {
            this.lastHealth = integer4;
            this.displayHealth = integer4;
            this.lastHealthTime = long6;
        }
        this.lastHealth = integer4;
        final int integer5 = this.displayHealth;
        this.random.setSeed(this.tickCount * 312871);
        final FoodData bge9 = bec3.getFoodData();
        final int integer6 = bge9.getFoodLevel();
        final int integer7 = this.screenWidth / 2 - 91;
        final int integer8 = this.screenWidth / 2 + 91;
        final int integer9 = this.screenHeight - 39;
        final float float14 = (float)bec3.getAttributeValue(Attributes.MAX_HEALTH);
        final int integer10 = Mth.ceil(bec3.getAbsorptionAmount());
        final int integer11 = Mth.ceil((float14 + integer10) / 2.0f / 10.0f);
        final int integer12 = Math.max(10 - (integer11 - 2), 3);
        final int integer13 = integer9 - (integer11 - 1) * integer12 - 10;
        int integer14 = integer9 - 10;
        int integer15 = integer10;
        final int integer16 = bec3.getArmorValue();
        int integer17 = -1;
        if (bec3.hasEffect(MobEffects.REGENERATION)) {
            integer17 = this.tickCount % Mth.ceil(float14 + 5.0f);
        }
        this.minecraft.getProfiler().push("armor");
        for (int integer18 = 0; integer18 < 10; ++integer18) {
            if (integer16 > 0) {
                final int integer19 = integer7 + integer18 * 8;
                if (integer18 * 2 + 1 < integer16) {
                    this.blit(dhl, integer19, integer13, 34, 9, 9, 9);
                }
                if (integer18 * 2 + 1 == integer16) {
                    this.blit(dhl, integer19, integer13, 25, 9, 9, 9);
                }
                if (integer18 * 2 + 1 > integer16) {
                    this.blit(dhl, integer19, integer13, 16, 9, 9, 9);
                }
            }
        }
        this.minecraft.getProfiler().popPush("health");
        for (int integer18 = Mth.ceil((float14 + integer10) / 2.0f) - 1; integer18 >= 0; --integer18) {
            int integer19 = 16;
            if (bec3.hasEffect(MobEffects.POISON)) {
                integer19 += 36;
            }
            else if (bec3.hasEffect(MobEffects.WITHER)) {
                integer19 += 72;
            }
            int integer20 = 0;
            if (boolean5) {
                integer20 = 1;
            }
            final int integer21 = Mth.ceil((integer18 + 1) / 10.0f) - 1;
            final int integer22 = integer7 + integer18 % 10 * 8;
            int integer23 = integer9 - integer21 * integer12;
            if (integer4 <= 4) {
                integer23 += this.random.nextInt(2);
            }
            if (integer15 <= 0 && integer18 == integer17) {
                integer23 -= 2;
            }
            int integer24 = 0;
            if (bec3.level.getLevelData().isHardcore()) {
                integer24 = 5;
            }
            this.blit(dhl, integer22, integer23, 16 + integer20 * 9, 9 * integer24, 9, 9);
            if (boolean5) {
                if (integer18 * 2 + 1 < integer5) {
                    this.blit(dhl, integer22, integer23, integer19 + 54, 9 * integer24, 9, 9);
                }
                if (integer18 * 2 + 1 == integer5) {
                    this.blit(dhl, integer22, integer23, integer19 + 63, 9 * integer24, 9, 9);
                }
            }
            if (integer15 > 0) {
                if (integer15 == integer10 && integer10 % 2 == 1) {
                    this.blit(dhl, integer22, integer23, integer19 + 153, 9 * integer24, 9, 9);
                    --integer15;
                }
                else {
                    this.blit(dhl, integer22, integer23, integer19 + 144, 9 * integer24, 9, 9);
                    integer15 -= 2;
                }
            }
            else {
                if (integer18 * 2 + 1 < integer4) {
                    this.blit(dhl, integer22, integer23, integer19 + 36, 9 * integer24, 9, 9);
                }
                if (integer18 * 2 + 1 == integer4) {
                    this.blit(dhl, integer22, integer23, integer19 + 45, 9 * integer24, 9, 9);
                }
            }
        }
        final LivingEntity aoy23 = this.getPlayerVehicleWithHealth();
        int integer19 = this.getVehicleMaxHearts(aoy23);
        if (integer19 == 0) {
            this.minecraft.getProfiler().popPush("food");
            for (int integer20 = 0; integer20 < 10; ++integer20) {
                int integer21 = integer9;
                int integer22 = 16;
                int integer23 = 0;
                if (bec3.hasEffect(MobEffects.HUNGER)) {
                    integer22 += 36;
                    integer23 = 13;
                }
                if (bec3.getFoodData().getSaturationLevel() <= 0.0f && this.tickCount % (integer6 * 3 + 1) == 0) {
                    integer21 += this.random.nextInt(3) - 1;
                }
                final int integer24 = integer8 - integer20 * 8 - 9;
                this.blit(dhl, integer24, integer21, 16 + integer23 * 9, 27, 9, 9);
                if (integer20 * 2 + 1 < integer6) {
                    this.blit(dhl, integer24, integer21, integer22 + 36, 27, 9, 9);
                }
                if (integer20 * 2 + 1 == integer6) {
                    this.blit(dhl, integer24, integer21, integer22 + 45, 27, 9, 9);
                }
            }
            integer14 -= 10;
        }
        this.minecraft.getProfiler().popPush("air");
        int integer20 = bec3.getAirSupply();
        int integer21 = bec3.getMaxAirSupply();
        if (bec3.isEyeInFluid(FluidTags.WATER) || integer20 < integer21) {
            final int integer22 = this.getVisibleVehicleHeartRows(integer19) - 1;
            integer14 -= integer22 * 10;
            for (int integer23 = Mth.ceil((integer20 - 2) * 10.0 / integer21), integer24 = Mth.ceil(integer20 * 10.0 / integer21) - integer23, integer25 = 0; integer25 < integer23 + integer24; ++integer25) {
                if (integer25 < integer23) {
                    this.blit(dhl, integer8 - integer25 * 8 - 9, integer14, 16, 18, 9, 9);
                }
                else {
                    this.blit(dhl, integer8 - integer25 * 8 - 9, integer14, 25, 18, 9, 9);
                }
            }
        }
        this.minecraft.getProfiler().pop();
    }
    
    private void renderVehicleHealth(final PoseStack dhl) {
        final LivingEntity aoy3 = this.getPlayerVehicleWithHealth();
        if (aoy3 == null) {
            return;
        }
        int integer4 = this.getVehicleMaxHearts(aoy3);
        if (integer4 == 0) {
            return;
        }
        final int integer5 = (int)Math.ceil(aoy3.getHealth());
        this.minecraft.getProfiler().popPush("mountHealth");
        final int integer6 = this.screenHeight - 39;
        final int integer7 = this.screenWidth / 2 + 91;
        int integer8 = integer6;
        int integer9 = 0;
        final boolean boolean10 = false;
        while (integer4 > 0) {
            final int integer10 = Math.min(integer4, 10);
            integer4 -= integer10;
            for (int integer11 = 0; integer11 < integer10; ++integer11) {
                final int integer12 = 52;
                final int integer13 = 0;
                final int integer14 = integer7 - integer11 * 8 - 9;
                this.blit(dhl, integer14, integer8, 52 + integer13 * 9, 9, 9, 9);
                if (integer11 * 2 + 1 + integer9 < integer5) {
                    this.blit(dhl, integer14, integer8, 88, 9, 9, 9);
                }
                if (integer11 * 2 + 1 + integer9 == integer5) {
                    this.blit(dhl, integer14, integer8, 97, 9, 9, 9);
                }
            }
            integer8 -= 10;
            integer9 += 20;
        }
    }
    
    private void renderPumpkin() {
        RenderSystem.disableDepthTest();
        RenderSystem.depthMask(false);
        RenderSystem.defaultBlendFunc();
        RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
        RenderSystem.disableAlphaTest();
        this.minecraft.getTextureManager().bind(Gui.PUMPKIN_BLUR_LOCATION);
        final Tesselator dhn2 = Tesselator.getInstance();
        final BufferBuilder dhg3 = dhn2.getBuilder();
        dhg3.begin(7, DefaultVertexFormat.POSITION_TEX);
        dhg3.vertex(0.0, this.screenHeight, -90.0).uv(0.0f, 1.0f).endVertex();
        dhg3.vertex(this.screenWidth, this.screenHeight, -90.0).uv(1.0f, 1.0f).endVertex();
        dhg3.vertex(this.screenWidth, 0.0, -90.0).uv(1.0f, 0.0f).endVertex();
        dhg3.vertex(0.0, 0.0, -90.0).uv(0.0f, 0.0f).endVertex();
        dhn2.end();
        RenderSystem.depthMask(true);
        RenderSystem.enableDepthTest();
        RenderSystem.enableAlphaTest();
        RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
    }
    
    private void updateVignetteBrightness(final Entity aom) {
        if (aom == null) {
            return;
        }
        final float float3 = Mth.clamp(1.0f - aom.getBrightness(), 0.0f, 1.0f);
        this.vignetteBrightness += (float)((float3 - this.vignetteBrightness) * 0.01);
    }
    
    private void renderVignette(final Entity aom) {
        final WorldBorder cgw3 = this.minecraft.level.getWorldBorder();
        float float4 = (float)cgw3.getDistanceToBorder(aom);
        final double double5 = Math.min(cgw3.getLerpSpeed() * cgw3.getWarningTime() * 1000.0, Math.abs(cgw3.getLerpTarget() - cgw3.getSize()));
        final double double6 = Math.max(cgw3.getWarningBlocks(), double5);
        if (float4 < double6) {
            float4 = 1.0f - (float)(float4 / double6);
        }
        else {
            float4 = 0.0f;
        }
        RenderSystem.disableDepthTest();
        RenderSystem.depthMask(false);
        RenderSystem.blendFuncSeparate(GlStateManager.SourceFactor.ZERO, GlStateManager.DestFactor.ONE_MINUS_SRC_COLOR, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
        if (float4 > 0.0f) {
            RenderSystem.color4f(0.0f, float4, float4, 1.0f);
        }
        else {
            RenderSystem.color4f(this.vignetteBrightness, this.vignetteBrightness, this.vignetteBrightness, 1.0f);
        }
        this.minecraft.getTextureManager().bind(Gui.VIGNETTE_LOCATION);
        final Tesselator dhn9 = Tesselator.getInstance();
        final BufferBuilder dhg10 = dhn9.getBuilder();
        dhg10.begin(7, DefaultVertexFormat.POSITION_TEX);
        dhg10.vertex(0.0, this.screenHeight, -90.0).uv(0.0f, 1.0f).endVertex();
        dhg10.vertex(this.screenWidth, this.screenHeight, -90.0).uv(1.0f, 1.0f).endVertex();
        dhg10.vertex(this.screenWidth, 0.0, -90.0).uv(1.0f, 0.0f).endVertex();
        dhg10.vertex(0.0, 0.0, -90.0).uv(0.0f, 0.0f).endVertex();
        dhn9.end();
        RenderSystem.depthMask(true);
        RenderSystem.enableDepthTest();
        RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
        RenderSystem.defaultBlendFunc();
    }
    
    private void renderPortalOverlay(float float1) {
        if (float1 < 1.0f) {
            float1 *= float1;
            float1 *= float1;
            float1 = float1 * 0.8f + 0.2f;
        }
        RenderSystem.disableAlphaTest();
        RenderSystem.disableDepthTest();
        RenderSystem.depthMask(false);
        RenderSystem.defaultBlendFunc();
        RenderSystem.color4f(1.0f, 1.0f, 1.0f, float1);
        this.minecraft.getTextureManager().bind(TextureAtlas.LOCATION_BLOCKS);
        final TextureAtlasSprite elv3 = this.minecraft.getBlockRenderer().getBlockModelShaper().getParticleIcon(Blocks.NETHER_PORTAL.defaultBlockState());
        final float float2 = elv3.getU0();
        final float float3 = elv3.getV0();
        final float float4 = elv3.getU1();
        final float float5 = elv3.getV1();
        final Tesselator dhn8 = Tesselator.getInstance();
        final BufferBuilder dhg9 = dhn8.getBuilder();
        dhg9.begin(7, DefaultVertexFormat.POSITION_TEX);
        dhg9.vertex(0.0, this.screenHeight, -90.0).uv(float2, float5).endVertex();
        dhg9.vertex(this.screenWidth, this.screenHeight, -90.0).uv(float4, float5).endVertex();
        dhg9.vertex(this.screenWidth, 0.0, -90.0).uv(float4, float3).endVertex();
        dhg9.vertex(0.0, 0.0, -90.0).uv(float2, float3).endVertex();
        dhn8.end();
        RenderSystem.depthMask(true);
        RenderSystem.enableDepthTest();
        RenderSystem.enableAlphaTest();
        RenderSystem.color4f(1.0f, 1.0f, 1.0f, 1.0f);
    }
    
    private void renderSlot(final int integer1, final int integer2, final float float3, final Player bec, final ItemStack bki) {
        if (bki.isEmpty()) {
            return;
        }
        final float float4 = bki.getPopTime() - float3;
        if (float4 > 0.0f) {
            RenderSystem.pushMatrix();
            final float float5 = 1.0f + float4 / 5.0f;
            RenderSystem.translatef((float)(integer1 + 8), (float)(integer2 + 12), 0.0f);
            RenderSystem.scalef(1.0f / float5, (float5 + 1.0f) / 2.0f, 1.0f);
            RenderSystem.translatef((float)(-(integer1 + 8)), (float)(-(integer2 + 12)), 0.0f);
        }
        this.itemRenderer.renderAndDecorateItem(bec, bki, integer1, integer2);
        if (float4 > 0.0f) {
            RenderSystem.popMatrix();
        }
        this.itemRenderer.renderGuiItemDecorations(this.minecraft.font, bki, integer1, integer2);
    }
    
    public void tick() {
        if (this.overlayMessageTime > 0) {
            --this.overlayMessageTime;
        }
        if (this.titleTime > 0) {
            --this.titleTime;
            if (this.titleTime <= 0) {
                this.title = null;
                this.subtitle = null;
            }
        }
        ++this.tickCount;
        final Entity aom2 = this.minecraft.getCameraEntity();
        if (aom2 != null) {
            this.updateVignetteBrightness(aom2);
        }
        if (this.minecraft.player != null) {
            final ItemStack bki3 = this.minecraft.player.inventory.getSelected();
            if (bki3.isEmpty()) {
                this.toolHighlightTimer = 0;
            }
            else if (this.lastToolHighlight.isEmpty() || bki3.getItem() != this.lastToolHighlight.getItem() || !bki3.getHoverName().equals(this.lastToolHighlight.getHoverName())) {
                this.toolHighlightTimer = 40;
            }
            else if (this.toolHighlightTimer > 0) {
                --this.toolHighlightTimer;
            }
            this.lastToolHighlight = bki3;
        }
    }
    
    public void setNowPlaying(final Component mr) {
        this.setOverlayMessage(new TranslatableComponent("record.nowPlaying", new Object[] { mr }), true);
    }
    
    public void setOverlayMessage(final Component mr, final boolean boolean2) {
        this.overlayMessageString = mr;
        this.overlayMessageTime = 60;
        this.animateOverlayMessageColor = boolean2;
    }
    
    public void setTitles(@Nullable final Component mr1, @Nullable final Component mr2, final int integer3, final int integer4, final int integer5) {
        if (mr1 == null && mr2 == null && integer3 < 0 && integer4 < 0 && integer5 < 0) {
            this.title = null;
            this.subtitle = null;
            this.titleTime = 0;
            return;
        }
        if (mr1 != null) {
            this.title = mr1;
            this.titleTime = this.titleFadeInTime + this.titleStayTime + this.titleFadeOutTime;
            return;
        }
        if (mr2 != null) {
            this.subtitle = mr2;
            return;
        }
        if (integer3 >= 0) {
            this.titleFadeInTime = integer3;
        }
        if (integer4 >= 0) {
            this.titleStayTime = integer4;
        }
        if (integer5 >= 0) {
            this.titleFadeOutTime = integer5;
        }
        if (this.titleTime > 0) {
            this.titleTime = this.titleFadeInTime + this.titleStayTime + this.titleFadeOutTime;
        }
    }
    
    public void handleChat(final ChatType mo, final Component mr, final UUID uUID) {
        for (final ChatListener dmx6 : this.chatListeners.get(mo)) {
            dmx6.handle(mo, mr, uUID);
        }
    }
    
    public ChatComponent getChat() {
        return this.chat;
    }
    
    public int getGuiTicks() {
        return this.tickCount;
    }
    
    public Font getFont() {
        return this.minecraft.font;
    }
    
    public SpectatorGui getSpectatorGui() {
        return this.spectatorGui;
    }
    
    public PlayerTabOverlay getTabList() {
        return this.tabList;
    }
    
    public void onDisconnected() {
        this.tabList.reset();
        this.bossOverlay.reset();
        this.minecraft.getToasts().clear();
    }
    
    public BossHealthOverlay getBossOverlay() {
        return this.bossOverlay;
    }
    
    public void clearCache() {
        this.debugScreen.clearChunkCache();
    }
    
    static {
        VIGNETTE_LOCATION = new ResourceLocation("textures/misc/vignette.png");
        WIDGETS_LOCATION = new ResourceLocation("textures/gui/widgets.png");
        PUMPKIN_BLUR_LOCATION = new ResourceLocation("textures/misc/pumpkinblur.png");
    }
}
