Added simple bedrock layer generator.

This commit is contained in:
Harrison Deng 2020-04-20 16:25:57 -05:00
parent 4b9c5ca440
commit d506b60f07

View File

@ -0,0 +1,22 @@
package ca.recrown.islandsurvivalcraft.worldgen;
import java.util.Random;
import org.bukkit.util.noise.SimplexOctaveGenerator;
public class BedrockGenerator {
private SimplexOctaveGenerator noiseGenerator;
private final int maxBedrockHeight = 5;
private final int minBedrockHeight = 1;
public BedrockGenerator(Random random) {
noiseGenerator = new SimplexOctaveGenerator(random, 8);
noiseGenerator.setScale(0.1D);
}
private double getNormalizedNoise(int worldX, int worldZ) {
return (noiseGenerator.noise(worldX, worldZ, 0.5D, 0.5D, true) + 1D) / 2D;
}
public int getBedrockHeight(int worldX, int worldZ) {
return (int) Math.min(minBedrockHeight, getNormalizedNoise(worldX, worldZ) * maxBedrockHeight);
}
}