Package org.bukkit.generator
Class ChunkGenerator
java.lang.Object
org.bukkit.generator.ChunkGenerator
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
Modifier and TypeClassDescriptionstatic interface
Interface to biome section for chunk to be generated: initialized with default values for world type and seed.static interface
Data for a Chunk. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Tests if the specified location is valid for a natural spawn positionprotected @NotNull ChunkGenerator.ChunkData
createChunkData(@NotNull World world)
Create a ChunkData for a world.createVanillaChunkData(@NotNull World world, int x, int z)
Create a ChunkData for use in a generator, that is populated by the vanilla generator for that worldgenerateChunkData(@NotNull World world, @NotNull Random random, int x, int z, @NotNull ChunkGenerator.BiomeGrid biome)
Shapes the chunk for the given coordinates.getDefaultPopulators(@NotNull World world)
Gets a list of defaultBlockPopulator
s to apply to a given worldgetFixedSpawnLocation(@NotNull World world, @NotNull Random random)
Gets a fixed spawn location to use for a given world.boolean
Gets if this ChunkGenerator is parallel capable.boolean
Gets if the server should generate Vanilla caves after this ChunkGenerator.boolean
Gets if the server should generate Vanilla decorations after this ChunkGenerator.boolean
Gets if the server should generate Vanilla mobs after this ChunkGenerator.boolean
Gets if the server should generate Vanilla structures after this ChunkGenerator.
-
Constructor Details
-
ChunkGenerator
public ChunkGenerator()
-
-
Method Details
-
generateChunkData
@NotNull public @NotNull ChunkGenerator.ChunkData generateChunkData(@NotNull @NotNull World world, @NotNull @NotNull Random random, int x, int z, @NotNull @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 @NotNull ChunkGenerator.ChunkData createChunkData(@NotNull @NotNull World world)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
@Nullable public @Nullable Location getFixedSpawnLocation(@NotNull @NotNull World world, @NotNull @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
-
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
-
createVanillaChunkData
@NotNull public @NotNull ChunkGenerator.ChunkData createVanillaChunkData(@NotNull @NotNull World world, int x, int z)Create a ChunkData for use in a generator, that is populated by the vanilla generator for that world- Parameters:
world
- the world to create the ChunkData forx
- the x coordinate of the chunkz
- the z coordinate of the chunk- Returns:
- a new ChunkData for the world
-