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.bindTexture("/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.bindTexture("/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 font = field_92016_l.getItem().getFontRenderer(field_92016_l);
437                    if (font != null)
438                    {
439                        i1 = (k - font.getStringWidth(s1)) / 2;
440                        font.drawStringWithShadow(s1, i1, j1, 16777215 + (j5 << 24));
441                    }
442                    else
443                    {
444                        fontrenderer.drawStringWithShadow(s1, i1, j1, 16777215 + (j5 << 24));
445                    }
446                    GL11.glDisable(GL11.GL_BLEND);
447                    GL11.glPopMatrix();
448                }
449            }
450
451            this.mc.mcProfiler.endSection();
452        }
453
454        if (this.mc.isDemo())
455        {
456            this.mc.mcProfiler.startSection("demo");
457            s1 = "";
458
459            if (this.mc.theWorld.getTotalWorldTime() >= 120500L)
460            {
461                s1 = StatCollector.translateToLocal("demo.demoExpired");
462            }
463            else
464            {
465                s1 = String.format(StatCollector.translateToLocal("demo.remainingTime"), new Object[] {StringUtils.ticksToElapsedTime((int)(120500L - this.mc.theWorld.getTotalWorldTime()))});
466            }
467
468            i1 = fontrenderer.getStringWidth(s1);
469            fontrenderer.drawStringWithShadow(s1, k - i1 - 10, 5, 16777215);
470            this.mc.mcProfiler.endSection();
471        }
472
473        if (this.mc.gameSettings.showDebugInfo)
474        {
475            this.mc.mcProfiler.startSection("debug");
476            GL11.glPushMatrix();
477            fontrenderer.drawStringWithShadow("Minecraft 1.5.1 (" + this.mc.debug + ")", 2, 2, 16777215);
478            fontrenderer.drawStringWithShadow(this.mc.debugInfoRenders(), 2, 12, 16777215);
479            fontrenderer.drawStringWithShadow(this.mc.getEntityDebug(), 2, 22, 16777215);
480            fontrenderer.drawStringWithShadow(this.mc.debugInfoEntities(), 2, 32, 16777215);
481            fontrenderer.drawStringWithShadow(this.mc.getWorldProviderName(), 2, 42, 16777215);
482            long l5 = Runtime.getRuntime().maxMemory();
483            long i6 = Runtime.getRuntime().totalMemory();
484            long j6 = Runtime.getRuntime().freeMemory();
485            long k6 = i6 - j6;
486            String s2 = "Used memory: " + k6 * 100L / l5 + "% (" + k6 / 1024L / 1024L + "MB) of " + l5 / 1024L / 1024L + "MB";
487            this.drawString(fontrenderer, s2, k - fontrenderer.getStringWidth(s2) - 2, 2, 14737632);
488            s2 = "Allocated memory: " + i6 * 100L / l5 + "% (" + i6 / 1024L / 1024L + "MB)";
489            this.drawString(fontrenderer, s2, k - fontrenderer.getStringWidth(s2) - 2, 12, 14737632);
490            k3 = MathHelper.floor_double(this.mc.thePlayer.posX);
491            l2 = MathHelper.floor_double(this.mc.thePlayer.posY);
492            k2 = MathHelper.floor_double(this.mc.thePlayer.posZ);
493            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);
494            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);
495            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);
496            i3 = MathHelper.floor_double((double)(this.mc.thePlayer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
497            this.drawString(fontrenderer, "f: " + i3 + " (" + Direction.directions[i3] + ") / " + MathHelper.wrapAngleTo180_float(this.mc.thePlayer.rotationYaw), 2, 88, 14737632);
498
499            if (this.mc.theWorld != null && this.mc.theWorld.blockExists(k3, l2, k2))
500            {
501                Chunk chunk = this.mc.theWorld.getChunkFromBlockCoords(k3, k2);
502                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);
503            }
504
505            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);
506            GL11.glPopMatrix();
507            this.mc.mcProfiler.endSection();
508        }
509
510        if (this.recordPlayingUpFor > 0)
511        {
512            this.mc.mcProfiler.startSection("overlayMessage");
513            f2 = (float)this.recordPlayingUpFor - par1;
514            i1 = (int)(f2 * 256.0F / 20.0F);
515
516            if (i1 > 255)
517            {
518                i1 = 255;
519            }
520
521            if (i1 > 0)
522            {
523                GL11.glPushMatrix();
524                GL11.glTranslatef((float)(k / 2), (float)(l - 48), 0.0F);
525                GL11.glEnable(GL11.GL_BLEND);
526                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
527                j1 = 16777215;
528
529                if (this.recordIsPlaying)
530                {
531                    j1 = Color.HSBtoRGB(f2 / 50.0F, 0.7F, 0.6F) & 16777215;
532                }
533
534                fontrenderer.drawString(this.recordPlaying, -fontrenderer.getStringWidth(this.recordPlaying) / 2, -4, j1 + (i1 << 24));
535                GL11.glDisable(GL11.GL_BLEND);
536                GL11.glPopMatrix();
537            }
538
539            this.mc.mcProfiler.endSection();
540        }
541
542        ScoreObjective scoreobjective = this.mc.theWorld.getScoreboard().func_96539_a(1);
543
544        if (scoreobjective != null)
545        {
546            this.func_96136_a(scoreobjective, l, k, fontrenderer);
547        }
548
549        GL11.glEnable(GL11.GL_BLEND);
550        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
551        GL11.glDisable(GL11.GL_ALPHA_TEST);
552        GL11.glPushMatrix();
553        GL11.glTranslatef(0.0F, (float)(l - 48), 0.0F);
554        this.mc.mcProfiler.startSection("chat");
555        this.persistantChatGUI.drawChat(this.updateCounter);
556        this.mc.mcProfiler.endSection();
557        GL11.glPopMatrix();
558        scoreobjective = this.mc.theWorld.getScoreboard().func_96539_a(0);
559
560        if (this.mc.gameSettings.keyBindPlayerList.pressed && (!this.mc.isIntegratedServerRunning() || this.mc.thePlayer.sendQueue.playerInfoList.size() > 1 || scoreobjective != null))
561        {
562            this.mc.mcProfiler.startSection("playerList");
563            NetClientHandler netclienthandler = this.mc.thePlayer.sendQueue;
564            List list = netclienthandler.playerInfoList;
565            j5 = netclienthandler.currentServerMaxPlayers;
566            k5 = j5;
567
568            for (l1 = 1; k5 > 20; k5 = (j5 + l1 - 1) / l1)
569            {
570                ++l1;
571            }
572
573            k1 = 300 / l1;
574
575            if (k1 > 150)
576            {
577                k1 = 150;
578            }
579
580            i2 = (k - l1 * k1) / 2;
581            byte b3 = 10;
582            drawRect(i2 - 1, b3 - 1, i2 + k1 * l1, b3 + 9 * k5, Integer.MIN_VALUE);
583
584            for (j2 = 0; j2 < j5; ++j2)
585            {
586                k3 = i2 + j2 % l1 * k1;
587                l2 = b3 + j2 / l1 * 9;
588                drawRect(k3, l2, k3 + k1 - 1, l2 + 8, 553648127);
589                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
590                GL11.glEnable(GL11.GL_ALPHA_TEST);
591
592                if (j2 < list.size())
593                {
594                    GuiPlayerInfo guiplayerinfo = (GuiPlayerInfo)list.get(j2);
595                    ScorePlayerTeam scoreplayerteam = this.mc.theWorld.getScoreboard().func_96509_i(guiplayerinfo.name);
596                    String s3 = ScorePlayerTeam.func_96667_a(scoreplayerteam, guiplayerinfo.name);
597                    fontrenderer.drawStringWithShadow(s3, k3, l2, 16777215);
598
599                    if (scoreobjective != null)
600                    {
601                        j3 = k3 + fontrenderer.getStringWidth(s3) + 5;
602                        l3 = k3 + k1 - 12 - 5;
603
604                        if (l3 - j3 > 5)
605                        {
606                            Score score = scoreobjective.func_96682_a().func_96529_a(guiplayerinfo.name, scoreobjective);
607                            String s4 = EnumChatFormatting.YELLOW + "" + score.func_96652_c();
608                            fontrenderer.drawStringWithShadow(s4, l3 - fontrenderer.getStringWidth(s4), l2, 16777215);
609                        }
610                    }
611
612                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
613                    this.mc.renderEngine.bindTexture("/gui/icons.png");
614                    byte b4 = 0;
615                    boolean flag3 = false;
616
617                    if (guiplayerinfo.responseTime < 0)
618                    {
619                        b0 = 5;
620                    }
621                    else if (guiplayerinfo.responseTime < 150)
622                    {
623                        b0 = 0;
624                    }
625                    else if (guiplayerinfo.responseTime < 300)
626                    {
627                        b0 = 1;
628                    }
629                    else if (guiplayerinfo.responseTime < 600)
630                    {
631                        b0 = 2;
632                    }
633                    else if (guiplayerinfo.responseTime < 1000)
634                    {
635                        b0 = 3;
636                    }
637                    else
638                    {
639                        b0 = 4;
640                    }
641
642                    this.zLevel += 100.0F;
643                    this.drawTexturedModalRect(k3 + k1 - 12, l2, 0 + b4 * 10, 176 + b0 * 8, 10, 8);
644                    this.zLevel -= 100.0F;
645                }
646            }
647        }
648
649        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
650        GL11.glDisable(GL11.GL_LIGHTING);
651        GL11.glEnable(GL11.GL_ALPHA_TEST);
652    }
653
654    private void func_96136_a(ScoreObjective par1ScoreObjective, int par2, int par3, FontRenderer par4FontRenderer)
655    {
656        Scoreboard scoreboard = par1ScoreObjective.func_96682_a();
657        Collection collection = scoreboard.func_96534_i(par1ScoreObjective);
658
659        if (collection.size() <= 15)
660        {
661            int k = par4FontRenderer.getStringWidth(par1ScoreObjective.func_96678_d());
662            String s;
663
664            for (Iterator iterator = collection.iterator(); iterator.hasNext(); k = Math.max(k, par4FontRenderer.getStringWidth(s)))
665            {
666                Score score = (Score)iterator.next();
667                ScorePlayerTeam scoreplayerteam = scoreboard.func_96509_i(score.func_96653_e());
668                s = ScorePlayerTeam.func_96667_a(scoreplayerteam, score.func_96653_e()) + ": " + EnumChatFormatting.RED + score.func_96652_c();
669            }
670
671            int l = collection.size() * par4FontRenderer.FONT_HEIGHT;
672            int i1 = par2 / 2 + l / 3;
673            byte b0 = 3;
674            int j1 = par3 - k - b0;
675            int k1 = 0;
676            Iterator iterator1 = collection.iterator();
677
678            while (iterator1.hasNext())
679            {
680                Score score1 = (Score)iterator1.next();
681                ++k1;
682                ScorePlayerTeam scoreplayerteam1 = scoreboard.func_96509_i(score1.func_96653_e());
683                String s1 = ScorePlayerTeam.func_96667_a(scoreplayerteam1, score1.func_96653_e());
684                String s2 = EnumChatFormatting.RED + "" + score1.func_96652_c();
685                int l1 = i1 - k1 * par4FontRenderer.FONT_HEIGHT;
686                int i2 = par3 - b0 + 2;
687                drawRect(j1 - 2, l1, i2, l1 + par4FontRenderer.FONT_HEIGHT, 1342177280);
688                par4FontRenderer.drawString(s1, j1, l1, 553648127);
689                par4FontRenderer.drawString(s2, i2 - par4FontRenderer.getStringWidth(s2), l1, 553648127);
690
691                if (k1 == collection.size())
692                {
693                    String s3 = par1ScoreObjective.func_96678_d();
694                    drawRect(j1 - 2, l1 - par4FontRenderer.FONT_HEIGHT - 1, i2, l1 - 1, 1610612736);
695                    drawRect(j1 - 2, l1 - 1, i2, l1, 1342177280);
696                    par4FontRenderer.drawString(s3, j1 + k / 2 - par4FontRenderer.getStringWidth(s3) / 2, l1 - par4FontRenderer.FONT_HEIGHT, 553648127);
697                }
698            }
699        }
700    }
701
702    /**
703     * Renders dragon's (boss) health on the HUD
704     */
705    private void renderBossHealth()
706    {
707        if (BossStatus.bossName != null && BossStatus.statusBarLength > 0)
708        {
709            --BossStatus.statusBarLength;
710            FontRenderer fontrenderer = this.mc.fontRenderer;
711            ScaledResolution scaledresolution = new ScaledResolution(this.mc.gameSettings, this.mc.displayWidth, this.mc.displayHeight);
712            int i = scaledresolution.getScaledWidth();
713            short short1 = 182;
714            int j = i / 2 - short1 / 2;
715            int k = (int)(BossStatus.healthScale * (float)(short1 + 1));
716            byte b0 = 12;
717            this.drawTexturedModalRect(j, b0, 0, 74, short1, 5);
718            this.drawTexturedModalRect(j, b0, 0, 74, short1, 5);
719
720            if (k > 0)
721            {
722                this.drawTexturedModalRect(j, b0, 0, 79, k, 5);
723            }
724
725            String s = BossStatus.bossName;
726            fontrenderer.drawStringWithShadow(s, i / 2 - fontrenderer.getStringWidth(s) / 2, b0 - 10, 16777215);
727            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
728            this.mc.renderEngine.bindTexture("/gui/icons.png");
729        }
730    }
731
732    private void renderPumpkinBlur(int par1, int par2)
733    {
734        GL11.glDisable(GL11.GL_DEPTH_TEST);
735        GL11.glDepthMask(false);
736        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
737        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
738        GL11.glDisable(GL11.GL_ALPHA_TEST);
739        this.mc.renderEngine.bindTexture("%blur%/misc/pumpkinblur.png");
740        Tessellator tessellator = Tessellator.instance;
741        tessellator.startDrawingQuads();
742        tessellator.addVertexWithUV(0.0D, (double)par2, -90.0D, 0.0D, 1.0D);
743        tessellator.addVertexWithUV((double)par1, (double)par2, -90.0D, 1.0D, 1.0D);
744        tessellator.addVertexWithUV((double)par1, 0.0D, -90.0D, 1.0D, 0.0D);
745        tessellator.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D);
746        tessellator.draw();
747        GL11.glDepthMask(true);
748        GL11.glEnable(GL11.GL_DEPTH_TEST);
749        GL11.glEnable(GL11.GL_ALPHA_TEST);
750        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
751    }
752
753    /**
754     * Renders the vignette. Args: vignetteBrightness, width, height
755     */
756    private void renderVignette(float par1, int par2, int par3)
757    {
758        par1 = 1.0F - par1;
759
760        if (par1 < 0.0F)
761        {
762            par1 = 0.0F;
763        }
764
765        if (par1 > 1.0F)
766        {
767            par1 = 1.0F;
768        }
769
770        this.prevVignetteBrightness = (float)((double)this.prevVignetteBrightness + (double)(par1 - this.prevVignetteBrightness) * 0.01D);
771        GL11.glDisable(GL11.GL_DEPTH_TEST);
772        GL11.glDepthMask(false);
773        GL11.glBlendFunc(GL11.GL_ZERO, GL11.GL_ONE_MINUS_SRC_COLOR);
774        GL11.glColor4f(this.prevVignetteBrightness, this.prevVignetteBrightness, this.prevVignetteBrightness, 1.0F);
775        this.mc.renderEngine.bindTexture("%blur%/misc/vignette.png");
776        Tessellator tessellator = Tessellator.instance;
777        tessellator.startDrawingQuads();
778        tessellator.addVertexWithUV(0.0D, (double)par3, -90.0D, 0.0D, 1.0D);
779        tessellator.addVertexWithUV((double)par2, (double)par3, -90.0D, 1.0D, 1.0D);
780        tessellator.addVertexWithUV((double)par2, 0.0D, -90.0D, 1.0D, 0.0D);
781        tessellator.addVertexWithUV(0.0D, 0.0D, -90.0D, 0.0D, 0.0D);
782        tessellator.draw();
783        GL11.glDepthMask(true);
784        GL11.glEnable(GL11.GL_DEPTH_TEST);
785        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
786        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
787    }
788
789    /**
790     * Renders the portal overlay. Args: portalStrength, width, height
791     */
792    private void renderPortalOverlay(float par1, int par2, int par3)
793    {
794        if (par1 < 1.0F)
795        {
796            par1 *= par1;
797            par1 *= par1;
798            par1 = par1 * 0.8F + 0.2F;
799        }
800
801        GL11.glDisable(GL11.GL_ALPHA_TEST);
802        GL11.glDisable(GL11.GL_DEPTH_TEST);
803        GL11.glDepthMask(false);
804        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
805        GL11.glColor4f(1.0F, 1.0F, 1.0F, par1);
806        this.mc.renderEngine.bindTexture("/terrain.png");
807        Icon icon = Block.portal.getBlockTextureFromSide(1);
808        float f1 = icon.getMinU();
809        float f2 = icon.getMinV();
810        float f3 = icon.getMaxU();
811        float f4 = icon.getMaxV();
812        Tessellator tessellator = Tessellator.instance;
813        tessellator.startDrawingQuads();
814        tessellator.addVertexWithUV(0.0D, (double)par3, -90.0D, (double)f1, (double)f4);
815        tessellator.addVertexWithUV((double)par2, (double)par3, -90.0D, (double)f3, (double)f4);
816        tessellator.addVertexWithUV((double)par2, 0.0D, -90.0D, (double)f3, (double)f2);
817        tessellator.addVertexWithUV(0.0D, 0.0D, -90.0D, (double)f1, (double)f2);
818        tessellator.draw();
819        GL11.glDepthMask(true);
820        GL11.glEnable(GL11.GL_DEPTH_TEST);
821        GL11.glEnable(GL11.GL_ALPHA_TEST);
822        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
823    }
824
825    /**
826     * Renders the specified item of the inventory slot at the specified location. Args: slot, x, y, partialTick
827     */
828    private void renderInventorySlot(int par1, int par2, int par3, float par4)
829    {
830        ItemStack itemstack = this.mc.thePlayer.inventory.mainInventory[par1];
831
832        if (itemstack != null)
833        {
834            float f1 = (float)itemstack.animationsToGo - par4;
835
836            if (f1 > 0.0F)
837            {
838                GL11.glPushMatrix();
839                float f2 = 1.0F + f1 / 5.0F;
840                GL11.glTranslatef((float)(par2 + 8), (float)(par3 + 12), 0.0F);
841                GL11.glScalef(1.0F / f2, (f2 + 1.0F) / 2.0F, 1.0F);
842                GL11.glTranslatef((float)(-(par2 + 8)), (float)(-(par3 + 12)), 0.0F);
843            }
844
845            itemRenderer.renderItemAndEffectIntoGUI(this.mc.fontRenderer, this.mc.renderEngine, itemstack, par2, par3);
846
847            if (f1 > 0.0F)
848            {
849                GL11.glPopMatrix();
850            }
851
852            itemRenderer.renderItemOverlayIntoGUI(this.mc.fontRenderer, this.mc.renderEngine, itemstack, par2, par3);
853        }
854    }
855
856    /**
857     * The update tick for the ingame UI
858     */
859    public void updateTick()
860    {
861        if (this.recordPlayingUpFor > 0)
862        {
863            --this.recordPlayingUpFor;
864        }
865
866        ++this.updateCounter;
867
868        if (this.mc.thePlayer != null)
869        {
870            ItemStack itemstack = this.mc.thePlayer.inventory.getCurrentItem();
871
872            if (itemstack == null)
873            {
874                this.field_92017_k = 0;
875            }
876            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()))
877            {
878                if (this.field_92017_k > 0)
879                {
880                    --this.field_92017_k;
881                }
882            }
883            else
884            {
885                this.field_92017_k = 40;
886            }
887
888            this.field_92016_l = itemstack;
889        }
890    }
891
892    public void setRecordPlayingMessage(String par1Str)
893    {
894        this.recordPlaying = "Now playing: " + par1Str;
895        this.recordPlayingUpFor = 60;
896        this.recordIsPlaying = true;
897    }
898
899    /**
900     * returns a pointer to the persistant Chat GUI, containing all previous chat messages and such
901     */
902    public GuiNewChat getChatGUI()
903    {
904        return this.persistantChatGUI;
905    }
906
907    public int getUpdateCounter()
908    {
909        return this.updateCounter;
910    }
911}