Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.84 KB | None | 0 0
  1. public byte[] NewChunk(int Height) {
  2.         byte[] Blocks = new byte[SizeX * SizeY * SizeZ];
  3.         boolean on = true;
  4.         for (int X = 0; X < SizeX; X++) {
  5.             for (int Z = 0; Z < SizeZ; Z++) {
  6.                 for (int Y = 0; Y < SizeY; Y++) {
  7.                     if (Y < Height) {
  8.                         if (Y == 0) {
  9.                             Blocks[GetIndex(X, Y, Z)] = 7;
  10.                         } else if (Y < Height) {
  11.                             Blocks[GetIndex(X, Y, Z)] = 2;
  12.                         } else if (Y <= Height) {
  13.                             Blocks[GetIndex(X, Y, Z)] = 3;
  14.                         } else {
  15.                             Blocks[GetIndex(X, Y, Z)] = 0;
  16.                         }
  17.                         if(X==0||Z==0){
  18.                             //Blocks[GetIndex(X, Y, Z)] = 0;
  19.                         }
  20.                     }
  21.                 }
  22.             }
  23.         }
  24.             return Blocks;
  25.     }
  26.  
  27.     public byte[] AddOtherStuff(byte[] blocks) throws IOException {
  28.         byte[] metadata = new byte[SizeX * SizeY * SizeZ / 2];
  29.         byte[] light = new byte[SizeX * SizeY * SizeZ / 2];
  30.         byte[] skylight = new byte[SizeX * SizeY * SizeZ / 2];
  31.  
  32.         for (int i = 0; i < (SizeX * SizeY * SizeZ) / 2; i++) {
  33.             byte nibblea = (byte) 0x00;
  34.             byte nibbleb = (byte) 0x00;
  35.             byte Both = (byte) ((nibblea << 4) | (nibbleb & 0x0F));
  36.             metadata[i] = Both;
  37.             light[i] = Both;
  38.  
  39.             nibblea = (byte) 0xf;
  40.             nibbleb = (byte) 0xf;
  41.             Both = (byte) ((nibblea << 4) | (nibbleb & 0x0F));
  42.             skylight[i] = Both;
  43.         }
  44.         ByteArrayOutputStream stream = new ByteArrayOutputStream();
  45.         stream.write(blocks);
  46.         stream.write(metadata);
  47.         stream.write(light);
  48.         stream.write(skylight);
  49.         return stream.toByteArray();
  50.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement