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