001package net.minecraft.client.renderer; 002 003import cpw.mods.fml.relauncher.Side; 004import cpw.mods.fml.relauncher.SideOnly; 005import java.util.Collection; 006import java.util.Iterator; 007import net.minecraft.client.gui.inventory.GuiContainer; 008import net.minecraft.inventory.Container; 009import net.minecraft.potion.Potion; 010import net.minecraft.potion.PotionEffect; 011import net.minecraft.util.StatCollector; 012import org.lwjgl.opengl.GL11; 013 014@SideOnly(Side.CLIENT) 015public 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 i = this.guiLeft - 124; 057 int j = this.guiTop; 058 Collection collection = this.mc.thePlayer.getActivePotionEffects(); 059 060 if (!collection.isEmpty()) 061 { 062 GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); 063 GL11.glDisable(GL11.GL_LIGHTING); 064 int k = 33; 065 066 if (collection.size() > 5) 067 { 068 k = 132 / (collection.size() - 1); 069 } 070 071 for (Iterator iterator = this.mc.thePlayer.getActivePotionEffects().iterator(); iterator.hasNext(); j += k) 072 { 073 PotionEffect potioneffect = (PotionEffect)iterator.next(); 074 Potion potion = Potion.potionTypes[potioneffect.getPotionID()]; 075 GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); 076 this.mc.renderEngine.func_98187_b("/gui/inventory.png"); 077 this.drawTexturedModalRect(i, j, 0, 166, 140, 32); 078 079 if (potion.hasStatusIcon()) 080 { 081 int l = potion.getStatusIconIndex(); 082 this.drawTexturedModalRect(i + 6, j + 7, 0 + l % 8 * 18, 198 + l / 8 * 18, 18, 18); 083 } 084 085 String s = StatCollector.translateToLocal(potion.getName()); 086 087 if (potioneffect.getAmplifier() == 1) 088 { 089 s = s + " II"; 090 } 091 else if (potioneffect.getAmplifier() == 2) 092 { 093 s = s + " III"; 094 } 095 else if (potioneffect.getAmplifier() == 3) 096 { 097 s = s + " IV"; 098 } 099 100 this.fontRenderer.drawStringWithShadow(s, i + 10 + 18, j + 6, 16777215); 101 String s1 = Potion.getDurationString(potioneffect); 102 this.fontRenderer.drawStringWithShadow(s1, i + 10 + 18, j + 6 + 10, 8355711); 103 } 104 } 105 } 106}