    001package net.minecraft.client.renderer.entity;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import net.minecraft.client.Minecraft;
    006import net.minecraft.client.renderer.Tessellator;
    007import net.minecraft.entity.Entity;
    008import net.minecraft.entity.projectile.EntityFishHook;
    009import net.minecraft.util.MathHelper;
    010import net.minecraft.util.Vec3;
    011import org.lwjgl.opengl.GL11;
    012import org.lwjgl.opengl.GL12;
    013
    014@SideOnly(Side.CLIENT)
    015public class RenderFish extends Render
    016{
    017    /**
    018     * Actually renders the fishing line and hook
    019     */
    020    public void doRenderFishHook(EntityFishHook par1EntityFishHook, double par2, double par4, double par6, float par8, float par9)
    021    {
    022        GL11.glPushMatrix();
    023        GL11.glTranslatef((float)par2, (float)par4, (float)par6);
    024        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    025        GL11.glScalef(0.5F, 0.5F, 0.5F);
    026        byte var10 = 1;
    027        byte var11 = 2;
    028        this.loadTexture("/particles.png");
    029        Tessellator var12 = Tessellator.instance;
    030        float var13 = (float)(var10 * 8 + 0) / 128.0F;
    031        float var14 = (float)(var10 * 8 + 8) / 128.0F;
    032        float var15 = (float)(var11 * 8 + 0) / 128.0F;
    033        float var16 = (float)(var11 * 8 + 8) / 128.0F;
    034        float var17 = 1.0F;
    035        float var18 = 0.5F;
    036        float var19 = 0.5F;
    037        GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    038        GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
    039        var12.startDrawingQuads();
    040        var12.setNormal(0.0F, 1.0F, 0.0F);
    041        var12.addVertexWithUV((double)(0.0F - var18), (double)(0.0F - var19), 0.0D, (double)var13, (double)var16);
    042        var12.addVertexWithUV((double)(var17 - var18), (double)(0.0F - var19), 0.0D, (double)var14, (double)var16);
    043        var12.addVertexWithUV((double)(var17 - var18), (double)(1.0F - var19), 0.0D, (double)var14, (double)var15);
    044        var12.addVertexWithUV((double)(0.0F - var18), (double)(1.0F - var19), 0.0D, (double)var13, (double)var15);
    045        var12.draw();
    046        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    047        GL11.glPopMatrix();
    048
    049        if (par1EntityFishHook.angler != null)
    050        {
    051            float var20 = par1EntityFishHook.angler.getSwingProgress(par9);
    052            float var21 = MathHelper.sin(MathHelper.sqrt_float(var20) * (float)Math.PI);
    053            Vec3 var22 = par1EntityFishHook.worldObj.getWorldVec3Pool().getVecFromPool(-0.5D, 0.03D, 0.8D);
    054            var22.rotateAroundX(-(par1EntityFishHook.angler.prevRotationPitch + (par1EntityFishHook.angler.rotationPitch - par1EntityFishHook.angler.prevRotationPitch) * par9) * (float)Math.PI / 180.0F);
    055            var22.rotateAroundY(-(par1EntityFishHook.angler.prevRotationYaw + (par1EntityFishHook.angler.rotationYaw - par1EntityFishHook.angler.prevRotationYaw) * par9) * (float)Math.PI / 180.0F);
    056            var22.rotateAroundY(var21 * 0.5F);
    057            var22.rotateAroundX(-var21 * 0.7F);
    058            double var23 = par1EntityFishHook.angler.prevPosX + (par1EntityFishHook.angler.posX - par1EntityFishHook.angler.prevPosX) * (double)par9 + var22.xCoord;
    059            double var25 = par1EntityFishHook.angler.prevPosY + (par1EntityFishHook.angler.posY - par1EntityFishHook.angler.prevPosY) * (double)par9 + var22.yCoord;
    060            double var27 = par1EntityFishHook.angler.prevPosZ + (par1EntityFishHook.angler.posZ - par1EntityFishHook.angler.prevPosZ) * (double)par9 + var22.zCoord;
    061            double var29 = par1EntityFishHook.angler != Minecraft.getMinecraft().thePlayer ? (double)par1EntityFishHook.angler.getEyeHeight() : 0.0D;
    062
    063            if (this.renderManager.options.thirdPersonView > 0 || par1EntityFishHook.angler != Minecraft.getMinecraft().thePlayer)
    064            {
    065                float var31 = (par1EntityFishHook.angler.prevRenderYawOffset + (par1EntityFishHook.angler.renderYawOffset - par1EntityFishHook.angler.prevRenderYawOffset) * par9) * (float)Math.PI / 180.0F;
    066                double var32 = (double)MathHelper.sin(var31);
    067                double var34 = (double)MathHelper.cos(var31);
    068                var23 = par1EntityFishHook.angler.prevPosX + (par1EntityFishHook.angler.posX - par1EntityFishHook.angler.prevPosX) * (double)par9 - var34 * 0.35D - var32 * 0.85D;
    069                var25 = par1EntityFishHook.angler.prevPosY + var29 + (par1EntityFishHook.angler.posY - par1EntityFishHook.angler.prevPosY) * (double)par9 - 0.45D;
    070                var27 = par1EntityFishHook.angler.prevPosZ + (par1EntityFishHook.angler.posZ - par1EntityFishHook.angler.prevPosZ) * (double)par9 - var32 * 0.35D + var34 * 0.85D;
    071            }
    072
    073            double var46 = par1EntityFishHook.prevPosX + (par1EntityFishHook.posX - par1EntityFishHook.prevPosX) * (double)par9;
    074            double var33 = par1EntityFishHook.prevPosY + (par1EntityFishHook.posY - par1EntityFishHook.prevPosY) * (double)par9 + 0.25D;
    075            double var35 = par1EntityFishHook.prevPosZ + (par1EntityFishHook.posZ - par1EntityFishHook.prevPosZ) * (double)par9;
    076            double var37 = (double)((float)(var23 - var46));
    077            double var39 = (double)((float)(var25 - var33));
    078            double var41 = (double)((float)(var27 - var35));
    079            GL11.glDisable(GL11.GL_TEXTURE_2D);
    080            GL11.glDisable(GL11.GL_LIGHTING);
    081            var12.startDrawing(3);
    082            var12.setColorOpaque_I(0);
    083            byte var43 = 16;
    084
    085            for (int var44 = 0; var44 <= var43; ++var44)
    086            {
    087                float var45 = (float)var44 / (float)var43;
    088                var12.addVertex(par2 + var37 * (double)var45, par4 + var39 * (double)(var45 * var45 + var45) * 0.5D + 0.25D, par6 + var41 * (double)var45);
    089            }
    090
    091            var12.draw();
    092            GL11.glEnable(GL11.GL_LIGHTING);
    093            GL11.glEnable(GL11.GL_TEXTURE_2D);
    094        }
    095    }
    096
    097    /**
    098     * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then
    099     * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic
    100     * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1,
    101     * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that.
    102     */
    103    public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9)
    104    {
    105        this.doRenderFishHook((EntityFishHook)par1Entity, par2, par4, par6, par8, par9);
    106    }
    107}