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