Advertisement
robin4002

RenderTestArrow

Jan 19th, 2014
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.39 KB | None | 0 0
  1. package tutoriel.client;
  2.  
  3. import net.minecraft.client.renderer.Tessellator;
  4. import net.minecraft.client.renderer.entity.RenderArrow;
  5. import net.minecraft.entity.Entity;
  6. import net.minecraft.util.MathHelper;
  7. import net.minecraft.util.ResourceLocation;
  8.  
  9. import org.lwjgl.opengl.GL11;
  10. import org.lwjgl.opengl.GL12;
  11.  
  12. import tutoriel.common.EntityTestArrow;
  13.  
  14. public class RenderTestArrow extends RenderArrow
  15. {
  16.     private static final ResourceLocation arrowTextures = new ResourceLocation("textures/entity/arrow.png");
  17.  
  18.     public void renderArrow(EntityTestArrow arrow, double par2, double par4, double par6, float par8, float par9)
  19.     {
  20.         this.bindEntityTexture(arrow);
  21.         GL11.glPushMatrix();
  22.         GL11.glTranslatef((float)par2, (float)par4, (float)par6);
  23.         GL11.glRotatef(arrow.prevRotationYaw + (arrow.rotationYaw - arrow.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F);
  24.         GL11.glRotatef(arrow.prevRotationPitch + (arrow.rotationPitch - arrow.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F);
  25.         Tessellator tessellator = Tessellator.instance;
  26.         byte b0 = 0;
  27.         float f2 = 0.0F;
  28.         float f3 = 0.5F;
  29.         float f4 = (float)(0 + b0 * 10) / 32.0F;
  30.         float f5 = (float)(5 + b0 * 10) / 32.0F;
  31.         float f6 = 0.0F;
  32.         float f7 = 0.15625F;
  33.         float f8 = (float)(5 + b0 * 10) / 32.0F;
  34.         float f9 = (float)(10 + b0 * 10) / 32.0F;
  35.         float f10 = 0.05625F;
  36.         GL11.glEnable(GL12.GL_RESCALE_NORMAL);
  37.         float f11 = (float)arrow.arrowShake - par9;
  38.  
  39.         if(f11 > 0.0F)
  40.         {
  41.             float f12 = -MathHelper.sin(f11 * 3.0F) * f11;
  42.             GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F);
  43.         }
  44.  
  45.         GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F);
  46.         GL11.glScalef(f10, f10, f10);
  47.         GL11.glTranslatef(-4.0F, 0.0F, 0.0F);
  48.         GL11.glNormal3f(f10, 0.0F, 0.0F);
  49.         tessellator.startDrawingQuads();
  50.         tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f8);
  51.         tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f8);
  52.         tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f9);
  53.         tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f9);
  54.         tessellator.draw();
  55.         GL11.glNormal3f(-f10, 0.0F, 0.0F);
  56.         tessellator.startDrawingQuads();
  57.         tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f8);
  58.         tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f8);
  59.         tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f9);
  60.         tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f9);
  61.         tessellator.draw();
  62.  
  63.         for(int i = 0; i < 4; ++i)
  64.         {
  65.             GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
  66.             GL11.glNormal3f(0.0F, 0.0F, f10);
  67.             tessellator.startDrawingQuads();
  68.             tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)f2, (double)f4);
  69.             tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)f3, (double)f4);
  70.             tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)f3, (double)f5);
  71.             tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)f2, (double)f5);
  72.             tessellator.draw();
  73.         }
  74.  
  75.         GL11.glDisable(GL12.GL_RESCALE_NORMAL);
  76.         GL11.glPopMatrix();
  77.     }
  78.  
  79.     protected ResourceLocation getArrowTextures(EntityTestArrow arrow)
  80.     {
  81.         return arrowTextures;
  82.     }
  83.  
  84.     protected ResourceLocation getEntityTexture(Entity entity)
  85.     {
  86.         return this.getArrowTextures((EntityTestArrow)entity);
  87.     }
  88.  
  89.     public void doRender(Entity entity, double par2, double par4, double par6, float par8, float par9)
  90.     {
  91.         this.renderArrow((EntityTestArrow)entity, par2, par4, par6, par8, par9);
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement