PoiManager 5.46.0
The village points of interest of a world (beds, bells, job sites) and which villager claimed each one.
POIs are found per chunk with VillageScanner::findPoiBlocks() and cached: a chunk is scanned again when a POI block is placed or removed in it (see PoiManager::onBlockChanged(), called by the world for every block change, a single array lookup) or after PoiManager::CACHE_TICKS. Scans of loaded chunks without POIs cost one palette check per sub-chunk.
Claims (Bedrock "minecraft:dweller"): a bed or job site belongs to at most one villager, identified by its runtime entity ID. The villager keeps the claimed positions in its NBT and registers them again when it is loaded; claims are released when it dies or is unloaded.
Constants
CACHE_TICKS
public const CACHE_TICKS = 6000Ticks after which the POIs of a chunk are scanned again even if no POI block changed.
Methods
__construct()
public function __construct(\pocketmine\world\World $world)claim()
public function claim(\pocketmine\math\Vector3 $pos, int $entityId) : boolClaims the POI for the entity. Returns false if another entity claimed it already.
countBeds()
public function countBeds(int $minX, int $minY, int $minZ, int $maxX, int $maxY, int $maxZ) : arrayCounts the beds (claimed and free) in the box.
findNearestFree()
public function findNearestFree(\pocketmine\world\raid\PoiType $type, \pocketmine\math\Vector3 $pos, int $horizontal, int $vertical, ?\Closure $filter = null, ?\Closure $positionFilter = null) : ?\pocketmine\math\Vector3Returns the unclaimed POI of the type nearest to the position within the given distances, if any.
getClaimant()
public function getClaimant(\pocketmine\math\Vector3 $pos) : ?intRuntime ID of the entity that claimed the POI, or null.
getClaims()
public function getClaims() : arraygetPois()
public function getPois(int $minX, int $minY, int $minZ, int $maxX, int $maxY, int $maxZ) : arrayReturns the POIs of the loaded chunks inside the box (beds at their head), with their block type IDs.
getScanCount()
public function getScanCount() : intNumber of chunk scans done so far (for tests and benchmarks).
invalidateChunk()
public function invalidateChunk(int $chunkX, int $chunkZ) : voidForgets the cached POIs of a chunk.
isClaimed()
public function isClaimed(\pocketmine\math\Vector3 $pos) : boolonBlockChanged()
public function onBlockChanged(int $chunkHash, int $oldStateId, int $newStateId) : voidCalled by the world when a block changes: the POIs of the chunk are scanned again if a POI block appeared or disappeared.
release()
public function release(\pocketmine\math\Vector3 $pos, int $entityId) : voidReleases the POI if the entity claimed it.
tick()
public function tick(int $currentTick) : voidtryGolemCheck()
public function tryGolemCheck(int $x, int $z, int $currentTick, int $interval) : boolWhether the iron golem summoning conditions of the 32x32 area around the position may be checked now (at most once every $interval ticks per area, so that crowds of villagers don't count each other over and over).
