Plex/src/main/java/dev/plex/world/NoiseChunkGenerator.java

35 lines
1.2 KiB
Java
Raw Normal View History

2021-01-03 07:21:15 +00:00
package dev.plex.world;
2020-10-31 04:51:22 +00:00
2020-11-06 01:29:38 +00:00
import java.util.Random;
2020-10-31 04:51:22 +00:00
import org.bukkit.World;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.util.noise.PerlinNoiseGenerator;
public abstract class NoiseChunkGenerator extends CustomChunkGenerator
{
private final NoiseOptions options;
public NoiseChunkGenerator(int height, NoiseOptions options, BlockPopulator... populators)
{
super(height, populators);
this.options = options;
}
@Override
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome)
{
ChunkData chunk = this.createChunkData(world);
PerlinNoiseGenerator generator = new PerlinNoiseGenerator(new Random(world.getSeed()));
for (int xx = 0; xx < 16; xx++)
{
for (int zz = 0; zz < 16; zz++)
{
2020-11-06 01:29:38 +00:00
height = (int)generator.noise(options.getX(), options.getY(), options.getFrequency(), options.getAmplitude(), options.isNormalized());
2020-10-31 04:51:22 +00:00
createLoopChunkData(xx, height, zz, chunk);
}
}
return chunk;
}
public abstract void createLoopChunkData(int x, int y, int z, ChunkData chunk);
}