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 BiomeSourcebiomeSourcestatic com.mojang.serialization.Codec<ChunkGenerator>CODECprotected BiomeSourcepopulationSourceUsed to control the population step without replacing the actual biome that comes from the originalbiomeSource.private List<ChunkPos>strongholdsprivate StructuresConfigstructuresConfigprivate longworldSeed -
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 voidaddStructureReferences(StructureWorldAccess world, StructureAccessor accessor, Chunk chunk)Finds all structures that the given chunk intersects, and adds references to their starting chunks to it.abstract voidbuildSurface(ChunkRegion region, Chunk chunk)voidcarve(long seed, BiomeAccess access, Chunk chunk, GenerationStep.Carver carver)voidgenerateFeatures(ChunkRegion region, StructureAccessor accessor)private voidgenerateStrongholdPositions()BiomeSourcegetBiomeSource()protected abstract com.mojang.serialization.Codec<? extends ChunkGenerator>getCodec()abstract VerticalBlockSamplegetColumnSample(int x, int z)List<SpawnSettings.SpawnEntry>getEntitySpawnList(Biome biome, StructureAccessor accessor, SpawnGroup group, BlockPos pos)abstract intgetHeight(int x, int z, Heightmap.Type heightmapType)intgetHeightInGround(int x, int z, Heightmap.Type heightmapType)intgetHeightOnGround(int x, int z, Heightmap.Type heightmapType)intgetSeaLevel()intgetSpawnHeight()StructuresConfiggetStructuresConfig()intgetWorldHeight()booleanisStrongholdStartingChunk(ChunkPos chunkPos)BlockPoslocateStructure(ServerWorld world, StructureFeature<?> feature, BlockPos center, int radius, boolean skipExistingChunks)Tries to find the closest structure of a given type near a given block.voidpopulateBiomes(Registry<Biome> biomeRegistry, Chunk chunk)voidpopulateEntities(ChunkRegion region)abstract voidpopulateNoise(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 voidsetStructureStart(ConfiguredStructureFeature<?,?> configuredStructureFeature, DynamicRegistryManager dynamicRegistryManager, StructureAccessor structureAccessor, Chunk chunk, StructureManager structureManager, long worldSeed, ChunkPos chunkPos, Biome biome)voidsetStructureStarts(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 ChunkGeneratorwithSeed(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
FlatChunkGeneratorto 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_STARTSphase 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:
nullif 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
-