Created
September 14, 2018 14:50
-
-
Save wyatt-herkamp/6359f93277e430b3289970c393a16a34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WaterWorldGen extends ChunkGenerator { | |
private NoiseGenerator generator; | |
private NoiseGenerator getGenerator(World world) { | |
if (generator == null) { | |
generator = new SimplexNoiseGenerator(world); | |
} | |
return generator; | |
} | |
private int getHeight(World world, double x, double y, int variance) { | |
NoiseGenerator gen = getGenerator(world); | |
double result = gen.noise(x, y); | |
result *= variance; | |
return NoiseGenerator.floor(result); | |
} | |
@Override | |
public ChunkGenerator.ChunkData generateChunkData(World world, Random random, int cx, int cz, | |
ChunkGenerator.BiomeGrid biome) { | |
// Create the chunk data from method | |
ChunkGenerator.ChunkData data = this.createChunkData(world); | |
// Loop through each X and Z value | |
for (int x = 0; x < 16; x++) { | |
for (int z = 0; z < 16; z++) { | |
int height = 20; | |
// Loop through each Y value in the column | |
for (int y = 0; y < height; y++) { | |
// Set the block to be stone if more than 5 blocks down from the surface | |
if (y == 0) { | |
data.setBlock(x, y, z, Material.BEDROCK); | |
} else if (y <= 3) { | |
data.setBlock(x, y, z, Material.SAND); | |
} else { | |
data.setBlock(x, y, z, Material.WATER); | |
} | |
} | |
} | |
} | |
return data; | |
} | |
@Override | |
public List<BlockPopulator> getDefaultPopulators(World world) { | |
return new ArrayList<BlockPopulator>(); | |
} | |
@Override | |
public Location getFixedSpawnLocation(World world, Random random) { | |
// Create random position within 100 blocks of 0,0 | |
int x = random.nextInt(200) - 100; | |
int z = random.nextInt(200) - 100; | |
int y = world.getHighestBlockYAt(x, z); | |
return new Location(world, x, y, z); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment