001 package net.minecraft.src;
002
003 import cpw.mods.fml.common.Side;
004 import cpw.mods.fml.common.asm.SideOnly;
005 import org.lwjgl.opengl.GL11;
006 import org.lwjgl.opengl.GL12;
007
008 @SideOnly(Side.CLIENT)
009 public class RenderSnowball extends Render
010 {
011 /**
012 * Have the icon index (in items.png) that will be used to render the image. Currently, eggs and snowballs uses this
013 * classes.
014 */
015 private int itemIconIndex;
016
017 public RenderSnowball(int par1)
018 {
019 this.itemIconIndex = par1;
020 }
021
022 /**
023 * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
024 * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
025 * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
026 * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
027 */
028 public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
029 {
030 GL11.glPushMatrix();
031 GL11.glTranslatef((float)par2, (float)par4, (float)par6);
032 GL11.glEnable(GL12.GL_RESCALE_NORMAL);
033 GL11.glScalef(0.5F, 0.5F, 0.5F);
034 this.loadTexture("/gui/items.png");
035 Tessellator var10 = Tessellator.instance;
036
037 if (this.itemIconIndex == 154)
038 {
039 int var11 = PotionHelper.func_77915_a(((EntityPotion)par1Entity).getPotionDamage(), false);
040 float var12 = (float)(var11 >> 16 & 255) / 255.0F;
041 float var13 = (float)(var11 >> 8 & 255) / 255.0F;
042 float var14 = (float)(var11 & 255) / 255.0F;
043 GL11.glColor3f(var12, var13, var14);
044 GL11.glPushMatrix();
045 this.func_77026_a(var10, 141);
046 GL11.glPopMatrix();
047 GL11.glColor3f(1.0F, 1.0F, 1.0F);
048 }
049
050 this.func_77026_a(var10, this.itemIconIndex);
051 GL11.glDisable(GL12.GL_RESCALE_NORMAL);
052 GL11.glPopMatrix();
053 }
054
055 private void func_77026_a(Tessellator par1Tessellator, int par2)
056 {
057 float var3 = (float)(par2 % 16 * 16 + 0) / 256.0F;
058 float var4 = (float)(par2 % 16 * 16 + 16) / 256.0F;
059 float var5 = (float)(par2 / 16 * 16 + 0) / 256.0F;
060 float var6 = (float)(par2 / 16 * 16 + 16) / 256.0F;
061 float var7 = 1.0F;
062 float var8 = 0.5F;
063 float var9 = 0.25F;
064 GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
065 GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
066 par1Tessellator.startDrawingQuads();
067 par1Tessellator.setNormal(0.0F, 1.0F, 0.0F);
068 par1Tessellator.addVertexWithUV((double)(0.0F - var8), (double)(0.0F - var9), 0.0D, (double)var3, (double)var6);
069 par1Tessellator.addVertexWithUV((double)(var7 - var8), (double)(0.0F - var9), 0.0D, (double)var4, (double)var6);
070 par1Tessellator.addVertexWithUV((double)(var7 - var8), (double)(var7 - var9), 0.0D, (double)var4, (double)var5);
071 par1Tessellator.addVertexWithUV((double)(0.0F - var8), (double)(var7 - var9), 0.0D, (double)var3, (double)var5);
072 par1Tessellator.draw();
073 }
074 }