Guest User

Untitled

a guest
Jul 21st, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. public class ExampleGenerator extends ChunkGenerator {
  2. @Override
  3. public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid grid) {
  4. // mandatory to create initial data
  5. ChunkData chunk = super.createChunkData(world);
  6.  
  7. // create generator for Y values
  8. // use world seed so results are the same for each unique seed
  9. // number of octaves (iterations) to use
  10. SimplexOctaveGenerator generator = new SimplexOctaveGenerator(new Random(world.getSeed()), 8);
  11.  
  12. // lower values create smoother terrain (plains) while high values make steep terrain (mountains)
  13. generator.setScale(0.005D);
  14.  
  15. // current Y value
  16. int y;
  17.  
  18. // loop through the chunk's blocks
  19. // remember the Y value comes from the octave generator
  20. for (int x = 0; x < 16; x++) {
  21. for (int z = 0; z < 16; z++) {
  22.  
  23. // set the current Y value
  24. y = (int)
  25. // get the current Y value for the given block at x/z at chunkX/chunkZ
  26. (((generator.noise((chunkX * 16) + x, (chunkZ * 16) + z, 0.5D, 0.5D, true) + 1)
  27. // multiply the Y value by a number - this is the difference between the highest and lowest points in the world (at 10 world stops at 64)
  28. // add a number to the Y value - this number the minimum height of the world
  29. // both of these numbers can be changed
  30. * 15D) + 7D);
  31.  
  32. // this is where you would apply your custom generation using (x, y, z)
  33.  
  34. // creating superflat terrain with 3 blocks of stone as an example
  35. chunk.setBlock(x, y, z, Material.GRASS);
  36. chunk.setBlock(x, y - 1, z, Material.DIRT);
  37. chunk.setBlock(x, y - 2, z, Material.DIRT);
  38. for (int index = y - 3; index > 0; index--) {
  39. chunk.setBlock(x, index, z, Material.STONE);
  40. }
  41. chunk.setBlock(x, 0, z, Material.BEDROCK);
  42. }
  43. }
  44.  
  45. // return your chunk
  46. return chunk;
  47. }
  48. }
Add Comment
Please, Sign In to add comment