From d506b60f0701c7c23caa7b0e262b342ada414ec3 Mon Sep 17 00:00:00 2001 From: Harrison Date: Mon, 20 Apr 2020 16:25:57 -0500 Subject: [PATCH] Added simple bedrock layer generator. --- .../worldgen/BedrockGenerator.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/main/java/ca/recrown/islandsurvivalcraft/worldgen/BedrockGenerator.java 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