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 { /** True if there is some potion effect to display */ private boolean hasActivePotionEffects; private static final String __OBFID = "CL_00000755"; public InventoryEffectRenderer(Container p_i1089_1_) { super(p_i1089_1_); } /** * Adds the buttons (and other controls) to the screen in question. */ public void initGui() { super.initGui(); if (!this.mc.thePlayer.getActivePotionEffects().isEmpty()) { this.guiLeft = 160 + (this.width - this.xSize - 200) / 2; this.hasActivePotionEffects = true; } } /** * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks */ public void drawScreen(int mouseX, int mouseY, float partialTicks) { super.drawScreen(mouseX, mouseY, partialTicks); if (this.hasActivePotionEffects) { this.drawActivePotionEffects(); } } /** * Display the potion effects list */ private void drawActivePotionEffects() { 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(inventoryBackground); 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); } potion.renderInventoryEffect(i, j, potioneffect, mc); if (!potion.shouldRenderInvText(potioneffect)) continue; String s1 = I18n.format(potion.getName(), new Object[0]); if (potioneffect.getAmplifier() == 1) { s1 = s1 + " " + I18n.format("enchantment.level.2", new Object[0]); } else if (potioneffect.getAmplifier() == 2) { s1 = s1 + " " + I18n.format("enchantment.level.3", new Object[0]); } else if (potioneffect.getAmplifier() == 3) { s1 = s1 + " " + I18n.format("enchantment.level.4", new Object[0]); } 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); } } } }