Skip to content

StructureManager 5.46.0 ​

final class · pocketmine\world\generator\vanilla\structure\StructureManager · source

The structures of one generator (dimension): where structure starts are (placement + start generation, a pure function of the seed so every worker thread agrees), and their placement chunk by chunk during decoration (vanilla's STRUCTURE_STARTS / STRUCTURE_REFERENCES statuses and the structure part of applyBiomeDecoration()).

Starts are computed on demand and kept in a bounded cache; nothing is shared between threads.

Properties ​

$env ​

php
public readonly \pocketmine\world\generator\vanilla\structure\StructureEnvironment $env

$startsComputed ​

php
public int $startsComputed

Methods ​

__construct() ​

php
public function __construct(\pocketmine\world\generator\vanilla\structure\StructureEnvironment $env, string $positionMode = \pocketmine\world\generator\vanilla\structure\placement\BedrockStructurePlacements::MODE_BEDROCK, array $disabled = [], array $dimensionBiomes = [])

getBeardifier() ​

php
public function getBeardifier(int $chunkX, int $chunkZ) : ?\pocketmine\world\generator\vanilla\structure\Beardifier

The terrain adaptation of the structures referenced by a chunk (Beardifier.forStructuresInChunk()), for the terrain filler, or null if there is none. Starts are computed if needed (from the terrain without adaptation, like vanilla's STRUCTURE_STARTS before NOISE).

getPlacement() ​

php
public function getPlacement(string $setId) : ?\pocketmine\world\generator\vanilla\structure\placement\StructurePlacement

getPlacements() ​

php
public function getPlacements() : array

getSetStructures() ​

php
public function getSetStructures(string $setId) : array

getStart() ​

php
public function getStart(string $setId, int $chunkX, int $chunkZ) : ?\pocketmine\world\generator\vanilla\structure\StructureStart

The start of a structure set in a chunk, or null (ChunkGenerator.createStructures() for one set).

getStartsAffecting() ​

php
public function getStartsAffecting(int $chunkX, int $chunkZ, bool $adaptingOnly = false) : array

The starts whose bounding box touches the chunk (vanilla's structure references of the chunk).

hasStructureChunkInRange() ​

php
public function hasStructureChunkInRange(string $setId, int $chunkX, int $chunkZ, int $range) : bool

ChunkGeneratorStructureState.hasStructureChunkInRange()

isStructureChunk() ​

php
public function isStructureChunk(string $setId, int $chunkX, int $chunkZ) : bool

StructurePlacement.isStructureChunk() for a set (cached).

locate() ​

php
public function locate(string $structure, int $x, int $z, int $radius = 100, ?int $maxChunks = null, ?\Closure $accept = null, ?int $deadlineNs = null) : ?array

Finds a start of a structure (an id, a pattern like "village_*", or a structure set id) around a block position like Java Edition's /locate (ChunkGenerator.getNearestGeneratedStructure()): placement chunks are searched ring by ring of spacing-sized regions, up to $radius rings, and the first start found in a ring is the candidate of its set; the nearest candidate of all sets wins. Returns [structure id, start chunk x, start chunk z, locate x, locate y, locate z] or null.

With $maxChunks, the number of rings of each set is derived from that distance in chunks instead (rounded up to whole regions; ring-placed starts farther than that are skipped). $accept, if given, filters starts by their start chunk (e.g. only chunks that are not generated yet). $deadlineNs (an hrtime() value) bounds the time spent: past it a LocateTimeoutException is thrown.

placeStep() ​

php
public function placeStep(\pocketmine\world\generator\vanilla\structure\StructurePlaceContext $c, array $starts, int $step, int $chunkX, int $chunkZ, int $decorationSeed, \pocketmine\world\generator\vanilla\feature\FeatureRandom $random) : void

Places the structures of a decoration step in a chunk (before the step's features), like ChunkGenerator.applyBiomeDecoration(): each structure gets the random setFeatureSeed(decorationSeed, index, step).

tryGenerate() ​

php
public function tryGenerate(\pocketmine\world\generator\vanilla\structure\StructureDefinition $structure, int $chunkX, int $chunkZ) : ?\pocketmine\world\generator\vanilla\structure\StructureStart

Structure.generate(): finds the generation point, checks its biome and builds the pieces.

VanillaMine is a fork of PocketMine-MP, maintained by Luxury Nodes. Not affiliated with the PMMP team or Mojang.