public abstract class ChunkGenerator extends Object
generateNoise(WorldInfo, Random, int, int, ChunkData)
generateSurface(WorldInfo, Random, int, int, ChunkData)
generateBedrock(WorldInfo, Random, int, int, ChunkData)
generateCaves(WorldInfo, Random, int, int, ChunkData)
getBaseHeight(WorldInfo, Random, int, int, HeightMap)
must be completely thread safe and able to handle multiple concurrent
callers.
Some aspects of world generation can be delegated to the Vanilla generator.
The following methods can be overridden to enable this:
Modifier and Type | Class and Description |
---|---|
static interface |
ChunkGenerator.BiomeGrid
Deprecated.
Biomes are now set with
BiomeProvider |
static interface |
ChunkGenerator.ChunkData
Data for a Chunk.
|
Constructor and Description |
---|
ChunkGenerator() |
Modifier and Type | Method and Description |
---|---|
boolean |
canSpawn(World world,
int x,
int z)
Tests if the specified location is valid for a natural spawn position
|
protected ChunkGenerator.ChunkData |
createChunkData(World world)
Deprecated.
ChunkGenerator.ChunkData are now directly provided |
void |
generateBedrock(WorldInfo worldInfo,
Random random,
int x,
int z,
ChunkGenerator.ChunkData chunkData)
Shapes the Chunk bedrock layer for the given coordinates.
|
void |
generateCaves(WorldInfo worldInfo,
Random random,
int x,
int z,
ChunkGenerator.ChunkData chunkData)
Shapes the Chunk caves for the given coordinates.
|
ChunkGenerator.ChunkData |
generateChunkData(World world,
Random random,
int x,
int z,
ChunkGenerator.BiomeGrid biome)
Deprecated.
The generation is now split up
|
void |
generateNoise(WorldInfo worldInfo,
Random random,
int x,
int z,
ChunkGenerator.ChunkData chunkData)
Shapes the Chunk noise for the given coordinates.
|
void |
generateSurface(WorldInfo worldInfo,
Random random,
int x,
int z,
ChunkGenerator.ChunkData chunkData)
Shapes the Chunk surface for the given coordinates.
|
int |
getBaseHeight(WorldInfo worldInfo,
Random random,
int x,
int z,
HeightMap heightMap)
This method is similar to
World.getHighestBlockAt(int, int, HeightMap) . |
BiomeProvider |
getDefaultBiomeProvider(WorldInfo worldInfo)
Gets called when no
BiomeProvider is set in
WorldCreator or via the server configuration files. |
List<BlockPopulator> |
getDefaultPopulators(World world)
Gets a list of default
BlockPopulator s to apply to a given
world |
Location |
getFixedSpawnLocation(World world,
Random random)
Gets a fixed spawn location to use for a given world.
|
boolean |
isParallelCapable()
Deprecated.
the chunk generation code should be thread safe
|
boolean |
shouldGenerateBedrock()
Gets if the server should generate Vanilla bedrock.
|
boolean |
shouldGenerateCaves()
Gets if the server should generate Vanilla caves.
|
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 |
shouldGenerateNoise()
Gets if the server should generate Vanilla noise.
|
boolean |
shouldGenerateStructures()
Gets if the server should generate Vanilla structures after this
ChunkGenerator.
|
boolean |
shouldGenerateSurface()
Gets if the server should generate Vanilla surface.
|
public void generateNoise(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull ChunkGenerator.ChunkData 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 the ChunkGenerator.ChunkData
at a later
point of time.
The Y-coordinate range should never be hardcoded, to get the
Y-coordinate range use the methods ChunkGenerator.ChunkData.getMinHeight()
and
ChunkGenerator.ChunkData.getMaxHeight()
.
If shouldGenerateNoise()
is set to true, the given
ChunkGenerator.ChunkData
contains already the Vanilla noise generation.
worldInfo
- The world info of the world this chunk will be used forrandom
- The random generator to usex
- The X-coordinate of the chunkz
- The Z-coordinate of the chunkchunkData
- To modifypublic void generateSurface(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull ChunkGenerator.ChunkData 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 the ChunkGenerator.ChunkData
at a later
point of time.
The Y-coordinate range should never be hardcoded, to get the
Y-coordinate range use the methods ChunkGenerator.ChunkData.getMinHeight()
and
ChunkGenerator.ChunkData.getMaxHeight()
.
If shouldGenerateSurface()
is set to true, the given
ChunkGenerator.ChunkData
contains already the Vanilla surface generation.
worldInfo
- The world info of the world this chunk will be used forrandom
- The random generator to usex
- The X-coordinate of the chunkz
- The Z-coordinate of the chunkchunkData
- To modifypublic void generateBedrock(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull ChunkGenerator.ChunkData 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 the ChunkGenerator.ChunkData
at a later
point of time.
The Y-coordinate range should never be hardcoded, to get the
Y-coordinate range use the methods ChunkGenerator.ChunkData.getMinHeight()
and
ChunkGenerator.ChunkData.getMaxHeight()
.
If shouldGenerateBedrock()
is set to true, the given
ChunkGenerator.ChunkData
contains already the Vanilla bedrock generation.
worldInfo
- The world info of the world this chunk will be used forrandom
- The random generator to usex
- The X-coordinate of the chunkz
- The Z-coordinate of the chunkchunkData
- To modifypublic void generateCaves(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull ChunkGenerator.ChunkData 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 the ChunkGenerator.ChunkData
at a later
point of time.
The Y-coordinate range should never be hardcoded, to get the
Y-coordinate range use the methods ChunkGenerator.ChunkData.getMinHeight()
and
ChunkGenerator.ChunkData.getMaxHeight()
.
If shouldGenerateCaves()
is set to true, the given
ChunkGenerator.ChunkData
contains already the Vanilla cave generation.
worldInfo
- The world info of the world this chunk will be used forrandom
- The random generator to usex
- The X-coordinate of the chunkz
- The Z-coordinate of the chunkchunkData
- To modify@Nullable public BiomeProvider getDefaultBiomeProvider(@NotNull WorldInfo worldInfo)
BiomeProvider
is set in
WorldCreator
or via the server configuration files. It
is therefore possible that one plugin can provide the Biomes and another
one the generation.
Notes:
If null
is returned, than Vanilla biomes are used.
This method only gets called once when the world is loaded. Returning
another BiomeProvider
later one is not respected.
worldInfo
- The world info of the world the biome provider will be
used forpublic int getBaseHeight(@NotNull WorldInfo worldInfo, @NotNull Random random, int x, int z, @NotNull HeightMap heightMap)
World.getHighestBlockAt(int, int, HeightMap)
. With the difference
being, that the highest y coordinate should be the block before any
surface, bedrock, caves or decoration is applied. Or in other words the
highest block when only the noise is present at the chunk.
Notes:
When this method is not overridden, the Vanilla base height is used.
This method should never attempt to get the Chunk at the passed
coordinates, or use the method
World.getHighestBlockAt(int, int, HeightMap)
, as doing so may
cause an infinite loop.
worldInfo
- The world info of the world this chunk will be used forrandom
- The random generator to usex
- The X-coordinate from world originz
- The Z-coordinate from world originheightMap
- From the highest block should be get@NotNull @Deprecated public ChunkGenerator.ChunkData generateChunkData(@NotNull World world, @NotNull Random random, int x, int z, @NotNull ChunkGenerator.BiomeGrid biome)
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)
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@NotNull @Deprecated protected final ChunkGenerator.ChunkData createChunkData(@NotNull World world)
ChunkGenerator.ChunkData
are now directly providedworld
- the world the ChunkData is forpublic boolean canSpawn(@NotNull World world, int x, int z)
world
- The world we're testing onx
- X-coordinate of the block to testz
- Z-coordinate of the block to test@NotNull public List<BlockPopulator> getDefaultPopulators(@NotNull World world)
BlockPopulator
s to apply to a given
worldworld
- World to apply to@Nullable public Location getFixedSpawnLocation(@NotNull World world, @NotNull Random random)
A null value is returned if a world should not use a fixed spawn point, and will instead attempt to find one randomly.
world
- The world to locate a spawn point forrandom
- Random generator to use in the calculation@Deprecated public boolean isParallelCapable()
ChunkGenerator
for more information.public boolean shouldGenerateNoise()
The Vanilla noise is generated before
generateNoise(WorldInfo, Random, int, int, ChunkData)
is called.
public boolean shouldGenerateSurface()
The Vanilla surface is generated before
generateSurface(WorldInfo, Random, int, int, ChunkData)
is
called.
public boolean shouldGenerateBedrock()
The Vanilla bedrock is generated before
generateBedrock(WorldInfo, Random, int, int, ChunkData)
is
called.
public boolean shouldGenerateCaves()
The Vanilla caves are generated before
generateCaves(WorldInfo, Random, int, int, ChunkData)
is called.
public boolean shouldGenerateDecorations()
The Vanilla decoration are generated before any
BlockPopulator
are called.
public boolean shouldGenerateMobs()
public boolean shouldGenerateStructures()
Copyright © 2022. All rights reserved.