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