Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.17 KB | None | 0 0
  1. package so101.bricks;
  2.  
  3. import org.lwjgl.opengl.GL11;
  4. import org.lwjgl.opengl.GL12;
  5.  
  6. import cpw.mods.fml.relauncher.Side;
  7. import cpw.mods.fml.relauncher.SideOnly;
  8. import net.minecraft.client.renderer.Tessellator;
  9. import net.minecraft.client.renderer.entity.Render;
  10. import net.minecraft.entity.Entity;
  11. import net.minecraft.item.ItemStack;
  12. import net.minecraft.util.IIcon;
  13. import net.minecraft.util.ResourceLocation;
  14.  
  15. @SideOnly(Side.CLIENT)
  16. public class RenderBrick extends Render
  17. {
  18.     private ItemStack brick;
  19.  
  20.     public RenderBrick()
  21.     {
  22.         super();
  23.     }
  24.  
  25.     public void doRender(Entity eentity, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_)
  26.     {
  27.         EntityBrick entity = (EntityBrick)eentity;
  28.         this.brick = entity.entityItemStack;
  29.         IIcon iicon = this.brick.getIconIndex();
  30.        
  31.         if (iicon != null)
  32.         {
  33.             GL11.glPushMatrix();
  34.             GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_, (float)p_76986_6_);
  35.             GL11.glEnable(GL12.GL_RESCALE_NORMAL);
  36.             GL11.glScalef(0.5F, 0.5F, 0.5F);
  37.             //this.preRender(entity);
  38.             this.bindEntityTexture(entity);
  39.             Tessellator tessellator = Tessellator.instance;
  40.    
  41.             this.func_77026_a(tessellator, iicon);
  42.             GL11.glDisable(GL12.GL_RESCALE_NORMAL);
  43.             GL11.glPopMatrix();
  44.         }
  45.        
  46.     }
  47.    
  48.    
  49.     private void func_77026_a(Tessellator p_77026_1_, IIcon p_77026_2_)
  50.     {
  51.         float f = p_77026_2_.getMinU();
  52.         float f1 = p_77026_2_.getMaxU();
  53.         float f2 = p_77026_2_.getMinV();
  54.         float f3 = p_77026_2_.getMaxV();
  55.         float f4 = 1.0F;
  56.         float f5 = 0.5F;
  57.         float f6 = 0.25F;
  58.         GL11.glRotatef(180.0F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
  59.         GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
  60.         p_77026_1_.startDrawingQuads();
  61.         p_77026_1_.setNormal(0.0F, 1.0F, 0.0F);
  62.         p_77026_1_.addVertexWithUV((double)(0.0F - f5), (double)(0.0F - f6), 0.0D, (double)f, (double)f3);
  63.         p_77026_1_.addVertexWithUV((double)(f4 - f5), (double)(0.0F - f6), 0.0D, (double)f1, (double)f3);
  64.         p_77026_1_.addVertexWithUV((double)(f4 - f5), (double)(f4 - f6), 0.0D, (double)f1, (double)f2);
  65.         p_77026_1_.addVertexWithUV((double)(0.0F - f5), (double)(f4 - f6), 0.0D, (double)f, (double)f2);
  66.         p_77026_1_.draw();
  67.     }
  68.  
  69.      /**
  70.      * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
  71.      */
  72.     protected ResourceLocation getEntityTexture(Entity p_110775_1_)
  73.     {
  74.         //return TextureMap.locationItemsTexture;
  75.         return this.getEntityTexture((EntityBrick)p_110775_1_);
  76.     }
  77.    
  78.     protected ResourceLocation getEntityTexture(EntityBrick entity)
  79.     {
  80.         return this.renderManager.renderEngine.getResourceLocation(entity.brickType.brick.getSpriteNumber());
  81.     }
  82.    
  83.     /**Prerender method for entity. Used for scaling.*/
  84.     public void preRender(EntityBrick entity)
  85.     {
  86.         if (entity.getEntityData().getFloat("Scale") != 1.0F)
  87.         {
  88.             float scale = entity.getEntityData().getFloat("Scale");
  89.             GL11.glScalef(scale, scale, scale);
  90.         }
  91.     }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement