001    package net.minecraft.src;
002    
003    import cpw.mods.fml.common.Side;
004    import cpw.mods.fml.common.asm.SideOnly;
005    import java.util.Collection;
006    import java.util.Iterator;
007    import org.lwjgl.opengl.GL11;
008    
009    @SideOnly(Side.CLIENT)
010    public abstract class InventoryEffectRenderer extends GuiContainer
011    {
012        private boolean field_74222_o;
013    
014        public InventoryEffectRenderer(Container par1Container)
015        {
016            super(par1Container);
017        }
018    
019        /**
020         * Adds the buttons (and other controls) to the screen in question.
021         */
022        public void initGui()
023        {
024            super.initGui();
025    
026            if (!this.mc.thePlayer.getActivePotionEffects().isEmpty())
027            {
028                this.guiLeft = 160 + (this.width - this.xSize - 200) / 2;
029                this.field_74222_o = true;
030            }
031        }
032    
033        /**
034         * Draws the screen and all the components in it.
035         */
036        public void drawScreen(int par1, int par2, float par3)
037        {
038            super.drawScreen(par1, par2, par3);
039    
040            if (this.field_74222_o)
041            {
042                this.displayDebuffEffects();
043            }
044        }
045    
046        /**
047         * Displays debuff/potion effects that are currently being applied to the player
048         */
049        private void displayDebuffEffects()
050        {
051            int var1 = this.guiLeft - 124;
052            int var2 = this.guiTop;
053            Collection var4 = this.mc.thePlayer.getActivePotionEffects();
054    
055            if (!var4.isEmpty())
056            {
057                int var5 = this.mc.renderEngine.getTexture("/gui/inventory.png");
058                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
059                GL11.glDisable(GL11.GL_LIGHTING);
060                int var6 = 33;
061    
062                if (var4.size() > 5)
063                {
064                    var6 = 132 / (var4.size() - 1);
065                }
066    
067                for (Iterator var7 = this.mc.thePlayer.getActivePotionEffects().iterator(); var7.hasNext(); var2 += var6)
068                {
069                    PotionEffect var8 = (PotionEffect)var7.next();
070                    Potion var9 = Potion.potionTypes[var8.getPotionID()];
071                    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
072                    this.mc.renderEngine.bindTexture(var5);
073                    this.drawTexturedModalRect(var1, var2, 0, 166, 140, 32);
074    
075                    if (var9.hasStatusIcon())
076                    {
077                        int var10 = var9.getStatusIconIndex();
078                        this.drawTexturedModalRect(var1 + 6, var2 + 7, 0 + var10 % 8 * 18, 198 + var10 / 8 * 18, 18, 18);
079                    }
080    
081                    String var12 = StatCollector.translateToLocal(var9.getName());
082    
083                    if (var8.getAmplifier() == 1)
084                    {
085                        var12 = var12 + " II";
086                    }
087                    else if (var8.getAmplifier() == 2)
088                    {
089                        var12 = var12 + " III";
090                    }
091                    else if (var8.getAmplifier() == 3)
092                    {
093                        var12 = var12 + " IV";
094                    }
095    
096                    this.fontRenderer.drawStringWithShadow(var12, var1 + 10 + 18, var2 + 6, 16777215);
097                    String var11 = Potion.getDurationString(var8);
098                    this.fontRenderer.drawStringWithShadow(var11, var1 + 10 + 18, var2 + 6 + 10, 8355711);
099                }
100            }
101        }
102    }