diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/worldgen/BedrockGenerator.java b/src/main/java/ca/recrown/islandsurvivalcraft/worldgen/BedrockGenerator.java new file mode 100644 index 0000000..31f9ca5 --- /dev/null +++ b/src/main/java/ca/recrown/islandsurvivalcraft/worldgen/BedrockGenerator.java @@ -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); + } +} \ No newline at end of file