Added custom world generator API

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot
2011-06-06 13:23:30 +01:00
parent 63a68b3e10
commit 6ad28ba607
8 changed files with 144 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
package org.bukkit.generator;
import java.util.Random;
import org.bukkit.Chunk;
import org.bukkit.World;
/**
* A block populator is responsible for generating a small area of blocks.
* For example, generating glowstone inside the nether or generating dungeons full of treasure
*/
public interface BlockPopulator {
/**
* Populates an area of blocks at or around the given chunk
*
* @param world The world to generate in
* @param random The random generator to use
* @param chunk The chunk to generate for
*/
public void populate(World world, Random random, Chunk source);
}

View File

@@ -0,0 +1,54 @@
package org.bukkit.generator;
import java.util.List;
import java.util.Random;
import org.bukkit.World;
/**
* A chunk generator is responsible for the initial shaping of an entire chunk.
* For example, the nether chunk generator should shape netherrack and soulsand
*/
public interface ChunkGenerator {
/**
* Shapes the chunk for the given coordinates.<br />
* <br />
* This method should return a byte[32768] in the following format:
* <pre>
* for (int x = 0; x < 16; x++) {
* for (int z = 0; z < 16; z++) {
* for (int y = 0; y < 128; y++) {
* // result[(x * 16 + z) * 128 + y] = ??;
* }
* }
* }
* </pre>
*
* Note that this method should <b>never</b> attempt to get the Chunk at
* the passed coordinates, as doing so may cause an infinite loop
*
* @param world The world this chunk will be used for
* @param random The random generator to use
* @param x The X-coordinate of the chunk
* @param z The Z-coordinate of the chunk
* @return byte[] containing the types for each block created by this generator
*/
public byte[] generate(World world, Random random, int x, int z);
/**
* Tests if the specified location is valid for a natural spawn position
*
* @param world The world we're testing on
* @param x X-coordinate of the block to test
* @param z Z-coordinate of the block to test
* @return true if the location is valid, otherwise false
*/
public boolean canSpawn(World world, int x, int z);
/**
* Gets a list of default {@link BlockPopulator}s to apply to a given world
*
* @param world World to apply to
* @return List containing any amount of BlockPopulators
*/
public List<BlockPopulator> getDefaultPopulators(World world);
}