Advertisement
spacechase0

World Gen

Aug 6th, 2013
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1.     @Override
  2.     public Chunk provideChunk( int x, int z )
  3.     {
  4.         long lx = ( long ) x;
  5.         long lz = ( long ) z;
  6.        
  7.         short[] id = new short[ 16 * 256 * 16 ];
  8.         byte[] meta = new byte[ 16 * 256 * 16 ];
  9.        
  10.         generateBase( id, meta );
  11.         addCaves( x, z, id, meta );
  12.        
  13.         Chunk chunk = makeChunk( x, z, id, meta );
  14.         chunk.generateSkylightMap();
  15.        
  16.         return chunk;
  17.     }
  18.    
  19.     private Chunk makeChunk( int x, int z, short[] id, byte[] meta )
  20.     {
  21.         Chunk chunk = new Chunk( world, x, z );
  22.         ExtendedBlockStorage[] storage = chunk.getBlockStorageArray();
  23.        
  24.         int height = id.length / ( 16 * 16 );
  25.         for ( int ix = 0; ix < 16; ++ix )
  26.         {
  27.             for ( int iz = 0; iz < 16; ++iz )
  28.             {
  29.                 for ( int iy = 0; iy < height; ++iy )
  30.                 {
  31.                     int index = 0;
  32.                     index |= ix << 12;
  33.                     index |= iz << 8;
  34.                     index |= iy;
  35.  
  36.                     int storageIndex = iy >> 4;
  37.                     if( storage[ storageIndex ] == null )
  38.                     {
  39.                         storage[ storageIndex ] = new ExtendedBlockStorage( storageIndex << 4, false );
  40.                     }
  41.                    
  42.                     storage[ storageIndex ].setExtBlockID( ix, iy & 0xf, iz, id[ index ] );
  43.                     storage[ storageIndex ].setExtBlockMetadata( ix, iy & 0xf, iz, meta[ index ] );
  44.                 }
  45.             }
  46.         }
  47.        
  48.         return chunk;
  49.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement