001 package org.bukkit.util.noise;
002
003 import java.util.Random;
004 import org.bukkit.World;
005
006 /**
007 * Creates perlin noise through unbiased octaves
008 */
009 public class PerlinOctaveGenerator extends OctaveGenerator {
010
011 /**
012 * Creates a perlin octave generator for the given world
013 *
014 * @param world World to construct this generator for
015 * @param octaves Amount of octaves to create
016 */
017 public PerlinOctaveGenerator(World world, int octaves) {
018 this(new Random(world.getSeed()), octaves);
019 }
020
021 /**
022 * Creates a perlin octave generator for the given world
023 *
024 * @param seed Seed to construct this generator for
025 * @param octaves Amount of octaves to create
026 */
027 public PerlinOctaveGenerator(long seed, int octaves) {
028 this(new Random(seed), octaves);
029 }
030
031 /**
032 * Creates a perlin octave generator for the given {@link Random}
033 *
034 * @param rand Random object to construct this generator for
035 * @param octaves Amount of octaves to create
036 */
037 public PerlinOctaveGenerator(Random rand, int octaves) {
038 super(createOctaves(rand, octaves));
039 }
040
041 private static NoiseGenerator[] createOctaves(Random rand, int octaves) {
042 NoiseGenerator[] result = new NoiseGenerator[octaves];
043
044 for (int i = 0; i < octaves; i++) {
045 result[i] = new PerlinNoiseGenerator(rand);
046 }
047
048 return result;
049 }
050 }