Added simple bedrock layer generator.
This commit is contained in:
parent
4b9c5ca440
commit
d506b60f07
@ -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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user