Package net.minecraft.world.gen.feature
Class StructureFeature<C extends FeatureConfig>
java.lang.Object
net.minecraft.world.gen.feature.StructureFeature<C>
- Direct Known Subclasses:
BuriedTreasureFeature
,DesertPyramidFeature
,EndCityFeature
,IglooFeature
,JigsawFeature
,JungleTempleFeature
,MineshaftFeature
,NetherFortressFeature
,NetherFossilFeature
,OceanMonumentFeature
,OceanRuinFeature
,RuinedPortalFeature
,ShipwreckFeature
,StrongholdFeature
,SwampHutFeature
,WoodlandMansionFeature
public abstract class StructureFeature<C extends FeatureConfig> extends Object
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
StructureFeature.StructureStartFactory<C extends FeatureConfig>
-
Field Summary
-
Constructor Summary
Constructors Constructor Description StructureFeature(com.mojang.serialization.Codec<C> codec)
-
Method Summary
Modifier and Type Method Description ConfiguredStructureFeature<C,? extends StructureFeature<C>>
configure(C config)
private StructureStart<C>
createStart(int chunkX, int chunkZ, BlockBox boundingBox, int referenceCount, long worldSeed)
com.mojang.serialization.Codec<ConfiguredStructureFeature<C,StructureFeature<C>>>
getCodec()
List<SpawnSettings.SpawnEntry>
getCreatureSpawns()
GenerationStep.Feature
getGenerationStep()
Gets the step during which this structure will participate in world generation.List<SpawnSettings.SpawnEntry>
getMonsterSpawns()
String
getName()
ChunkPos
getStartChunk(StructureConfig config, long worldSeed, ChunkRandom placementRandom, int chunkX, int chunkY)
Determines the cell of the structure placement grid a chunk belongs to, and returns the chunk within that cell, that this structure will actually be placed at.abstract StructureFeature.StructureStartFactory<C>
getStructureStartFactory()
protected boolean
isUniformDistribution()
If true, this structure's start position will be uniformly distributed within a placement grid cell.BlockPos
locateStructure(WorldView world, StructureAccessor structureAccessor, BlockPos searchStartPos, int searchRadius, boolean skipExistingChunks, long worldSeed, StructureConfig config)
Tries to find the closest structure of this type near a given block.static void
method_28664()
static StructureStart<?>
readStructureStart(StructureManager manager, CompoundTag tag, long worldSeed)
private static <F extends StructureFeature<?>>
Fregister(String name, F structureFeature, GenerationStep.Feature step)
protected boolean
shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom random, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, C config)
Checks if this structure can actually be placed at a potential structure position determined viagetStartChunk(net.minecraft.world.gen.chunk.StructureConfig, long, net.minecraft.world.gen.ChunkRandom, int, int)
.StructureStart<?>
tryPlaceStart(DynamicRegistryManager dynamicRegistryManager, ChunkGenerator chunkGenerator, BiomeSource biomeSource, StructureManager structureManager, long worldSeed, ChunkPos chunkPos, Biome biome, int referenceCount, ChunkRandom chunkRandom, StructureConfig structureConfig, C c)
Tries to place a starting point for this type of structure in the given chunk.
-
Field Details
-
STRUCTURES
-
STRUCTURE_TO_GENERATION_STEP
-
LOGGER
-
PILLAGER_OUTPOST
-
MINESHAFT
-
MANSION
-
JUNGLE_PYRAMID
-
DESERT_PYRAMID
-
IGLOO
-
RUINED_PORTAL
-
SHIPWRECK
-
SWAMP_HUT
-
STRONGHOLD
-
MONUMENT
-
OCEAN_RUIN
-
FORTRESS
-
END_CITY
-
BURIED_TREASURE
-
VILLAGE
-
NETHER_FOSSIL
-
BASTION_REMNANT
-
JIGSAW_STRUCTURES
-
JIGSAW_ID
-
field_25839
-
codec
private final com.mojang.serialization.Codec<ConfiguredStructureFeature<C extends FeatureConfig,StructureFeature<C extends FeatureConfig>>> codec
-
-
Constructor Details
-
StructureFeature
-
-
Method Details
-
register
private static <F extends StructureFeature<?>> F register(String name, F structureFeature, GenerationStep.Feature step) -
getGenerationStep
Gets the step during which this structure will participate in world generation. Structures will generate before other features in the same generation step. -
method_28664
public static void method_28664() -
readStructureStart
@Nullable public static StructureStart<?> readStructureStart(StructureManager manager, CompoundTag tag, long worldSeed) -
getCodec
public com.mojang.serialization.Codec<ConfiguredStructureFeature<C,StructureFeature<C>>> getCodec() -
configure
-
locateStructure
@Nullable public BlockPos locateStructure(WorldView world, StructureAccessor structureAccessor, BlockPos searchStartPos, int searchRadius, boolean skipExistingChunks, long worldSeed, StructureConfig config)Tries to find the closest structure of this type near a given block.This method relies on the given world generation settings (seed and placement configuration) to match the time at which the structure was generated, otherwise it will not be found.
New chunks will only be generated up to the
ChunkStatus.STRUCTURE_STARTS
phase by this method.- Parameters:
searchRadius
- 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.- Returns:
null
if no structure could be found within the given search radius
-
isUniformDistribution
protected boolean isUniformDistribution()If true, this structure's start position will be uniformly distributed within a placement grid cell. If false, the structure's starting point will be biased towards the center of the cell. -
getStartChunk
public final ChunkPos getStartChunk(StructureConfig config, long worldSeed, ChunkRandom placementRandom, int chunkX, int chunkY)Determines the cell of the structure placement grid a chunk belongs to, and returns the chunk within that cell, that this structure will actually be placed at.If the
StructureConfig
uses a separation setting greater than 0, the placement will be constrained to [0, spacing - separation] within the grid cell. If a non-uniform distribution is used for placement {@see #isUniformDistribution()}, then this also moves the center towards the origin. -
shouldStartAt
protected boolean shouldStartAt(ChunkGenerator chunkGenerator, BiomeSource biomeSource, long worldSeed, ChunkRandom random, int chunkX, int chunkZ, Biome biome, ChunkPos chunkPos, C config)Checks if this structure can actually be placed at a potential structure position determined viagetStartChunk(net.minecraft.world.gen.chunk.StructureConfig, long, net.minecraft.world.gen.ChunkRandom, int, int)
. Specific structures override this method to reduce the spawn probability or restrict the spawn in some other way. -
createStart
private StructureStart<C> createStart(int chunkX, int chunkZ, BlockBox boundingBox, int referenceCount, long worldSeed) -
tryPlaceStart
public StructureStart<?> tryPlaceStart(DynamicRegistryManager dynamicRegistryManager, ChunkGenerator chunkGenerator, BiomeSource biomeSource, StructureManager structureManager, long worldSeed, ChunkPos chunkPos, Biome biome, int referenceCount, ChunkRandom chunkRandom, StructureConfig structureConfig, C c)Tries to place a starting point for this type of structure in the given chunk.If this structure doesn't have a starting point in the chunk,
StructureStart.DEFAULT
will be returned. -
getStructureStartFactory
-
getName
-
getMonsterSpawns
-
getCreatureSpawns
-