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 Details

    • CODEC

      public static final com.mojang.serialization.Codec<ChunkGenerator> CODEC
    • populationSource

      protected final BiomeSource populationSource
      Used to control the population step without replacing the actual biome that comes from the original biomeSource.

      This is used by FlatChunkGenerator to overwrite biome properties like whether lakes generate, while preserving the original biome ID.

    • biomeSource

      protected final BiomeSource biomeSource
    • structuresConfig

      private final StructuresConfig structuresConfig
    • worldSeed

      private final long worldSeed
    • strongholds

      private final List<ChunkPos> strongholds
  • Constructor Details

  • Method Details

    • generateStrongholdPositions

      private void generateStrongholdPositions()
    • getCodec

      protected abstract com.mojang.serialization.Codec<? extends ChunkGenerator> getCodec()
    • withSeed

      @Environment(CLIENT) public abstract ChunkGenerator withSeed​(long seed)
    • populateBiomes

      public void populateBiomes​(Registry<Biome> biomeRegistry, Chunk chunk)
    • carve

      public void carve​(long seed, BiomeAccess access, Chunk chunk, GenerationStep.Carver carver)
    • 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

      public void generateFeatures​(ChunkRegion region, StructureAccessor accessor)
    • buildSurface

      public abstract void buildSurface​(ChunkRegion region, Chunk chunk)
    • populateEntities

      public void populateEntities​(ChunkRegion region)
    • getStructuresConfig

      public StructuresConfig getStructuresConfig()
    • getSpawnHeight

      public int getSpawnHeight()
    • getBiomeSource

      public BiomeSource 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

      public 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.
    • getSeaLevel

      public int getSeaLevel()
    • getHeight

      public abstract int getHeight​(int x, int z, Heightmap.Type heightmapType)
    • getColumnSample

      public abstract BlockView getColumnSample​(int x, int z)
    • getHeightOnGround

      public int getHeightOnGround​(int x, int z, Heightmap.Type heightmapType)
    • getHeightInGround

      public int getHeightInGround​(int x, int z, Heightmap.Type heightmapType)
    • isStrongholdStartingChunk

      public boolean isStrongholdStartingChunk​(ChunkPos chunkPos)