001package net.minecraft.client.renderer.entity; 002 003import cpw.mods.fml.relauncher.Side; 004import cpw.mods.fml.relauncher.SideOnly; 005import net.minecraft.client.renderer.Tessellator; 006import net.minecraft.entity.Entity; 007import net.minecraft.entity.projectile.EntityPotion; 008import net.minecraft.item.Item; 009import net.minecraft.item.ItemPotion; 010import net.minecraft.potion.PotionHelper; 011import net.minecraft.util.Icon; 012import org.lwjgl.opengl.GL11; 013import org.lwjgl.opengl.GL12; 014 015@SideOnly(Side.CLIENT) 016public class RenderSnowball extends Render 017{ 018 private Item field_94151_a; 019 private int field_94150_f; 020 021 public RenderSnowball(Item par1, int par2) 022 { 023 this.field_94151_a = par1; 024 this.field_94150_f = par2; 025 } 026 027 public RenderSnowball(Item par1) 028 { 029 this(par1, 0); 030 } 031 032 /** 033 * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then 034 * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic 035 * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1, 036 * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. 037 */ 038 public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) 039 { 040 Icon icon = this.field_94151_a.getIconFromDamage(this.field_94150_f); 041 042 if (icon != null) 043 { 044 GL11.glPushMatrix(); 045 GL11.glTranslatef((float)par2, (float)par4, (float)par6); 046 GL11.glEnable(GL12.GL_RESCALE_NORMAL); 047 GL11.glScalef(0.5F, 0.5F, 0.5F); 048 this.loadTexture("/gui/items.png"); 049 Tessellator tessellator = Tessellator.instance; 050 051 if (icon == ItemPotion.func_94589_d("potion_splash")) 052 { 053 int i = PotionHelper.func_77915_a(((EntityPotion)par1Entity).getPotionDamage(), false); 054 float f2 = (float)(i >> 16 & 255) / 255.0F; 055 float f3 = (float)(i >> 8 & 255) / 255.0F; 056 float f4 = (float)(i & 255) / 255.0F; 057 GL11.glColor3f(f2, f3, f4); 058 GL11.glPushMatrix(); 059 this.func_77026_a(tessellator, ItemPotion.func_94589_d("potion_contents")); 060 GL11.glPopMatrix(); 061 GL11.glColor3f(1.0F, 1.0F, 1.0F); 062 } 063 064 this.func_77026_a(tessellator, icon); 065 GL11.glDisable(GL12.GL_RESCALE_NORMAL); 066 GL11.glPopMatrix(); 067 } 068 } 069 070 private void func_77026_a(Tessellator par1Tessellator, Icon par2Icon) 071 { 072 float f = par2Icon.getMinU(); 073 float f1 = par2Icon.getMaxU(); 074 float f2 = par2Icon.getMinV(); 075 float f3 = par2Icon.getMaxV(); 076 float f4 = 1.0F; 077 float f5 = 0.5F; 078 float f6 = 0.25F; 079 GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F); 080 GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F); 081 par1Tessellator.startDrawingQuads(); 082 par1Tessellator.setNormal(0.0F, 1.0F, 0.0F); 083 par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3); 084 par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3); 085 par1Tessellator.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2); 086 par1Tessellator.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2); 087 par1Tessellator.draw(); 088 } 089}