package net.minecraft.client.renderer;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Collection;
import java.util.Iterator;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.inventory.Container;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import org.lwjgl.opengl.GL11;

@SideOnly(Side.CLIENT)
public abstract class InventoryEffectRenderer extends GuiContainer
{
	private boolean field_147045_u;
	private static final String __OBFID = "CL_00000755";

	public InventoryEffectRenderer(Container par1Container)
	{
		super(par1Container);
	}

	public void initGui()
	{
		super.initGui();

		if (!this.mc.thePlayer.getActivePotionEffects().isEmpty())
		{
			this.guiLeft = 160 + (this.width - this.xSize - 200) / 2;
			this.field_147045_u = true;
		}
	}

	public void drawScreen(int par1, int par2, float par3)
	{
		super.drawScreen(par1, par2, par3);

		if (this.field_147045_u)
		{
			this.func_147044_g();
		}
	}

	private void func_147044_g()
	{
		int i = this.guiLeft - 124;
		int j = this.guiTop;
		boolean flag = true;
		Collection collection = this.mc.thePlayer.getActivePotionEffects();

		if (!collection.isEmpty())
		{
			GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
			GL11.glDisable(GL11.GL_LIGHTING);
			int k = 33;

			if (collection.size() > 5)
			{
				k = 132 / (collection.size() - 1);
			}

			for (Iterator iterator = this.mc.thePlayer.getActivePotionEffects().iterator(); iterator.hasNext(); j += k)
			{
				PotionEffect potioneffect = (PotionEffect)iterator.next();
				Potion potion = Potion.potionTypes[potioneffect.getPotionID()];
				GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
				this.mc.getTextureManager().bindTexture(field_147001_a);
				this.drawTexturedModalRect(i, j, 0, 166, 140, 32);

				if (potion.hasStatusIcon())
				{
					int l = potion.getStatusIconIndex();
					this.drawTexturedModalRect(i + 6, j + 7, 0 + l % 8 * 18, 198 + l / 8 * 18, 18, 18);
				}

				String s1 = I18n.format(potion.getName(), new Object[0]);

				if (potioneffect.getAmplifier() == 1)
				{
					s1 = s1 + " II";
				}
				else if (potioneffect.getAmplifier() == 2)
				{
					s1 = s1 + " III";
				}
				else if (potioneffect.getAmplifier() == 3)
				{
					s1 = s1 + " IV";
				}

				this.fontRendererObj.drawStringWithShadow(s1, i + 10 + 18, j + 6, 16777215);
				String s = Potion.getDurationString(potioneffect);
				this.fontRendererObj.drawStringWithShadow(s, i + 10 + 18, j + 6 + 10, 8355711);
			}
		}
	}
}