Skip to content

PoiManager 5.46.0 ​

final class · pocketmine\world\raid\PoiManager · source

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 ​

php
public const CACHE_TICKS = 6000

Ticks after which the POIs of a chunk are scanned again even if no POI block changed.

Methods ​

__construct() ​

php
public function __construct(\pocketmine\world\World $world)

claim() ​

php
public function claim(\pocketmine\math\Vector3 $pos, int $entityId) : bool

Claims the POI for the entity. Returns false if another entity claimed it already.

countBeds() ​

php
public function countBeds(int $minX, int $minY, int $minZ, int $maxX, int $maxY, int $maxZ) : array

Counts the beds (claimed and free) in the box.

findNearestFree() ​

php
public function findNearestFree(\pocketmine\world\raid\PoiType $type, \pocketmine\math\Vector3 $pos, int $horizontal, int $vertical, ?\Closure $filter = null, ?\Closure $positionFilter = null) : ?\pocketmine\math\Vector3

Returns the unclaimed POI of the type nearest to the position within the given distances, if any.

getClaimant() ​

php
public function getClaimant(\pocketmine\math\Vector3 $pos) : ?int

Runtime ID of the entity that claimed the POI, or null.

getClaims() ​

php
public function getClaims() : array

getPois() ​

php
public function getPois(int $minX, int $minY, int $minZ, int $maxX, int $maxY, int $maxZ) : array

Returns the POIs of the loaded chunks inside the box (beds at their head), with their block type IDs.

getScanCount() ​

php
public function getScanCount() : int

Number of chunk scans done so far (for tests and benchmarks).

invalidateChunk() ​

php
public function invalidateChunk(int $chunkX, int $chunkZ) : void

Forgets the cached POIs of a chunk.

isClaimed() ​

php
public function isClaimed(\pocketmine\math\Vector3 $pos) : bool

onBlockChanged() ​

php
public function onBlockChanged(int $chunkHash, int $oldStateId, int $newStateId) : void

Called by the world when a block changes: the POIs of the chunk are scanned again if a POI block appeared or disappeared.

release() ​

php
public function release(\pocketmine\math\Vector3 $pos, int $entityId) : void

Releases the POI if the entity claimed it.

tick() ​

php
public function tick(int $currentTick) : void

tryGolemCheck() ​

php
public function tryGolemCheck(int $x, int $z, int $currentTick, int $interval) : bool

Whether 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).

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