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 call
generateChunkData(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, then
isParallelCapable()
should be overridden accordingly to allow
multiple concurrent callers.
Some aspects of world generation can be delegated to the Vanilla generator.
The methods shouldGenerateCaves()
, shouldGenerateDecorations()
,
shouldGenerateMobs()
and shouldGenerateStructures()
can be
overridden to enable this.-
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
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.boolean
shouldGenerateCaves()
Gets if the server should generate Vanilla caves after this ChunkGenerator.boolean
shouldGenerateDecorations()
Gets if the server should generate Vanilla decorations after this ChunkGenerator.boolean
shouldGenerateMobs()
Gets if the server should generate Vanilla mobs after this ChunkGenerator.boolean
shouldGenerateStructures()
Gets if the server should generate Vanilla structures after this ChunkGenerator.
-
Constructor Details
-
ChunkGenerator
public ChunkGenerator()
-
-
Method Details
-
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
Create a ChunkData for a world.- Parameters:
world
- the world the ChunkData is for- Returns:
- a new ChunkData for world
-
canSpawn
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
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
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
-
shouldGenerateCaves
public boolean shouldGenerateCaves()Gets if the server should generate Vanilla caves after this ChunkGenerator.- Returns:
- true if the server should generate Vanilla caves
-
shouldGenerateDecorations
public boolean shouldGenerateDecorations()Gets if the server should generate Vanilla decorations after this ChunkGenerator.- Returns:
- true if the server should generate Vanilla decorations
-
shouldGenerateMobs
public boolean shouldGenerateMobs()Gets if the server should generate Vanilla mobs after this ChunkGenerator.- Returns:
- true if the server should generate Vanilla mobs
-
shouldGenerateStructures
public boolean shouldGenerateStructures()Gets if the server should generate Vanilla structures after this ChunkGenerator.- Returns:
- true if the server should generate Vanilla structures
-