Advertisement
Guest User

SkyRider worldgen code

a guest
Sep 19th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1.     public byte[][] generateBlockSections(World world, Random random, int ChunkX, int ChunkZ, BiomeGrid biomes){
  2.         byte[][] blocks = new byte[world.getMaxHeight() / 16][];
  3.         int x, y, z;
  4.        
  5.         Random rand = new Random(world.getSeed());
  6.        
  7.         SimplexOctaveGenerator octave = new SimplexOctaveGenerator(rand, 12);
  8.         SimplexOctaveGenerator octave2 = new SimplexOctaveGenerator(rand, 8);
  9.         octave.setScale(1/48.0);
  10.         octave2.setScale(1/8.0);
  11.         for(x=0; x < 16; x++){
  12.             for(z=0; z<16; z++){
  13.                
  14.                 biomes.setBiome(x, z, Biome.SKY);
  15.                
  16.                  int real_x = x+ChunkX * 16;
  17.                  int real_z = z+ChunkZ*16;
  18.                
  19.                 for(y=0; y<255; y++){
  20.                    
  21.                     double threshold =  0.8;
  22.                     double threshold2 = 0.91;
  23.                    
  24.                     //for some reason this breaks Multiverse2
  25.                     if(y < 96 || y > 224){
  26.                         threshold2 = .99999;
  27.                         threshold = 1;
  28.                     }
  29.                    
  30.                     double noise = octave.noise(real_x, y*2, real_z, 0.5, 0.5);
  31.                     double noise2 = octave2.noise(real_x, y/2, real_z, 0.5, 0.5);
  32.  
  33.                     if(noise > threshold || noise - noise2 > threshold2*2){
  34.                         setBlock(x, y, z, blocks, Material.ENDER_STONE);
  35.                         setBlock(x, y+1, z, blocks, Material.DIRT);
  36.                         setBlock(x, y+2, z, blocks, Material.GRASS);
  37.                     }
  38.                 }
  39.                
  40.             }
  41.            
  42.         }
  43.        
  44.         return blocks;
  45.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement