2021-01-03 07:21:15 +00:00
|
|
|
package dev.plex.world;
|
2020-10-31 04:51:22 +00:00
|
|
|
|
|
|
|
import org.bukkit.World;
|
|
|
|
import org.bukkit.generator.BlockPopulator;
|
|
|
|
import org.bukkit.util.noise.PerlinOctaveGenerator;
|
|
|
|
|
2022-01-04 03:04:39 +00:00
|
|
|
import java.util.Random;
|
|
|
|
|
2020-10-31 04:51:22 +00:00
|
|
|
public abstract class OctaveChunkGenerator extends CustomChunkGenerator
|
|
|
|
{
|
2020-11-06 03:50:16 +00:00
|
|
|
private final OctaveOptions options;
|
2020-10-31 04:51:22 +00:00
|
|
|
|
2020-11-06 01:29:38 +00:00
|
|
|
public OctaveChunkGenerator(int height, OctaveOptions options, BlockPopulator... populators)
|
2020-10-31 04:51:22 +00:00
|
|
|
{
|
|
|
|
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);
|
|
|
|
PerlinOctaveGenerator generator = new PerlinOctaveGenerator(new Random(world.getSeed()), options.getOctaves());
|
|
|
|
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);
|
|
|
|
}
|