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.EntityArrow; 008import net.minecraft.util.MathHelper; 009import org.lwjgl.opengl.GL11; 010import org.lwjgl.opengl.GL12; 011 012@SideOnly(Side.CLIENT) 013public class RenderArrow extends Render 014{ 015 public void renderArrow(EntityArrow par1EntityArrow, double par2, double par4, double par6, float par8, float par9) 016 { 017 this.loadTexture("/item/arrows.png"); 018 GL11.glPushMatrix(); 019 GL11.glTranslatef((float)par2, (float)par4, (float)par6); 020 GL11.glRotatef(par1EntityArrow.prevRotationYaw + (par1EntityArrow.rotationYaw - par1EntityArrow.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F); 021 GL11.glRotatef(par1EntityArrow.prevRotationPitch + (par1EntityArrow.rotationPitch - par1EntityArrow.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F); 022 Tessellator tessellator = Tessellator.instance; 023 byte b0 = 0; 024 float f2 = 0.0F; 025 float f3 = 0.5F; 026 float f4 = (float)(0 + b0 * 10) / 32.0F; 027 float f5 = (float)(5 + b0 * 10) / 32.0F; 028 float f6 = 0.0F; 029 float f7 = 0.15625F; 030 float f8 = (float)(5 + b0 * 10) / 32.0F; 031 float f9 = (float)(10 + b0 * 10) / 32.0F; 032 float f10 = 0.05625F; 033 GL11.glEnable(GL12.GL_RESCALE_NORMAL); 034 float f11 = (float)par1EntityArrow.arrowShake - par9; 035 036 if (f11 > 0.0F) 037 { 038 float f12 = -MathHelper.sin(f11 * 3.0F) * f11; 039 GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F); 040 } 041 042 GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F); 043 GL11.glScalef(f10, f10, f10); 044 GL11.glTranslatef(-4.0F, 0.0F, 0.0F); 045 GL11.glNormal3f(f10, 0.0F, 0.0F); 046 tessellator.startDrawingQuads(); 047 tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f8); 048 tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f8); 049 tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f9); 050 tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f9); 051 tessellator.draw(); 052 GL11.glNormal3f(-f10, 0.0F, 0.0F); 053 tessellator.startDrawingQuads(); 054 tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f8); 055 tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f8); 056 tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f9); 057 tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f9); 058 tessellator.draw(); 059 060 for (int i = 0; i < 4; ++i) 061 { 062 GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); 063 GL11.glNormal3f(0.0F, 0.0F, f10); 064 tessellator.startDrawingQuads(); 065 tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)f2, (double)f4); 066 tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)f3, (double)f4); 067 tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)f3, (double)f5); 068 tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)f2, (double)f5); 069 tessellator.draw(); 070 } 071 072 GL11.glDisable(GL12.GL_RESCALE_NORMAL); 073 GL11.glPopMatrix(); 074 } 075 076 /** 077 * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then 078 * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic 079 * (Render<T extends Entity) and this method has signature public void doRender(T entity, double d, double d1, 080 * double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. 081 */ 082 public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) 083 { 084 this.renderArrow((EntityArrow)par1Entity, par2, par4, par6, par8, par9); 085 } 086}