Package org.bukkit.generator
Class ChunkGenerator
- java.lang.Object
-
- org.bukkit.generator.ChunkGenerator
-
public abstract class ChunkGenerator extends Object
A chunk generator is responsible for the initial shaping of an entire chunk. For example, the nether chunk generator should shape netherrack and soulsand. By default only one thread will callgenerateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)
at a time, although this may not necessarily be the main server thread. If your generator is capable of fully asynchronous generation, thenisParallelCapable()
should be overriden accordingly to allow multiple concurrent callers.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ChunkGenerator.BiomeGrid
Interface to biome section for chunk to be generated: initialized with default values for world type and seed.static interface
ChunkGenerator.ChunkData
Data for a Chunk.
-
Constructor Summary
Constructors Constructor Description ChunkGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canSpawn(World world, int x, int z)
Tests if the specified location is valid for a natural spawn positionprotected ChunkGenerator.ChunkData
createChunkData(World world)
Create a ChunkData for a world.ChunkGenerator.ChunkData
generateChunkData(World world, Random random, int x, int z, ChunkGenerator.BiomeGrid biome)
Shapes the chunk for the given coordinates.List<BlockPopulator>
getDefaultPopulators(World world)
Gets a list of defaultBlockPopulator
s to apply to a given worldLocation
getFixedSpawnLocation(World world, Random random)
Gets a fixed spawn location to use for a given world.boolean
isParallelCapable()
Gets if this ChunkGenerator is parallel capable.
-
-
-
Method Detail
-
generateChunkData
@NotNull public ChunkGenerator.ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, @NotNull ChunkGenerator.BiomeGrid biome)
Shapes the chunk for the given coordinates. This method must return a ChunkData.Notes:
This method should never attempt to get the Chunk at the passed coordinates, as doing so may cause an infinite loop
This method should never modify a ChunkData after it has been returned.
This method must return a ChunkData returned by
createChunkData(org.bukkit.World)
- Parameters:
world
- The world this chunk will be used forrandom
- The random generator to usex
- The X-coordinate of the chunkz
- The Z-coordinate of the chunkbiome
- Proposed biome values for chunk - can be updated by generator- Returns:
- ChunkData containing the types for each block created by this generator
-
createChunkData
@NotNull protected final ChunkGenerator.ChunkData createChunkData(@NotNull World world)
Create a ChunkData for a world.- Parameters:
world
- the world the ChunkData is for- Returns:
- a new ChunkData for world
-
canSpawn
public boolean canSpawn(@NotNull World world, int x, int z)
Tests if the specified location is valid for a natural spawn position- Parameters:
world
- The world we're testing onx
- X-coordinate of the block to testz
- Z-coordinate of the block to test- Returns:
- true if the location is valid, otherwise false
-
getDefaultPopulators
@NotNull public List<BlockPopulator> getDefaultPopulators(@NotNull World world)
Gets a list of defaultBlockPopulator
s to apply to a given world- Parameters:
world
- World to apply to- Returns:
- List containing any amount of BlockPopulators
-
getFixedSpawnLocation
@Nullable public Location getFixedSpawnLocation(@NotNull World world, @NotNull Random random)
Gets a fixed spawn location to use for a given world.A null value is returned if a world should not use a fixed spawn point, and will instead attempt to find one randomly.
- Parameters:
world
- The world to locate a spawn point forrandom
- Random generator to use in the calculation- Returns:
- Location containing a new spawn point, otherwise null
-
isParallelCapable
public boolean isParallelCapable()
Gets if this ChunkGenerator is parallel capable. SeeChunkGenerator
for more information.- Returns:
- parallel capable status
-
-