mirror of
https://github.com/plexusorg/Plex.git
synced 2024-06-27 16:30:42 +00:00
36 lines
1.2 KiB
Java
36 lines
1.2 KiB
Java
package me.totalfreedom.plex.world.impl;
|
|
|
|
import org.bukkit.World;
|
|
import org.bukkit.generator.BlockPopulator;
|
|
import org.bukkit.util.noise.PerlinOctaveGenerator;
|
|
|
|
import java.util.Random;
|
|
|
|
public abstract class OctaveChunkGenerator extends CustomChunkGenerator
|
|
{
|
|
private OctaveOptions options;
|
|
|
|
public OctaveChunkGenerator(int height, OctaveOptions 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);
|
|
PerlinOctaveGenerator generator = new PerlinOctaveGenerator(new Random(world.getSeed()), options.getOctaves());
|
|
for (int xx = 0; xx < 16; xx++)
|
|
{
|
|
for (int zz = 0; zz < 16; zz++)
|
|
{
|
|
height = (int) generator.noise(options.getX(), options.getY(), options.getFrequency(), options.getAmplitude(), options.isNormalized());
|
|
createLoopChunkData(xx, height, zz, chunk);
|
|
}
|
|
}
|
|
return chunk;
|
|
}
|
|
|
|
public abstract void createLoopChunkData(int x, int y, int z, ChunkData chunk);
|
|
} |