Advertisement
Superloup10

Render2

Feb 28th, 2015
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 12.09 KB | None | 0 0
  1. /*******************************************************************************
  2.  * Copyright (c) 2014, Superloup10
  3.  *
  4.  * Wolf's Addons is distributed under the terms of the Minecraft Mod Public
  5.  * License 1.0, or MMPL. Please check the contents of the license located in
  6.  * https://www.dropbox.com/s/6l16rc7b1aks211/MMPL-1.0.txt
  7.  ******************************************************************************/
  8. package wolf.addons.client.render;
  9.  
  10. import net.minecraft.client.renderer.Tessellator;
  11. import net.minecraft.client.renderer.WorldRenderer;
  12. import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
  13. import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
  14. import net.minecraft.tileentity.TileEntity;
  15. import net.minecraft.util.EnumFacing;
  16. import net.minecraft.util.ResourceLocation;
  17.  
  18. import org.lwjgl.opengl.GL11;
  19.  
  20. import wolf.addons.common.tileentity.TileEntityCable;
  21.  
  22. public class TESRCable extends TileEntitySpecialRenderer
  23. {
  24.     // private static final ModelCable model = new ModelCable();
  25.     // private static final ModelCable2 model2 = new ModelCable2();
  26.     // private static final ResourceLocation texture = new ResourceLocation("wolf_addons:textures/blocks/cable.png");
  27.     // private static final ResourceLocation texture2 = new ResourceLocation("wolf_addons:textures/blocks/cable2.png");
  28.     private static final ResourceLocation texture = new ResourceLocation("wolf_addons:textures/blocks/cable1.png");
  29.     private boolean drawInside = true;
  30.     private float pixel = 1F / 16F;
  31.     private float pixel_texture = 1F / 32F;
  32.  
  33.     public TESRCable()
  34.     {
  35.         this.setRendererDispatcher(TileEntityRendererDispatcher.instance);
  36.     }
  37.  
  38.     @Override
  39.     public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale, int p_180535_9_)
  40.     {
  41.         GL11.glTranslated(x, y, z);
  42.         GL11.glDisable(GL11.GL_LIGHTING);
  43.         this.bindTexture(texture);
  44.         this.renderCore((TileEntityCable)te);
  45.         GL11.glEnable(GL11.GL_LIGHTING);
  46.         GL11.glTranslated(-x, -y, -z);
  47.         /*
  48.          * TileEntityCable tileEntity = (TileEntityCable)te; if(tileEntity.render[0])// South this.renderDirectional((TileEntityCable)te, x, y, z, scale, 0F); if(tileEntity.render[1])// North this.renderDirectional((TileEntityCable)te, x, y, z, scale, 180F); if(tileEntity.render[2])// West this.renderDirectional((TileEntityCable)te, x, y, z, scale, 270F); if(tileEntity.render[3])// East
  49.          * this.renderDirectional((TileEntityCable)te, x, y, z, scale, 90F); if(tileEntity.render[4])// Down this.renderDirectionalAxeNegY((TileEntityCable)te, x, y, z, scale); if(tileEntity.render[5])// Up this.renderDirectionalAxePosY((TileEntityCable)te, x, y, z, scale); this.renderCore((TileEntityCable)te, x, y, z, scale, p_180535_9_);
  50.          */
  51.     }
  52.  
  53.     /*
  54.      * private void renderDirectionalAxePosY(TileEntityCable te, double x, double y, double z, float scale) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.5D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F); GL11.glTranslatef(0.0F, -1.3103F, -0.69F); this.bindTexture(texture2); model2.renderAll(); GL11.glPopMatrix(); } private void
  55.      * renderDirectionalAxeNegY(TileEntityCable te, double x, double y, double z, float scale) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.5D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F); GL11.glScalef(1.0F, 1.0F, 1.05F); GL11.glTranslatef(0.0F, -1.313F, -1.24F); this.bindTexture(texture2); model2.renderAll(); GL11.glPopMatrix(); } private
  56.      * void renderDirectional(TileEntityCable te, double x, double y, double z, float scale, float angle) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.55D, y + 1.5D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(angle, 0.0F, 1.0F, 0.0F); this.bindTexture(texture2); model2.renderAll(); GL11.glPopMatrix(); }
  57.      */
  58.  
  59.     private void renderDirectional(EnumFacing direction)
  60.     {
  61.         switch(direction)
  62.         {
  63.         case NORTH:
  64.             break;
  65.         case SOUTH:
  66.             break;
  67.         case UP:
  68.             break;
  69.         case DOWN:
  70.             break;
  71.         case WEST:
  72.             break;
  73.         case EAST:
  74.             break;
  75.         }
  76.  
  77.         Tessellator tessellator = Tessellator.getInstance();
  78.         WorldRenderer worldrenderer = tessellator.getWorldRenderer();
  79.         worldrenderer.startDrawingQuads();
  80.         {
  81.  
  82.         }
  83.         tessellator.draw();
  84.     }
  85.  
  86.     private void renderCore(TileEntityCable te/* , double x, double y, double z, float scale, int p_180535_9_ */)
  87.     {
  88.         Tessellator tessellator = Tessellator.getInstance();
  89.         WorldRenderer worldrenderer = tessellator.getWorldRenderer();
  90.         worldrenderer.startDrawingQuads();
  91.         {
  92.             worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 11 * pixel / 2, 1 - 11 * pixel / 2, 5 * pixel_texture, 5 * pixel_texture);
  93.             worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 5 * pixel_texture, 0 * pixel_texture);
  94.             worldrenderer.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 0 * pixel_texture, 0 * pixel_texture);
  95.             worldrenderer.addVertexWithUV(11 * pixel / 2, 11 * pixel / 2, 1 - 11 * pixel / 2, 0 * pixel_texture, 5 * pixel_texture);
  96.  
  97.             worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 11 * pixel / 2, 11 * pixel / 2, 5 * pixel_texture, 5 * pixel_texture);
  98.             worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 5 * pixel_texture, 0 * pixel_texture);
  99.             worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 0 * pixel_texture, 0 * pixel_texture);
  100.             worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 11 * pixel / 2, 1 - 11 * pixel / 2, 0 * pixel_texture, 5 * pixel_texture);
  101.  
  102.             worldrenderer.addVertexWithUV(11 * pixel / 2, 11 * pixel / 2, 11 * pixel / 2, 5 * pixel_texture, 5 * pixel_texture);
  103.             worldrenderer.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 5 * pixel_texture, 0 * pixel_texture);
  104.             worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 0 * pixel_texture, 0 * pixel_texture);
  105.             worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 11 * pixel / 2, 11 * pixel / 2, 0 * pixel_texture, 5 * pixel_texture);
  106.  
  107.             worldrenderer.addVertexWithUV(11 * pixel / 2, 11 * pixel / 2, 1 - 11 * pixel / 2, 5 * pixel_texture, 5 * pixel_texture);
  108.             worldrenderer.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 5 * pixel_texture, 0 * pixel_texture);
  109.             worldrenderer.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 0 * pixel_texture, 0 * pixel_texture);
  110.             worldrenderer.addVertexWithUV(11 * pixel / 2, 11 * pixel / 2, 11 * pixel / 2, 0 * pixel_texture, 5 * pixel_texture);
  111.  
  112.             worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 5 * pixel_texture, 5 * pixel_texture);
  113.             worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 5 * pixel_texture, 0 * pixel_texture);
  114.             worldrenderer.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 0 * pixel_texture, 0 * pixel_texture);
  115.             worldrenderer.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 0 * pixel_texture, 5 * pixel_texture);
  116.  
  117.             worldrenderer.addVertexWithUV(11 * pixel / 2, 11 * pixel / 2, 1 - 11 * pixel / 2, 5 * pixel_texture, 5 * pixel_texture);
  118.             worldrenderer.addVertexWithUV(11 * pixel / 2, 11 * pixel / 2, 11 * pixel / 2, 5 * pixel_texture, 0 * pixel_texture);
  119.             worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 11 * pixel / 2, 11 * pixel / 2, 0 * pixel_texture, 0 * pixel_texture);
  120.             worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 11 * pixel / 2, 1 - 11 * pixel / 2, 0 * pixel_texture, 5 * pixel_texture);
  121.  
  122.             if(drawInside)
  123.             {
  124.                 worldrenderer.addVertexWithUV(11 * pixel / 2, 11 * pixel / 2, 1 - 11 * pixel / 2, 0 * pixel_texture, 5 * pixel_texture);
  125.                 worldrenderer.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 0 * pixel_texture, 0 * pixel_texture);
  126.                 worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 11 * pixel / 2, 1 - 11 * pixel / 2, 5 * pixel_texture, 5 * pixel_texture);
  127.                 worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 5 * pixel_texture, 0 * pixel_texture);
  128.  
  129.                 worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 11 * pixel / 2, 1 - 11 * pixel / 2, 0 * pixel_texture, 5 * pixel_texture);
  130.                 worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 0 * pixel_texture, 0 * pixel_texture);
  131.                 worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 5 * pixel_texture, 0 * pixel_texture);
  132.                 worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 11 * pixel / 2, 11 * pixel / 2, 5 * pixel_texture, 5 * pixel_texture);
  133.  
  134.                 worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 11 * pixel / 2, 11 * pixel / 2, 0 * pixel_texture, 5 * pixel_texture);
  135.                 worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 0 * pixel_texture, 0 * pixel_texture);
  136.                 worldrenderer.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 5 * pixel_texture, 0 * pixel_texture);
  137.                 worldrenderer.addVertexWithUV(11 * pixel / 2, 11 * pixel / 2, 11 * pixel / 2, 5 * pixel_texture, 5 * pixel_texture);
  138.  
  139.                 worldrenderer.addVertexWithUV(11 * pixel / 2, 11 * pixel / 2, 1 - 11 * pixel / 2, 5 * pixel_texture, 5 * pixel_texture);
  140.                 worldrenderer.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 5 * pixel_texture, 0 * pixel_texture);
  141.                 worldrenderer.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 0 * pixel_texture, 0 * pixel_texture);
  142.                 worldrenderer.addVertexWithUV(11 * pixel / 2, 11 * pixel / 2, 11 * pixel / 2, 0 * pixel_texture, 5 * pixel_texture);
  143.  
  144.                 worldrenderer.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 0 * pixel_texture, 5 * pixel_texture);
  145.                 worldrenderer.addVertexWithUV(11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 0 * pixel_texture, 0 * pixel_texture);
  146.                 worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 11 * pixel / 2, 5 * pixel_texture, 0 * pixel_texture);
  147.                 worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 1 - 11 * pixel / 2, 5 * pixel_texture, 5 * pixel_texture);
  148.  
  149.                 worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 11 * pixel / 2, 1 - 11 * pixel / 2, 0 * pixel_texture, 5 * pixel_texture);
  150.                 worldrenderer.addVertexWithUV(1 - 11 * pixel / 2, 11 * pixel / 2, 11 * pixel / 2, 0 * pixel_texture, 0 * pixel_texture);
  151.                 worldrenderer.addVertexWithUV(11 * pixel / 2, 11 * pixel / 2, 11 * pixel / 2, 5 * pixel_texture, 0 * pixel_texture);
  152.                 worldrenderer.addVertexWithUV(11 * pixel / 2, 11 * pixel / 2, 1 - 11 * pixel / 2, 5 * pixel_texture, 5 * pixel_texture);
  153.             }
  154.         }
  155.         tessellator.draw();
  156.         /*
  157.          * GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.5D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(0F, 0.0F, 1.0F, 1.0F); this.bindTexture(texture); model.renderAll(); GL11.glPopMatrix();
  158.          */
  159.     }
  160.  
  161.     private void drawVertex(WorldRenderer worldrenderer, double x, double y, double u, double v)
  162.     {
  163.         x = 11 * pixel / 2;
  164.         y = 1 - 11 * pixel / 2;
  165.         u = 5 * pixel_texture;
  166.         v = 0 * pixel_texture;
  167.         worldrenderer.addVertexWithUV(y, x, y, u, u);
  168.         worldrenderer.addVertexWithUV(y, y, y, u, v);
  169.         worldrenderer.addVertexWithUV(x, y, y, v, v);
  170.         worldrenderer.addVertexWithUV(x, y, y, v, u);
  171.     }
  172. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement