Package net.minecraft.world.gen.chunk
Class ChunkGenerator
java.lang.Object
net.minecraft.world.gen.chunk.ChunkGenerator
- Direct Known Subclasses:
DebugChunkGenerator
,FlatChunkGenerator
,NoiseChunkGenerator
public abstract class ChunkGenerator extends Object
In charge of shaping, adding biome specific surface blocks, and carving chunks,
as well as populating the generated chunks with features and entities.
Biome placement starts here, however all vanilla and most modded chunk generators delegate this to a biome source.
-
Field Summary
Fields Modifier and Type Field Description protected BiomeSource
biomeSource
static com.mojang.serialization.Codec<ChunkGenerator>
CODEC
protected BiomeSource
populationSource
Used to control the population step without replacing the actual biome that comes from the originalbiomeSource
.private List<ChunkPos>
strongholds
private StructuresConfig
structuresConfig
private long
worldSeed
-
Constructor Summary
Constructors Constructor Description ChunkGenerator(BiomeSource populationSource, BiomeSource biomeSource, StructuresConfig structuresConfig, long worldSeed)
ChunkGenerator(BiomeSource biomeSource, StructuresConfig structuresConfig)
-
Method Summary
Modifier and Type Method Description void
addStructureReferences(StructureWorldAccess world, StructureAccessor accessor, Chunk chunk)
Finds all structures that the given chunk intersects, and adds references to their starting chunks to it.abstract void
buildSurface(ChunkRegion region, Chunk chunk)
void
carve(long seed, BiomeAccess access, Chunk chunk, GenerationStep.Carver carver)
void
generateFeatures(ChunkRegion region, StructureAccessor accessor)
private void
generateStrongholdPositions()
BiomeSource
getBiomeSource()
protected abstract com.mojang.serialization.Codec<? extends ChunkGenerator>
getCodec()
abstract BlockView
getColumnSample(int x, int z)
List<SpawnSettings.SpawnEntry>
getEntitySpawnList(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos)
abstract int
getHeight(int x, int z, Heightmap.Type heightmapType)
int
getHeightInGround(int x, int z, Heightmap.Type heightmapType)
int
getHeightOnGround(int x, int z, Heightmap.Type heightmapType)
int
getSeaLevel()
int
getSpawnHeight()
StructuresConfig
getStructuresConfig()
int
getWorldHeight()
boolean
isStrongholdStartingChunk(ChunkPos chunkPos)
BlockPos
locateStructure(ServerWorld world, StructureFeature<?> feature, BlockPos center, int radius, boolean skipExistingChunks)
Tries to find the closest structure of a given type near a given block.void
populateBiomes(Registry<Biome> biomeRegistry, Chunk chunk)
void
populateEntities(ChunkRegion region)
abstract void
populateNoise(WorldAccess world, StructureAccessor accessor, Chunk chunk)
Generates the base shape of the chunk out of the basic block states as decided by this chunk generator's config.private void
setStructureStart(ConfiguredStructureFeature<?,?> configuredStructureFeature, DynamicRegistryManager dynamicRegistryManager, StructureAccessor structureAccessor, Chunk chunk, StructureManager structureManager, long worldSeed, ChunkPos chunkPos, Biome biome)
void
setStructureStarts(DynamicRegistryManager dynamicRegistryManager, StructureAccessor structureAccessor, Chunk chunk, StructureManager structureManager, long worldSeed)
Determines which structures should start in the given chunk and creates their starting points.abstract ChunkGenerator
withSeed(long seed)
-
Field Details
-
CODEC
-
populationSource
Used to control the population step without replacing the actual biome that comes from the originalbiomeSource
.This is used by
FlatChunkGenerator
to overwrite biome properties like whether lakes generate, while preserving the original biome ID. -
biomeSource
-
structuresConfig
-
worldSeed
private final long worldSeed -
strongholds
-
-
Constructor Details
-
ChunkGenerator
-
ChunkGenerator
public ChunkGenerator(BiomeSource populationSource, BiomeSource biomeSource, StructuresConfig structuresConfig, long worldSeed)
-
-
Method Details
-
generateStrongholdPositions
private void generateStrongholdPositions() -
getCodec
-
withSeed
-
populateBiomes
-
carve
-
locateStructure
@Nullable public BlockPos locateStructure(ServerWorld world, StructureFeature<?> feature, BlockPos center, int radius, boolean skipExistingChunks)Tries to find the closest structure of a given type near a given block.New chunks will only be generated up to the
ChunkStatus.STRUCTURE_STARTS
phase by this method.- Parameters:
radius
- The search radius in chunks around the chunk the given block position is in. A radius of 0 will only search in the given chunk. This is ignored for strongholds.skipExistingChunks
- whether only structures that are not referenced by generated chunks (chunks past the STRUCTURE_STARTS stage) are returned, excluding strongholds- Returns:
null
if no structure could be found within the given search radius
-
generateFeatures
-
buildSurface
-
populateEntities
-
getStructuresConfig
-
getSpawnHeight
public int getSpawnHeight() -
getBiomeSource
-
getWorldHeight
public int getWorldHeight() -
getEntitySpawnList
public List<SpawnSettings.SpawnEntry> getEntitySpawnList(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos) -
setStructureStarts
public void setStructureStarts(DynamicRegistryManager dynamicRegistryManager, StructureAccessor structureAccessor, Chunk chunk, StructureManager structureManager, long worldSeed)Determines which structures should start in the given chunk and creates their starting points. -
setStructureStart
private void setStructureStart(ConfiguredStructureFeature<?,?> configuredStructureFeature, DynamicRegistryManager dynamicRegistryManager, StructureAccessor structureAccessor, Chunk chunk, StructureManager structureManager, long worldSeed, ChunkPos chunkPos, Biome biome) -
addStructureReferences
public void addStructureReferences(StructureWorldAccess world, StructureAccessor accessor, Chunk chunk)Finds all structures that the given chunk intersects, and adds references to their starting chunks to it. A radius of 8 chunks around the given chunk will be searched for structure starts. -
populateNoise
Generates the base shape of the chunk out of the basic block states as decided by this chunk generator's config. -
getSeaLevel
public int getSeaLevel() -
getHeight
-
getColumnSample
-
getHeightOnGround
-
getHeightInGround
-
isStrongholdStartingChunk
-