Advertisement
Guest User

Untitled

a guest
Oct 20th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.16 KB | None | 0 0
  1.     @Override
  2.     public void renderTileEntityAt(TileEntityQuarry te, double xIn, double yIn, double zIn, float partialTicks, int destroyStage)
  3.     {
  4.        super.renderTileEntityAt(te, xIn, yIn, zIn, partialTicks, destroyStage);
  5.  
  6.        EntityPlayer entityplayer = Minecraft.getMinecraft().thePlayer;
  7.        BlockPos start = te.getStart();
  8.        BlockPos end = te.getEnd();
  9.        BlockPos current = te.getCurrent();
  10.        Tessellator tes = Tessellator.getInstance();
  11.        VertexBuffer buff = tes.getBuffer();
  12.  
  13.        Random rnd = new Random((long)(xIn + yIn + zIn));
  14.  
  15.        float r = 1.0f;//rnd.nextFloat();
  16.        float g = 0.0f;//rnd.nextFloat();
  17.        float b = 0.0f;//rnd.nextFloat();
  18.  
  19.        double driftX = entityplayer.lastTickPosX + (entityplayer.posX - entityplayer.lastTickPosX) * (double)partialTicks;
  20.        double driftY = entityplayer.lastTickPosY + (entityplayer.posY - entityplayer.lastTickPosY) * (double)partialTicks;
  21.        double driftZ = entityplayer.lastTickPosZ + (entityplayer.posZ - entityplayer.lastTickPosZ) * (double)partialTicks;
  22.        double yMin = (double)(current.getY()) - driftY;
  23.        double yMax = (double)(end.getY()+1) - driftY;
  24.        double xMin = (double)(start.getX() < end.getX() ? start.getX() : end.getX()) - driftX;
  25.        double zMin = (double)(start.getZ() < end.getZ() ? start.getZ() : end.getZ()) - driftZ;
  26.        int xSize = Math.abs(start.getX() - end.getX());
  27.        int zSize = Math.abs(start.getZ() - end.getZ());
  28.  
  29.        GlStateManager.disableTexture2D();
  30.        GlStateManager.disableBlend();
  31.        GlStateManager.glLineWidth(1.0F);
  32.        buff.begin(3, DefaultVertexFormats.POSITION_COLOR);
  33.  
  34.        int step = 2;
  35.        for (int j = step; j <= xSize; j += step)
  36.        {
  37.            double xOff = xMin + j;
  38.            //North Face
  39.            buff.pos(xOff, yMin, zMin        ).color(r, g, b, 0.0F).endVertex();
  40.            buff.pos(xOff, yMin, zMin        ).color(r, g, b, 1.0F).endVertex();
  41.            buff.pos(xOff, yMax, zMin        ).color(r, g, b, 1.0F).endVertex();
  42.            buff.pos(xOff, yMax, zMin        ).color(r, g, b, 0.0F).endVertex();
  43.            //South Face
  44.            buff.pos(xOff, yMin, zMin + 16.0D).color(r, g, b, 0.0F).endVertex();
  45.            buff.pos(xOff, yMin, zMin + 16.0D).color(r, g, b, 1.0F).endVertex();
  46.            buff.pos(xOff, yMax, zMin + 16.0D).color(r, g, b, 1.0F).endVertex();
  47.            buff.pos(xOff, yMax, zMin + 16.0D).color(r, g, b, 0.0F).endVertex();
  48.        }
  49.  
  50.        for (int j = step; j <= zSize; j += step)
  51.        {
  52.            double zOff = zMin + j;
  53.            //West Face
  54.            buff.pos(xMin,         yMin, zOff).color(r, g, b, 0.0F).endVertex();
  55.            buff.pos(xMin,         yMin, zOff).color(r, g, b, 1.0F).endVertex();
  56.            buff.pos(xMin,         yMax, zOff).color(r, g, b, 1.0F).endVertex();
  57.            buff.pos(xMin,         yMax, zOff).color(r, g, b, 0.0F).endVertex();
  58.            //East Face
  59.            buff.pos(xMin + 16.0D, yMin, zOff).color(r, g, b, 0.0F).endVertex();
  60.            buff.pos(xMin + 16.0D, yMin, zOff).color(r, g, b, 1.0F).endVertex();
  61.            buff.pos(xMin + 16.0D, yMax, zOff).color(r, g, b, 1.0F).endVertex();
  62.            buff.pos(xMin + 16.0D, yMax, zOff).color(r, g, b, 0.0F).endVertex();
  63.        }
  64.  
  65.        //Horizontal Y rings
  66.        for (int y = start.getY(); y <= end.getY(); y += step)
  67.        {
  68.            double yOff = (double)y - driftY;
  69.            buff.pos(xMin,         yOff, zMin        ).color(r, g, b, 0.0F).endVertex();
  70.            buff.pos(xMin,         yOff, zMin        ).color(r, g, b, 1.0F).endVertex();
  71.            buff.pos(xMin,         yOff, zMin + 16.0D).color(r, g, b, 1.0F).endVertex();
  72.            buff.pos(xMin + 16.0D, yOff, zMin + 16.0D).color(r, g, b, 1.0F).endVertex();
  73.            buff.pos(xMin + 16.0D, yOff, zMin        ).color(r, g, b, 1.0F).endVertex();
  74.            buff.pos(xMin,         yOff, zMin        ).color(r, g, b, 1.0F).endVertex();
  75.            buff.pos(xMin,         yOff, zMin        ).color(r, g, b, 0.0F).endVertex();
  76.        }
  77.  
  78.        tes.draw();
  79.        GlStateManager.glLineWidth(1.0F);
  80.        GlStateManager.enableBlend();
  81.        GlStateManager.enableTexture2D();
  82.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement