package ca.recrown.islandsurvivalcraft.world.generation;

import java.util.Random;

import org.bukkit.util.noise.SimplexOctaveGenerator;

public class BedrockGenerator {
    private SimplexOctaveGenerator noiseGenerator;
    private final int maxBedrockHeight;
    private final int minBedrockHeight;

    public BedrockGenerator(Random random, int maxBedrockHeight, int minBedrockHeight) {
        noiseGenerator = new SimplexOctaveGenerator(random, 1);
        noiseGenerator.setScale(0.1D);
        this.maxBedrockHeight = maxBedrockHeight;
        this.minBedrockHeight = minBedrockHeight;
    }

    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);
    }
}