    001package net.minecraft.client.gui;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import java.awt.Color;
    006import java.util.Collection;
    007import java.util.Iterator;
    008import java.util.List;
    009import java.util.Random;
    010import net.minecraft.block.Block;
    011import net.minecraft.block.material.Material;
    012import net.minecraft.client.Minecraft;
    013import net.minecraft.client.multiplayer.NetClientHandler;
    014import net.minecraft.client.renderer.RenderHelper;
    015import net.minecraft.client.renderer.Tessellator;
    016import net.minecraft.client.renderer.entity.RenderItem;
    017import net.minecraft.entity.boss.BossStatus;
    018import net.minecraft.entity.player.InventoryPlayer;
    019import net.minecraft.item.ItemStack;
    020import net.minecraft.potion.Potion;
    021import net.minecraft.scoreboard.Score;
    022import net.minecraft.scoreboard.ScoreObjective;
    023import net.minecraft.scoreboard.ScorePlayerTeam;
    024import net.minecraft.scoreboard.Scoreboard;
    025import net.minecraft.util.Direction;
    026import net.minecraft.util.EnumChatFormatting;
    027import net.minecraft.util.FoodStats;
    028import net.minecraft.util.Icon;
    029import net.minecraft.util.MathHelper;
    030import net.minecraft.util.StatCollector;
    031import net.minecraft.util.StringUtils;
    032import net.minecraft.world.EnumSkyBlock;
    033import net.minecraft.world.chunk.Chunk;
    034import org.lwjgl.opengl.GL11;
    035import org.lwjgl.opengl.GL12;
    036
    037import net.minecraftforge.common.ForgeHooks;
    038
    039@SideOnly(Side.CLIENT)
    040public class GuiIngame extends Gui
    041{
    042    protected static final RenderItem itemRenderer = new RenderItem();
    043    protected final Random rand = new Random();
    044    protected final Minecraft mc;
    045
    046    /** ChatGUI instance that retains all previous chat data */
    047    protected final GuiNewChat persistantChatGUI;
    048    protected int updateCounter = 0;
    049
    050    /** The string specifying which record music is playing */
    051    protected String recordPlaying = "";
    052
    053    /** How many ticks the record playing message will be displayed */
    054    protected int recordPlayingUpFor = 0;
    055    protected boolean recordIsPlaying = false;
    056
    057    /** Previous frame vignette brightness (slowly changes by 1% each frame) */
    058    public float prevVignetteBrightness = 1.0F;
    059    protected int field_92017_k;
    060    protected ItemStack field_92016_l;
    061
    062    public GuiIngame(Minecraft par1Minecraft)
    063    {
    064        this.mc = par1Minecraft;
    065        this.persistantChatGUI = new GuiNewChat(par1Minecraft);
    066    }
    067
    068    /**
    069     * Render the ingame overlay with quick icon bar, ...
    070     */
    071    public void renderGameOverlay(float par1, boolean par2, int par3, int par4)
    072    {
    073        ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight);
    074        int k = scaledresolution.getScaledWidth();
    075        int l = scaledresolution.getScaledHeight();
    076        FontRenderer fontrenderer = this.mc.fontRenderer;
    077        this.mc.entityRenderer.setupOverlayRendering();
    078        GL11.glEnable(GL11.GL_BLEND);
    079
    080        if (Minecraft.isFancyGraphicsEnabled())
    081        {
    082            this.renderVignette(this.mc.thePlayer.getBrightness(par1), k, l);
    083        }
    084        else
    085        {
    086            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    087        }
    088
    089        ItemStack itemstack = this.mc.thePlayer.inventory.armorItemInSlot(3);
    090
    091        if (this.mc.gameSettings.thirdPersonView == 0 && itemstack != null && itemstack.getItem() != null)
    092        {
    093            if (itemstack.itemID == Block.pumpkin.blockID)
    094            {
    095                this.renderPumpkinBlur(k, l);
    096            }
    097            else
    098            {
    099                itemstack.getItem().renderHelmetOverlay(itemstack, mc.thePlayer, scaledresolution, par1, par2, par3, par4);
    100            }
    101        }
    102
    103        if (!this.mc.thePlayer.isPotionActive(Potion.confusion))
    104        {
    105            float f1 = this.mc.thePlayer.prevTimeInPortal + (this.mc.thePlayer.timeInPortal - this.mc.thePlayer.prevTimeInPortal) * par1;
    106
    107            if (f1 > 0.0F)
    108            {
    109                this.renderPortalOverlay(f1, k, l);
    110            }
    111        }
    112
    113        boolean flag1;
    114        int i1;
    115        int j1;
    116        int k1;
    117        int l1;
    118        int i2;
    119        int j2;
    120        int k2;
    121        int l2;
    122        int i3;
    123        byte b0;
    124        int j3;
    125        int k3;
    126        int l3;
    127
    128        if (!this.mc.playerController.enableEverythingIsScrewedUpMode())
    129        {
    130            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    131            this.mc.renderEngine.bindTexture("/gui/gui.png");
    132            InventoryPlayer inventoryplayer = this.mc.thePlayer.inventory;
    133            this.zLevel = -90.0F;
    134            this.drawTexturedModalRect(k / 2 - 91, l - 22, 0, 0, 182, 22);
    135            this.drawTexturedModalRect(k / 2 - 91 - 1 + inventoryplayer.currentItem * 20, l - 22 - 1, 0, 22, 24, 22);
    136            this.mc.renderEngine.bindTexture("/gui/icons.png");
    137            GL11.glEnable(GL11.GL_BLEND);
    138            GL11.glBlendFunc(GL11.GL_ONE_MINUS_DST_COLOR, GL11.GL_ONE_MINUS_SRC_COLOR);
    139            this.drawTexturedModalRect(k / 2 - 7, l / 2 - 7, 0, 0, 16, 16);
    140            GL11.glDisable(GL11.GL_BLEND);
    141            flag1 = this.mc.thePlayer.hurtResistantTime / 3 % 2 == 1;
    142
    143            if (this.mc.thePlayer.hurtResistantTime < 10)
    144            {
    145                flag1 = false;
    146            }
    147
    148            i1 = this.mc.thePlayer.getHealth();
    149            j1 = this.mc.thePlayer.prevHealth;
    150            this.rand.setSeed((long)(this.updateCounter * 312871));
    151            boolean flag2 = false;
    152            FoodStats foodstats = this.mc.thePlayer.getFoodStats();
    153            l1 = foodstats.getFoodLevel();
    154            k1 = foodstats.getPrevFoodLevel();
    155            this.mc.mcProfiler.startSection("bossHealth");
    156            this.renderBossHealth();
    157            this.mc.mcProfiler.endSection();
    158            int i4;
    159
    160            if (this.mc.playerController.shouldDrawHUD())
    161            {
    162                i2 = k / 2 - 91;
    163                i4 = k / 2 + 91;
    164                this.mc.mcProfiler.startSection("expBar");
    165                j2 = this.mc.thePlayer.xpBarCap();
    166
    167                if (j2 > 0)
    168                {
    169                    short short1 = 182;
    170                    l2 = (int)(this.mc.thePlayer.experience * (float)(short1 + 1));
    171                    k2 = l - 32 + 3;
    172                    this.drawTexturedModalRect(i2, k2, 0, 64, short1, 5);
    173
    174                    if (l2 > 0)
    175                    {
    176                        this.drawTexturedModalRect(i2, k2, 0, 69, l2, 5);
    177                    }
    178                }
    179
    180                k3 = l - 39;
    181                l2 = k3 - 10;
    182                k2 = ForgeHooks.getTotalArmorValue(mc.thePlayer);
    183                i3 = -1;
    184
    185                if (this.mc.thePlayer.isPotionActive(Potion.regeneration))
    186                {
    187                    i3 = this.updateCounter % 25;
    188                }
    189
    190                this.mc.mcProfiler.endStartSection("healthArmor");
    191                int j4;
    192                int k4;
    193                int l4;
    194
    195                for (j4 = 0; j4 < 10; ++j4)
    196                {
    197                    if (k2 > 0)
    198                    {
    199                        j3 = i2 + j4 * 8;
    200
    201                        if (j4 * 2 + 1 < k2)
    202                        {
    203                            this.drawTexturedModalRect(j3, l2, 34, 9, 9, 9);
    204                        }
    205
    206                        if (j4 * 2 + 1 == k2)
    207                        {
    208                            this.drawTexturedModalRect(j3, l2, 25, 9, 9, 9);
    209                        }
    210
    211                        if (j4 * 2 + 1 > k2)
    212                        {
    213                            this.drawTexturedModalRect(j3, l2, 16, 9, 9, 9);
    214                        }
    215                    }
    216
    217                    j3 = 16;
    218
    219                    if (this.mc.thePlayer.isPotionActive(Potion.poison))
    220                    {
    221                        j3 += 36;
    222                    }
    223                    else if (this.mc.thePlayer.isPotionActive(Potion.wither))
    224                    {
    225                        j3 += 72;
    226                    }
    227
    228                    b0 = 0;
    229
    230                    if (flag1)
    231                    {
    232                        b0 = 1;
    233                    }
    234
    235                    l4 = i2 + j4 * 8;
    236                    k4 = k3;
    237
    238                    if (i1 <= 4)
    239                    {
    240                        k4 = k3 + this.rand.nextInt(2);
    241                    }
    242
    243                    if (j4 == i3)
    244                    {
    245                        k4 -= 2;
    246                    }
    247
    248                    byte b1 = 0;
    249
    250                    if (this.mc.theWorld.getWorldInfo().isHardcoreModeEnabled())
    251                    {
    252                        b1 = 5;
    253                    }
    254
    255                    this.drawTexturedModalRect(l4, k4, 16 + b0 * 9, 9 * b1, 9, 9);
    256
    257                    if (flag1)
    258                    {
    259                        if (j4 * 2 + 1 < j1)
    260                        {
    261                            this.drawTexturedModalRect(l4, k4, j3 + 54, 9 * b1, 9, 9);
    262                        }
    263
    264                        if (j4 * 2 + 1 == j1)
    265                        {
    266                            this.drawTexturedModalRect(l4, k4, j3 + 63, 9 * b1, 9, 9);
    267                        }
    268                    }
    269
    270                    if (j4 * 2 + 1 < i1)
    271                    {
    272                        this.drawTexturedModalRect(l4, k4, j3 + 36, 9 * b1, 9, 9);
    273                    }
    274
    275                    if (j4 * 2 + 1 == i1)
    276                    {
    277                        this.drawTexturedModalRect(l4, k4, j3 + 45, 9 * b1, 9, 9);
    278                    }
    279                }
    280
    281                this.mc.mcProfiler.endStartSection("food");
    282
    283                for (j4 = 0; j4 < 10; ++j4)
    284                {
    285                    j3 = k3;
    286                    l3 = 16;
    287                    byte b2 = 0;
    288
    289                    if (this.mc.thePlayer.isPotionActive(Potion.hunger))
    290                    {
    291                        l3 += 36;
    292                        b2 = 13;
    293                    }
    294
    295                    if (this.mc.thePlayer.getFoodStats().getSaturationLevel() <= 0.0F && this.updateCounter % (l1 * 3 + 1) == 0)
    296                    {
    297                        j3 = k3 + (this.rand.nextInt(3) - 1);
    298                    }
    299
    300                    if (flag2)
    301                    {
    302                        b2 = 1;
    303                    }
    304
    305                    k4 = i4 - j4 * 8 - 9;
    306                    this.drawTexturedModalRect(k4, j3, 16 + b2 * 9, 27, 9, 9);
    307
    308                    if (flag2)
    309                    {
    310                        if (j4 * 2 + 1 < k1)
    311                        {
    312                            this.drawTexturedModalRect(k4, j3, l3 + 54, 27, 9, 9);
    313                        }
    314
    315                        if (j4 * 2 + 1 == k1)
    316                        {
    317                            this.drawTexturedModalRect(k4, j3, l3 + 63, 27, 9, 9);
    318                        }
    319                    }
    320
    321                    if (j4 * 2 + 1 < l1)
    322                    {
    323                        this.drawTexturedModalRect(k4, j3, l3 + 36, 27, 9, 9);
    324                    }
    325
    326                    if (j4 * 2 + 1 == l1)
    327                    {
    328                        this.drawTexturedModalRect(k4, j3, l3 + 45, 27, 9, 9);
    329                    }
    330                }
    331
    332                this.mc.mcProfiler.endStartSection("air");
    333
    334                if (this.mc.thePlayer.isInsideOfMaterial(Material.water))
    335                {
    336                    j4 = this.mc.thePlayer.getAir();
    337                    j3 = MathHelper.ceiling_double_int((double)(j4 - 2) * 10.0D / 300.0D);
    338                    l3 = MathHelper.ceiling_double_int((double)j4 * 10.0D / 300.0D) - j3;
    339
    340                    for (l4 = 0; l4 < j3 + l3; ++l4)
    341                    {
    342                        if (l4 < j3)
    343                        {
    344                            this.drawTexturedModalRect(i4 - l4 * 8 - 9, l2, 16, 18, 9, 9);
    345                        }
    346                        else
    347                        {
    348                            this.drawTexturedModalRect(i4 - l4 * 8 - 9, l2, 25, 18, 9, 9);
    349                        }
    350                    }
    351                }
    352
    353                this.mc.mcProfiler.endSection();
    354            }
    355
    356            GL11.glDisable(GL11.GL_BLEND);
    357            this.mc.mcProfiler.startSection("actionBar");
    358            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    359            RenderHelper.enableGUIStandardItemLighting();
    360
    361            for (i2 = 0; i2 < 9; ++i2)
    362            {
    363                i4 = k / 2 - 90 + i2 * 20 + 2;
    364                j2 = l - 16 - 3;
    365                this.renderInventorySlot(i2, i4, j2, par1);
    366            }
    367
    368            RenderHelper.disableStandardItemLighting();
    369            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    370            this.mc.mcProfiler.endSection();
    371        }
    372
    373        float f2;
    374
    375        if (this.mc.thePlayer.getSleepTimer() > 0)
    376        {
    377            this.mc.mcProfiler.startSection("sleep");
    378            GL11.glDisable(GL11.GL_DEPTH_TEST);
    379            GL11.glDisable(GL11.GL_ALPHA_TEST);
    380            int i5 = this.mc.thePlayer.getSleepTimer();
    381            f2 = (float)i5 / 100.0F;
    382
    383            if (f2 > 1.0F)
    384            {
    385                f2 = 1.0F - (float)(i5 - 100) / 10.0F;
    386            }
    387
    388            i1 = (int)(220.0F * f2) << 24 | 1052704;
    389            drawRect(0, 0, k, l, i1);
    390            GL11.glEnable(GL11.GL_ALPHA_TEST);
    391            GL11.glEnable(GL11.GL_DEPTH_TEST);
    392            this.mc.mcProfiler.endSection();
    393        }
    394
    395        int j5;
    396        int k5;
    397
    398        if (this.mc.playerController.func_78763_f() && this.mc.thePlayer.experienceLevel > 0)
    399        {
    400            this.mc.mcProfiler.startSection("expLevel");
    401            flag1 = false;
    402            i1 = flag1 ? 16777215 : 8453920;
    403            String s = "" + this.mc.thePlayer.experienceLevel;
    404            j5 = (k - fontrenderer.getStringWidth(s)) / 2;
    405            k5 = l - 31 - 4;
    406            fontrenderer.drawString(s, j5 + 1, k5, 0);
    407            fontrenderer.drawString(s, j5 - 1, k5, 0);
    408            fontrenderer.drawString(s, j5, k5 + 1, 0);
    409            fontrenderer.drawString(s, j5, k5 - 1, 0);
    410            fontrenderer.drawString(s, j5, k5, i1);
    411            this.mc.mcProfiler.endSection();
    412        }
    413
    414        String s1;
    415
    416        if (this.mc.gameSettings.heldItemTooltips)
    417        {
    418            this.mc.mcProfiler.startSection("toolHighlight");
    419
    420            if (this.field_92017_k > 0 && this.field_92016_l != null)
    421            {
    422                s1 = this.field_92016_l.getDisplayName();
    423                i1 = (k - fontrenderer.getStringWidth(s1)) / 2;
    424                j1 = l - 59;
    425
    426                if (!this.mc.playerController.shouldDrawHUD())
    427                {
    428                    j1 += 14;
    429                }
    430
    431                j5 = (int)((float)this.field_92017_k * 256.0F / 10.0F);
    432
    433                if (j5 > 255)
    434                {
    435                    j5 = 255;
    436                }
    437
    438                if (j5 > 0)
    439                {
    440                    GL11.glPushMatrix();
    441                    GL11.glEnable(GL11.GL_BLEND);
    442                    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    443                    FontRenderer font = field_92016_l.getItem().getFontRenderer(field_92016_l);
    444                    if (font != null)
    445                    {
    446                        i1 = (k - font.getStringWidth(s1)) / 2;
    447                        font.drawStringWithShadow(s1, i1, j1, 16777215 + (j5 << 24));
    448                    }
    449                    else
    450                    {
    451                        fontrenderer.drawStringWithShadow(s1, i1, j1, 16777215 + (j5 << 24));
    452                    }
    453                    GL11.glDisable(GL11.GL_BLEND);
    454                    GL11.glPopMatrix();
    455                }
    456            }
    457
    458            this.mc.mcProfiler.endSection();
    459        }
    460
    461        if (this.mc.isDemo())
    462        {
    463            this.mc.mcProfiler.startSection("demo");
    464            s1 = "";
    465
    466            if (this.mc.theWorld.getTotalWorldTime() >= 120500L)
    467            {
    468                s1 = StatCollector.translateToLocal("demo.demoExpired");
    469            }
    470            else
    471            {
    472                s1 = String.format(StatCollector.translateToLocal("demo.remainingTime"), new Object[] {StringUtils.ticksToElapsedTime((int)(120500L - this.mc.theWorld.getTotalWorldTime()))});
    473            }
    474
    475            i1 = fontrenderer.getStringWidth(s1);
    476            fontrenderer.drawStringWithShadow(s1, k - i1 - 10, 5, 16777215);
    477            this.mc.mcProfiler.endSection();
    478        }
    479
    480        if (this.mc.gameSettings.showDebugInfo)
    481        {
    482            this.mc.mcProfiler.startSection("debug");
    483            GL11.glPushMatrix();
    484            fontrenderer.drawStringWithShadow("Minecraft 1.5.1 (" + this.mc.debug + ")", 2, 2, 16777215);
    485            fontrenderer.drawStringWithShadow(this.mc.debugInfoRenders(), 2, 12, 16777215);
    486            fontrenderer.drawStringWithShadow(this.mc.getEntityDebug(), 2, 22, 16777215);
    487            fontrenderer.drawStringWithShadow(this.mc.debugInfoEntities(), 2, 32, 16777215);
    488            fontrenderer.drawStringWithShadow(this.mc.getWorldProviderName(), 2, 42, 16777215);
    489            long l5 = Runtime.getRuntime().maxMemory();
    490            long i6 = Runtime.getRuntime().totalMemory();
    491            long j6 = Runtime.getRuntime().freeMemory();
    492            long k6 = i6 - j6;
    493            String s2 = "Used memory: " + k6 * 100L / l5 + "% (" + k6 / 1024L / 1024L + "MB) of " + l5 / 1024L / 1024L + "MB";
    494            this.drawString(fontrenderer, s2, k - fontrenderer.getStringWidth(s2) - 2, 2, 14737632);
    495            s2 = "Allocated memory: " + i6 * 100L / l5 + "% (" + i6 / 1024L / 1024L + "MB)";
    496            this.drawString(fontrenderer, s2, k - fontrenderer.getStringWidth(s2) - 2, 12, 14737632);
    497            k3 = MathHelper.floor_double(this.mc.thePlayer.posX);
    498            l2 = MathHelper.floor_double(this.mc.thePlayer.posY);
    499            k2 = MathHelper.floor_double(this.mc.thePlayer.posZ);
    500            this.drawString(fontrenderer, String.format("x: %.5f (%d) // c: %d (%d)", new Object[] {Double.valueOf(this.mc.thePlayer.posX), Integer.valueOf(k3), Integer.valueOf(k3 >> 4), Integer.valueOf(k3 & 15)}), 2, 64, 14737632);
    501            this.drawString(fontrenderer, String.format("y: %.3f (feet pos, %.3f eyes pos)", new Object[] {Double.valueOf(this.mc.thePlayer.boundingBox.minY), Double.valueOf(this.mc.thePlayer.posY)}), 2, 72, 14737632);
    502            this.drawString(fontrenderer, String.format("z: %.5f (%d) // c: %d (%d)", new Object[] {Double.valueOf(this.mc.thePlayer.posZ), Integer.valueOf(k2), Integer.valueOf(k2 >> 4), Integer.valueOf(k2 & 15)}), 2, 80, 14737632);
    503            i3 = MathHelper.floor_double((double)(this.mc.thePlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
    504            this.drawString(fontrenderer, "f: " + i3 + " (" + Direction.directions[i3] + ") / " + MathHelper.wrapAngleTo180_float(this.mc.thePlayer.rotationYaw), 2, 88, 14737632);
    505
    506            if (this.mc.theWorld != null && this.mc.theWorld.blockExists(k3, l2, k2))
    507            {
    508                Chunk chunk = this.mc.theWorld.getChunkFromBlockCoords(k3, k2);
    509                this.drawString(fontrenderer, "lc: " + (chunk.getTopFilledSegment() + 15) + " b: " + chunk.getBiomeGenForWorldCoords(k3 & 15, k2 & 15, this.mc.theWorld.getWorldChunkManager()).biomeName + " bl: " + chunk.getSavedLightValue(EnumSkyBlock.Block, k3 & 15, l2, k2 & 15) + " sl: " + chunk.getSavedLightValue(EnumSkyBlock.Sky, k3 & 15, l2, k2 & 15) + " rl: " + chunk.getBlockLightValue(k3 & 15, l2, k2 & 15, 0), 2, 96, 14737632);
    510            }
    511
    512            this.drawString(fontrenderer, String.format("ws: %.3f, fs: %.3f, g: %b, fl: %d", new Object[] {Float.valueOf(this.mc.thePlayer.capabilities.getWalkSpeed()), Float.valueOf(this.mc.thePlayer.capabilities.getFlySpeed()), Boolean.valueOf(this.mc.thePlayer.onGround), Integer.valueOf(this.mc.theWorld.getHeightValue(k3, k2))}), 2, 104, 14737632);
    513            GL11.glPopMatrix();
    514            this.mc.mcProfiler.endSection();
    515        }
    516
    517        if (this.recordPlayingUpFor > 0)
    518        {
    519            this.mc.mcProfiler.startSection("overlayMessage");
    520            f2 = (float)this.recordPlayingUpFor - par1;
    521            i1 = (int)(f2 * 256.0F / 20.0F);
    522
    523            if (i1 > 255)
    524            {
    525                i1 = 255;
    526            }
    527
    528            if (i1 > 0)
    529            {
    530                GL11.glPushMatrix();
    531                GL11.glTranslatef((float)(k / 2), (float)(l - 48), 0.0F);
    532                GL11.glEnable(GL11.GL_BLEND);
    533                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    534                j1 = 16777215;
    535
    536                if (this.recordIsPlaying)
    537                {
    538                    j1 = Color.HSBtoRGB(f2 / 50.0F, 0.7F, 0.6F) & 16777215;
    539                }
    540
    541                fontrenderer.drawString(this.recordPlaying, -fontrenderer.getStringWidth(this.recordPlaying) / 2, -4, j1 + (i1 << 24));
    542                GL11.glDisable(GL11.GL_BLEND);
    543                GL11.glPopMatrix();
    544            }
    545
    546            this.mc.mcProfiler.endSection();
    547        }
    548
    549        ScoreObjective scoreobjective = this.mc.theWorld.getScoreboard().func_96539_a(1);
    550
    551        if (scoreobjective != null)
    552        {
    553            this.func_96136_a(scoreobjective, l, k, fontrenderer);
    554        }
    555
    556        GL11.glEnable(GL11.GL_BLEND);
    557        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    558        GL11.glDisable(GL11.GL_ALPHA_TEST);
    559        GL11.glPushMatrix();
    560        GL11.glTranslatef(0.0F, (float)(l - 48), 0.0F);
    561        this.mc.mcProfiler.startSection("chat");
    562        this.persistantChatGUI.drawChat(this.updateCounter);
    563        this.mc.mcProfiler.endSection();
    564        GL11.glPopMatrix();
    565        scoreobjective = this.mc.theWorld.getScoreboard().func_96539_a(0);
    566
    567        if (this.mc.gameSettings.keyBindPlayerList.pressed && (!this.mc.isIntegratedServerRunning() || this.mc.thePlayer.sendQueue.playerInfoList.size() > 1 || scoreobjective != null))
    568        {
    569            this.mc.mcProfiler.startSection("playerList");
    570            NetClientHandler netclienthandler = this.mc.thePlayer.sendQueue;
    571            List list = netclienthandler.playerInfoList;
    572            j5 = netclienthandler.currentServerMaxPlayers;
    573            k5 = j5;
    574
    575            for (l1 = 1; k5 > 20; k5 = (j5 + l1 - 1) / l1)
    576            {
    577                ++l1;
    578            }
    579
    580            k1 = 300 / l1;
    581
    582            if (k1 > 150)
    583            {
    584                k1 = 150;
    585            }
    586
    587            i2 = (k - l1 * k1) / 2;
    588            byte b3 = 10;
    589            drawRect(i2 - 1, b3 - 1, i2 + k1 * l1, b3 + 9 * k5, Integer.MIN_VALUE);
    590
    591            for (j2 = 0; j2 < j5; ++j2)
    592            {
    593                k3 = i2 + j2 % l1 * k1;
    594                l2 = b3 + j2 / l1 * 9;
    595                drawRect(k3, l2, k3 + k1 - 1, l2 + 8, 553648127);
    596                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    597                GL11.glEnable(GL11.GL_ALPHA_TEST);
    598
    599                if (j2 < list.size())
    600                {
    601                    GuiPlayerInfo guiplayerinfo = (GuiPlayerInfo)list.get(j2);
    602                    ScorePlayerTeam scoreplayerteam = this.mc.theWorld.getScoreboard().func_96509_i(guiplayerinfo.name);
    603                    String s3 = ScorePlayerTeam.func_96667_a(scoreplayerteam, guiplayerinfo.name);
    604                    fontrenderer.drawStringWithShadow(s3, k3, l2, 16777215);
    605
    606                    if (scoreobjective != null)
    607                    {
    608                        j3 = k3 + fontrenderer.getStringWidth(s3) + 5;
    609                        l3 = k3 + k1 - 12 - 5;
    610
    611                        if (l3 - j3 > 5)
    612                        {
    613                            Score score = scoreobjective.getScoreboard().func_96529_a(guiplayerinfo.name, scoreobjective);
    614                            String s4 = EnumChatFormatting.YELLOW + "" + score.func_96652_c();
    615                            fontrenderer.drawStringWithShadow(s4, l3 - fontrenderer.getStringWidth(s4), l2, 16777215);
    616                        }
    617                    }
    618
    619                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    620                    this.mc.renderEngine.bindTexture("/gui/icons.png");
    621                    byte b4 = 0;
    622                    boolean flag3 = false;
    623
    624                    if (guiplayerinfo.responseTime < 0)
    625                    {
    626                        b0 = 5;
    627                    }
    628                    else if (guiplayerinfo.responseTime < 150)
    629                    {
    630                        b0 = 0;
    631                    }
    632                    else if (guiplayerinfo.responseTime < 300)
    633                    {
    634                        b0 = 1;
    635                    }
    636                    else if (guiplayerinfo.responseTime < 600)
    637                    {
    638                        b0 = 2;
    639                    }
    640                    else if (guiplayerinfo.responseTime < 1000)
    641                    {
    642                        b0 = 3;
    643                    }
    644                    else
    645                    {
    646                        b0 = 4;
    647                    }
    648
    649                    this.zLevel += 100.0F;
    650                    this.drawTexturedModalRect(k3 + k1 - 12, l2, 0 + b4 * 10, 176 + b0 * 8, 10, 8);
    651                    this.zLevel -= 100.0F;
    652                }
    653            }
    654        }
    655
    656        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    657        GL11.glDisable(GL11.GL_LIGHTING);
    658        GL11.glEnable(GL11.GL_ALPHA_TEST);
    659    }
    660
    661    protected void func_96136_a(ScoreObjective par1ScoreObjective, int par2, int par3, FontRenderer par4FontRenderer)
    662    {
    663        Scoreboard scoreboard = par1ScoreObjective.getScoreboard();
    664        Collection collection = scoreboard.func_96534_i(par1ScoreObjective);
    665
    666        if (collection.size() <= 15)
    667        {
    668            int k = par4FontRenderer.getStringWidth(par1ScoreObjective.getDisplayName());
    669            String s;
    670
    671            for (Iterator iterator = collection.iterator(); iterator.hasNext(); k = Math.max(k, par4FontRenderer.getStringWidth(s)))
    672            {
    673                Score score = (Score)iterator.next();
    674                ScorePlayerTeam scoreplayerteam = scoreboard.func_96509_i(score.func_96653_e());
    675                s = ScorePlayerTeam.func_96667_a(scoreplayerteam, score.func_96653_e()) + ": " + EnumChatFormatting.RED + score.func_96652_c();
    676            }
    677
    678            int l = collection.size() * par4FontRenderer.FONT_HEIGHT;
    679            int i1 = par2 / 2 + l / 3;
    680            byte b0 = 3;
    681            int j1 = par3 - k - b0;
    682            int k1 = 0;
    683            Iterator iterator1 = collection.iterator();
    684
    685            while (iterator1.hasNext())
    686            {
    687                Score score1 = (Score)iterator1.next();
    688                ++k1;
    689                ScorePlayerTeam scoreplayerteam1 = scoreboard.func_96509_i(score1.func_96653_e());
    690                String s1 = ScorePlayerTeam.func_96667_a(scoreplayerteam1, score1.func_96653_e());
    691                String s2 = EnumChatFormatting.RED + "" + score1.func_96652_c();
    692                int l1 = i1 - k1 * par4FontRenderer.FONT_HEIGHT;
    693                int i2 = par3 - b0 + 2;
    694                drawRect(j1 - 2, l1, i2, l1 + par4FontRenderer.FONT_HEIGHT, 1342177280);
    695                par4FontRenderer.drawString(s1, j1, l1, 553648127);
    696                par4FontRenderer.drawString(s2, i2 - par4FontRenderer.getStringWidth(s2), l1, 553648127);
    697
    698                if (k1 == collection.size())
    699                {
    700                    String s3 = par1ScoreObjective.getDisplayName();
    701                    drawRect(j1 - 2, l1 - par4FontRenderer.FONT_HEIGHT - 1, i2, l1 - 1, 1610612736);
    702                    drawRect(j1 - 2, l1 - 1, i2, l1, 1342177280);
    703                    par4FontRenderer.drawString(s3, j1 + k / 2 - par4FontRenderer.getStringWidth(s3) / 2, l1 - par4FontRenderer.FONT_HEIGHT, 553648127);
    704                }
    705            }
    706        }
    707    }
    708
    709    /**
    710     * Renders dragon's (boss) health on the HUD
    711     */
    712    protected void renderBossHealth()
    713    {
    714        if (BossStatus.bossName != null && BossStatus.statusBarLength > 0)
    715        {
    716            --BossStatus.statusBarLength;
    717            FontRenderer fontrenderer = this.mc.fontRenderer;
    718            ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight);
    719            int i = scaledresolution.getScaledWidth();
    720            short short1 = 182;
    721            int j = i / 2 - short1 / 2;
    722            int k = (int)(BossStatus.healthScale * (float)(short1 + 1));
    723            byte b0 = 12;
    724            this.drawTexturedModalRect(j, b0, 0, 74, short1, 5);
    725            this.drawTexturedModalRect(j, b0, 0, 74, short1, 5);
    726
    727            if (k > 0)
    728            {
    729                this.drawTexturedModalRect(j, b0, 0, 79, k, 5);
    730            }
    731
    732            String s = BossStatus.bossName;
    733            fontrenderer.drawStringWithShadow(s, i / 2 - fontrenderer.getStringWidth(s) / 2, b0 - 10, 16777215);
    734            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    735            this.mc.renderEngine.bindTexture("/gui/icons.png");
    736        }
    737    }
    738
    739    protected void renderPumpkinBlur(int par1, int par2)
    740    {
    741        GL11.glDisable(GL11.GL_DEPTH_TEST);
    742        GL11.glDepthMask(false);
    743        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    744        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    745        GL11.glDisable(GL11.GL_ALPHA_TEST);
    746        this.mc.renderEngine.bindTexture("%blur%/misc/pumpkinblur.png");
    747        Tessellator tessellator = Tessellator.instance;
    748        tessellator.startDrawingQuads();
    749        tessellator.addVertexWithUV(0.0D, (double)par2, -90.0D, 0.0D, 1.0D);
    750        tessellator.addVertexWithUV((double)par1, (double)par2, -90.0D, 1.0D, 1.0D);
    751        tessellator.addVertexWithUV((double)par1, 0.0D, -90.0D, 1.0D, 0.0D);
    752        tessellator.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D);
    753        tessellator.draw();
    754        GL11.glDepthMask(true);
    755        GL11.glEnable(GL11.GL_DEPTH_TEST);
    756        GL11.glEnable(GL11.GL_ALPHA_TEST);
    757        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    758    }
    759
    760    /**
    761     * Renders the vignette. Args: vignetteBrightness, width, height
    762     */
    763    protected void renderVignette(float par1, int par2, int par3)
    764    {
    765        par1 = 1.0F - par1;
    766
    767        if (par1 < 0.0F)
    768        {
    769            par1 = 0.0F;
    770        }
    771
    772        if (par1 > 1.0F)
    773        {
    774            par1 = 1.0F;
    775        }
    776
    777        this.prevVignetteBrightness = (float)((double)this.prevVignetteBrightness + (double)(par1 - this.prevVignetteBrightness) * 0.01D);
    778        GL11.glDisable(GL11.GL_DEPTH_TEST);
    779        GL11.glDepthMask(false);
    780        GL11.glBlendFunc(GL11.GL_ZERO, GL11.GL_ONE_MINUS_SRC_COLOR);
    781        GL11.glColor4f(this.prevVignetteBrightness, this.prevVignetteBrightness, this.prevVignetteBrightness, 1.0F);
    782        this.mc.renderEngine.bindTexture("%blur%/misc/vignette.png");
    783        Tessellator tessellator = Tessellator.instance;
    784        tessellator.startDrawingQuads();
    785        tessellator.addVertexWithUV(0.0D, (double)par3, -90.0D, 0.0D, 1.0D);
    786        tessellator.addVertexWithUV((double)par2, (double)par3, -90.0D, 1.0D, 1.0D);
    787        tessellator.addVertexWithUV((double)par2, 0.0D, -90.0D, 1.0D, 0.0D);
    788        tessellator.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D);
    789        tessellator.draw();
    790        GL11.glDepthMask(true);
    791        GL11.glEnable(GL11.GL_DEPTH_TEST);
    792        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    793        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    794    }
    795
    796    /**
    797     * Renders the portal overlay. Args: portalStrength, width, height
    798     */
    799    protected void renderPortalOverlay(float par1, int par2, int par3)
    800    {
    801        if (par1 < 1.0F)
    802        {
    803            par1 *= par1;
    804            par1 *= par1;
    805            par1 = par1 * 0.8F + 0.2F;
    806        }
    807
    808        GL11.glDisable(GL11.GL_ALPHA_TEST);
    809        GL11.glDisable(GL11.GL_DEPTH_TEST);
    810        GL11.glDepthMask(false);
    811        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    812        GL11.glColor4f(1.0F, 1.0F, 1.0F, par1);
    813        this.mc.renderEngine.bindTexture("/terrain.png");
    814        Icon icon = Block.portal.getBlockTextureFromSide(1);
    815        float f1 = icon.getMinU();
    816        float f2 = icon.getMinV();
    817        float f3 = icon.getMaxU();
    818        float f4 = icon.getMaxV();
    819        Tessellator tessellator = Tessellator.instance;
    820        tessellator.startDrawingQuads();
    821        tessellator.addVertexWithUV(0.0D, (double)par3, -90.0D, (double)f1, (double)f4);
    822        tessellator.addVertexWithUV((double)par2, (double)par3, -90.0D, (double)f3, (double)f4);
    823        tessellator.addVertexWithUV((double)par2, 0.0D, -90.0D, (double)f3, (double)f2);
    824        tessellator.addVertexWithUV(0.0D, 0.0D, -90.0D, (double)f1, (double)f2);
    825        tessellator.draw();
    826        GL11.glDepthMask(true);
    827        GL11.glEnable(GL11.GL_DEPTH_TEST);
    828        GL11.glEnable(GL11.GL_ALPHA_TEST);
    829        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    830    }
    831
    832    /**
    833     * Renders the specified item of the inventory slot at the specified location. Args: slot, x, y, partialTick
    834     */
    835    protected void renderInventorySlot(int par1, int par2, int par3, float par4)
    836    {
    837        ItemStack itemstack = this.mc.thePlayer.inventory.mainInventory[par1];
    838
    839        if (itemstack != null)
    840        {
    841            float f1 = (float)itemstack.animationsToGo - par4;
    842
    843            if (f1 > 0.0F)
    844            {
    845                GL11.glPushMatrix();
    846                float f2 = 1.0F + f1 / 5.0F;
    847                GL11.glTranslatef((float)(par2 + 8), (float)(par3 + 12), 0.0F);
    848                GL11.glScalef(1.0F / f2, (f2 + 1.0F) / 2.0F, 1.0F);
    849                GL11.glTranslatef((float)(-(par2 + 8)), (float)(-(par3 + 12)), 0.0F);
    850            }
    851
    852            itemRenderer.renderItemAndEffectIntoGUI(this.mc.fontRenderer, this.mc.renderEngine, itemstack, par2, par3);
    853
    854            if (f1 > 0.0F)
    855            {
    856                GL11.glPopMatrix();
    857            }
    858
    859            itemRenderer.renderItemOverlayIntoGUI(this.mc.fontRenderer, this.mc.renderEngine, itemstack, par2, par3);
    860        }
    861    }
    862
    863    /**
    864     * The update tick for the ingame UI
    865     */
    866    public void updateTick()
    867    {
    868        if (this.recordPlayingUpFor > 0)
    869        {
    870            --this.recordPlayingUpFor;
    871        }
    872
    873        ++this.updateCounter;
    874
    875        if (this.mc.thePlayer != null)
    876        {
    877            ItemStack itemstack = this.mc.thePlayer.inventory.getCurrentItem();
    878
    879            if (itemstack == null)
    880            {
    881                this.field_92017_k = 0;
    882            }
    883            else if (this.field_92016_l != null && itemstack.itemID == this.field_92016_l.itemID && ItemStack.areItemStackTagsEqual(itemstack, this.field_92016_l) && (itemstack.isItemStackDamageable() || itemstack.getItemDamage() == this.field_92016_l.getItemDamage()))
    884            {
    885                if (this.field_92017_k > 0)
    886                {
    887                    --this.field_92017_k;
    888                }
    889            }
    890            else
    891            {
    892                this.field_92017_k = 40;
    893            }
    894
    895            this.field_92016_l = itemstack;
    896        }
    897    }
    898
    899    public void setRecordPlayingMessage(String par1Str)
    900    {
    901        this.recordPlaying = "Now playing: " + par1Str;
    902        this.recordPlayingUpFor = 60;
    903        this.recordIsPlaying = true;
    904    }
    905
    906    /**
    907     * returns a pointer to the persistant Chat GUI, containing all previous chat messages and such
    908     */
    909    public GuiNewChat getChatGUI()
    910    {
    911        return this.persistantChatGUI;
    912    }
    913
    914    public int getUpdateCounter()
    915    {
    916        return this.updateCounter;
    917    }
    918}