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

34 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
2022-01-27 21:23:01 +00:00
import java.util.Random;
2020-10-31 04:51:22 +00:00
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.WorldInfo;
2020-10-31 04:51:22 +00:00
import org.bukkit.util.noise.PerlinOctaveGenerator;
import org.jetbrains.annotations.NotNull;
2020-10-31 04:51:22 +00:00
public abstract class OctaveChunkGenerator extends CustomChunkGenerator
{
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 void generateNoise(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull ChunkData chunk)
2020-10-31 04:51:22 +00:00
{
PerlinOctaveGenerator generator = new PerlinOctaveGenerator(new Random(worldInfo.getSeed()), options.getOctaves());
2020-10-31 04:51:22 +00:00
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);
}
}
}
public abstract void createLoopChunkData(int x, int y, int z, ChunkData chunk);
}