Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.80 KB | None | 0 0
  1.     //Most of the block is rendered by ISBRH
  2.     //Only the door (which animates) will be rendered with TESR like this.
  3.  
  4.     //Image 1: http://ctrlv.in/716615 - Correct, looking down
  5.     //Image 2: http://ctrlv.in/716616 - Look up a little and they bug out.
  6.  
  7.     @Override
  8.     public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float scale) {
  9.         LootCrateEntity te = (LootCrateEntity) tileEntity;
  10.         ItemStack item = te.getStackInSlot(1);
  11.        
  12.         //Rotation stuff removed for debug     
  13.         String uuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString();
  14.        
  15.         if (te.playerList.contains(uuid)) {
  16.             renderDoor(te, x, y, z, 135, true);
  17.         } else {
  18.             //More stuff removed for debug
  19.             renderDoor(te, x, y, z, 10, false);
  20.         }
  21.     }
  22.    
  23.     public void renderDoor(LootCrateEntity te, double x, double y, double z, float rotation, boolean open) {
  24.         GL11.glPushMatrix();
  25.         GL11.glTranslated(x, y, z);
  26.  
  27.         //Rotation && extra icons etc removed for debug
  28.        
  29.         IIcon icon = te.blockType.getIcon(8, 1);
  30.        
  31.         double u0 = (double) icon.getMinU();
  32.         double u1 = (double) icon.getMaxU();
  33.         double v0 = (double) icon.getMinV();
  34.         double v1 = (double) icon.getMaxV();
  35.        
  36.         tess.startDrawingQuads();
  37.         tess.addVertexWithUV(0.25, 0.499, 0.75,   u1, v1);
  38.         tess.addVertexWithUV(0.25, 0.499, 0.8125, u1, v0);
  39.         tess.addVertexWithUV(0.75, 0.499, 0.8125, u0, v0);
  40.         tess.addVertexWithUV(0.75, 0.499, 0.75,   u0, v1);
  41.        
  42.         tess.setColorOpaque(204, 204, 204);     //NORTH (inside)
  43.         tess.addVertexWithUV(0.75, 0.5, 0.75, u1, v1);
  44.         tess.addVertexWithUV(0.75, 0,   0.75, u1, v0);
  45.         tess.addVertexWithUV(0.25, 0,   0.75, u0, v0);
  46.         tess.addVertexWithUV(0.25, 0.5, 0.75, u0, v1);
  47.        
  48.         tess.setColorOpaque(153, 153, 153);     //EAST (right side)
  49.         tess.addVertexWithUV(0.75, 0.5, 0.8125, u1, v1);
  50.         tess.addVertexWithUV(0.75, 0,   0.8125, u1, v0);
  51.         tess.addVertexWithUV(0.75, 0,   0.75,   u0, v0);
  52.         tess.addVertexWithUV(0.75, 0.5, 0.75,   u0, v1);
  53.        
  54.         tess.setColorOpaque(204, 204, 204);     //SOUTH (outside)
  55.         tess.addVertexWithUV(0.25, 0.5, 0.8125, u1, v1);
  56.         tess.addVertexWithUV(0.25, 0,   0.8125, u1, v0);
  57.         tess.addVertexWithUV(0.75, 0,   0.8125, u0, v0);
  58.         tess.addVertexWithUV(0.75, 0.5, 0.8125, u0, v1);
  59.  
  60.         tess.setColorOpaque(153, 153, 153);     //WEST (left side)
  61.         tess.addVertexWithUV(0.25, 0.5, 0.75,   u1, v1);
  62.         tess.addVertexWithUV(0.25, 0,   0.75,   u1, v0);
  63.         tess.addVertexWithUV(0.25, 0,   0.8125, u0, v0);
  64.         tess.addVertexWithUV(0.25, 0.5, 0.8125, u0, v1);
  65.  
  66.         tess.setColorOpaque(128, 128, 128);     //BOTTOM
  67.         tess.addVertexWithUV(0.25, 0, 0.8125, u1, v1);
  68.         tess.addVertexWithUV(0.25, 0, 0.75,   u1, v0);
  69.         tess.addVertexWithUV(0.75, 0, 0.75,   u0, v0);
  70.         tess.addVertexWithUV(0.75, 0, 0.8125, u0, v1);
  71.        
  72.         tess.draw();
  73.         GL11.glPopMatrix();
  74.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement