Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
PerlinOctaveGenerator.java
1 package org.bukkit.util.noise;
2 
3 import java.util.Random;
4 import org.bukkit.World;
5 
6 /**
7  * Creates perlin noise through unbiased octaves
8  */
9 public class PerlinOctaveGenerator extends OctaveGenerator {
10 
11  /**
12  * Creates a perlin octave generator for the given world
13  *
14  * @param world World to construct this generator for
15  * @param octaves Amount of octaves to create
16  */
17  public PerlinOctaveGenerator(World world, int octaves) {
18  this(new Random(world.getSeed()), octaves);
19  }
20 
21  /**
22  * Creates a perlin octave generator for the given world
23  *
24  * @param seed Seed to construct this generator for
25  * @param octaves Amount of octaves to create
26  */
27  public PerlinOctaveGenerator(long seed, int octaves) {
28  this(new Random(seed), octaves);
29  }
30 
31  /**
32  * Creates a perlin octave generator for the given {@link Random}
33  *
34  * @param rand Random object to construct this generator for
35  * @param octaves Amount of octaves to create
36  */
37  public PerlinOctaveGenerator(Random rand, int octaves) {
38  super(createOctaves(rand, octaves));
39  }
40 
41  private static NoiseGenerator[] createOctaves(Random rand, int octaves) {
42  NoiseGenerator[] result = new NoiseGenerator[octaves];
43 
44  for (int i = 0; i < octaves; i++) {
45  result[i] = new PerlinNoiseGenerator(rand);
46  }
47 
48  return result;
49  }
50 }