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 b0 = 1;
027        byte b1 = 2;
028        this.loadTexture("/particles.png");
029        Tessellator tessellator = Tessellator.instance;
030        float f2 = (float)(b0 * 8 + 0) / 128.0F;
031        float f3 = (float)(b0 * 8 + 8) / 128.0F;
032        float f4 = (float)(b1 * 8 + 0) / 128.0F;
033        float f5 = (float)(b1 * 8 + 8) / 128.0F;
034        float f6 = 1.0F;
035        float f7 = 0.5F;
036        float f8 = 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        tessellator.startDrawingQuads();
040        tessellator.setNormal(0.0F, 1.0F, 0.0F);
041        tessellator.addVertexWithUV((double)(0.0F - f7), (double)(0.0F - f8), 0.0D, (double)f2, (double)f5);
042        tessellator.addVertexWithUV((double)(f6 - f7), (double)(0.0F - f8), 0.0D, (double)f3, (double)f5);
043        tessellator.addVertexWithUV((double)(f6 - f7), (double)(1.0F - f8), 0.0D, (double)f3, (double)f4);
044        tessellator.addVertexWithUV((double)(0.0F - f7), (double)(1.0F - f8), 0.0D, (double)f2, (double)f4);
045        tessellator.draw();
046        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
047        GL11.glPopMatrix();
048
049        if (par1EntityFishHook.angler != null)
050        {
051            float f9 = par1EntityFishHook.angler.getSwingProgress(par9);
052            float f10 = MathHelper.sin(MathHelper.sqrt_float(f9) * (float)Math.PI);
053            Vec3 vec3 = par1EntityFishHook.worldObj.getWorldVec3Pool().getVecFromPool(-0.5D, 0.03D, 0.8D);
054            vec3.rotateAroundX(-(par1EntityFishHook.angler.prevRotationPitch + (par1EntityFishHook.angler.rotationPitch - par1EntityFishHook.angler.prevRotationPitch) * par9) * (float)Math.PI / 180.0F);
055            vec3.rotateAroundY(-(par1EntityFishHook.angler.prevRotationYaw + (par1EntityFishHook.angler.rotationYaw - par1EntityFishHook.angler.prevRotationYaw) * par9) * (float)Math.PI / 180.0F);
056            vec3.rotateAroundY(f10 * 0.5F);
057            vec3.rotateAroundX(-f10 * 0.7F);
058            double d3 = par1EntityFishHook.angler.prevPosX + (par1EntityFishHook.angler.posX - par1EntityFishHook.angler.prevPosX) * (double)par9 + vec3.xCoord;
059            double d4 = par1EntityFishHook.angler.prevPosY + (par1EntityFishHook.angler.posY - par1EntityFishHook.angler.prevPosY) * (double)par9 + vec3.yCoord;
060            double d5 = par1EntityFishHook.angler.prevPosZ + (par1EntityFishHook.angler.posZ - par1EntityFishHook.angler.prevPosZ) * (double)par9 + vec3.zCoord;
061            double d6 = 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 f11 = (par1EntityFishHook.angler.prevRenderYawOffset + (par1EntityFishHook.angler.renderYawOffset - par1EntityFishHook.angler.prevRenderYawOffset) * par9) * (float)Math.PI / 180.0F;
066                double d7 = (double)MathHelper.sin(f11);
067                double d8 = (double)MathHelper.cos(f11);
068                d3 = par1EntityFishHook.angler.prevPosX + (par1EntityFishHook.angler.posX - par1EntityFishHook.angler.prevPosX) * (double)par9 - d8 * 0.35D - d7 * 0.85D;
069                d4 = par1EntityFishHook.angler.prevPosY + d6 + (par1EntityFishHook.angler.posY - par1EntityFishHook.angler.prevPosY) * (double)par9 - 0.45D;
070                d5 = par1EntityFishHook.angler.prevPosZ + (par1EntityFishHook.angler.posZ - par1EntityFishHook.angler.prevPosZ) * (double)par9 - d7 * 0.35D + d8 * 0.85D;
071            }
072
073            double d9 = par1EntityFishHook.prevPosX + (par1EntityFishHook.posX - par1EntityFishHook.prevPosX) * (double)par9;
074            double d10 = par1EntityFishHook.prevPosY + (par1EntityFishHook.posY - par1EntityFishHook.prevPosY) * (double)par9 + 0.25D;
075            double d11 = par1EntityFishHook.prevPosZ + (par1EntityFishHook.posZ - par1EntityFishHook.prevPosZ) * (double)par9;
076            double d12 = (double)((float)(d3 - d9));
077            double d13 = (double)((float)(d4 - d10));
078            double d14 = (double)((float)(d5 - d11));
079            GL11.glDisable(GL11.GL_TEXTURE_2D);
080            GL11.glDisable(GL11.GL_LIGHTING);
081            tessellator.startDrawing(3);
082            tessellator.setColorOpaque_I(0);
083            byte b2 = 16;
084
085            for (int i = 0; i <= b2; ++i)
086            {
087                float f12 = (float)i / (float)b2;
088                tessellator.addVertex(par2 + d12 * (double)f12, par4 + d13 * (double)(f12 * f12 + f12) * 0.5D + 0.25D, par6 + d14 * (double)f12);
089            }
090
091            tessellator.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}