Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ExampleGenerator extends ChunkGenerator {
- @Override
- public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid grid) {
- // mandatory to create initial data
- ChunkData chunk = super.createChunkData(world);
- // create generator for Y values
- // use world seed so results are the same for each unique seed
- // number of octaves (iterations) to use
- SimplexOctaveGenerator generator = new SimplexOctaveGenerator(new Random(world.getSeed()), 8);
- // lower values create smoother terrain (plains) while high values make steep terrain (mountains)
- generator.setScale(0.005D);
- // current Y value
- int y;
- // loop through the chunk's blocks
- // remember the Y value comes from the octave generator
- for (int x = 0; x < 16; x++) {
- for (int z = 0; z < 16; z++) {
- // set the current Y value
- y = (int)
- // get the current Y value for the given block at x/z at chunkX/chunkZ
- (((generator.noise((chunkX * 16) + x, (chunkZ * 16) + z, 0.5D, 0.5D, true) + 1)
- // 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)
- // add a number to the Y value - this number the minimum height of the world
- // both of these numbers can be changed
- * 15D) + 7D);
- // this is where you would apply your custom generation using (x, y, z)
- // creating superflat terrain with 3 blocks of stone as an example
- chunk.setBlock(x, y, z, Material.GRASS);
- chunk.setBlock(x, y - 1, z, Material.DIRT);
- chunk.setBlock(x, y - 2, z, Material.DIRT);
- for (int index = y - 3; index > 0; index--) {
- chunk.setBlock(x, index, z, Material.STONE);
- }
- chunk.setBlock(x, 0, z, Material.BEDROCK);
- }
- }
- // return your chunk
- return chunk;
- }
- }
Add Comment
Please, Sign In to add comment