Village 5.46.0
A village, worked out from the points of interest players can build (Bedrock village mechanics, simplified):
- POIs are beds (houses), bells (gathering sites) and job site blocks. Villagers claim beds and job sites (see
PoiManagerand\pocketmine\entity\npc\VillagerV2); the claimed ones are known to the village (Village::getClaimedBedCount(),Village::getFreeBeds()). - A bed starts a village whose boundary is the bed ±32 blocks horizontally and ±12 vertically (Bedrock's initial 64x24x64 box). POIs within the expansion range of a village (32 more blocks horizontally, 52 vertically) join it and the boundary grows to the box around all its POIs, again ±32/±12. Unclaimed POIs join too (Bedrock only counts claimed ones), so that the fallback below has a boundary.
- It is a village when a villager claimed one of its beds (Bedrock). Fallback for villages without (loaded) villagers that claimed a bed: at least one bed and either a villager inside the boundary or a bell. It lets players build a village, and raids happen in it, before villagers move in or while they are unloaded.
- The centre is the middle of the box around its POIs (Bedrock uses the first bed while the village hasn't grown).
Constants
BORDER_HORIZONTAL
php
public const BORDER_HORIZONTAL = 32BORDER_VERTICAL
php
public const BORDER_VERTICAL = 12EXPANSION_HORIZONTAL
php
public const EXPANSION_HORIZONTAL = 32EXPANSION_VERTICAL
php
public const EXPANSION_VERTICAL = 52OMEN_RANGE_HORIZONTAL
php
public const OMEN_RANGE_HORIZONTAL = 32.0Half sizes of the region around the centre where Bad Omen turns into Raid Omen (Bedrock: 64x23x64).
OMEN_RANGE_VERTICAL
php
public const OMEN_RANGE_VERTICAL = 11.5Methods
__construct()
php
public function __construct(array $beds, array $bells, array $jobSites, int $villagers, \pocketmine\math\AxisAlignedBB $poiBox, ?array $freeBeds = null)contains()
php
public function contains(\pocketmine\math\Vector3 $pos) : boolfindAll()
php
public static function findAll(array $pois, array $villagers, array $claimed = []) : arrayGroups POIs into villages. Villager positions decide which groups are villages (see the class doc).
getBeds()
php
public function getBeds() : arraygetBells()
php
public function getBells() : arraygetBounds()
php
public function getBounds() : \pocketmine\math\AxisAlignedBBThe village boundary: the box around the POIs, ±32 blocks horizontally and ±12 vertically.
getCenter()
php
public function getCenter() : \pocketmine\math\Vector3getClaimedBedCount()
php
public function getClaimedBedCount() : intNumber of beds claimed by villagers.
getFreeBeds()
php
public function getFreeBeds() : arrayBeds no villager claimed.
getJobSites()
php
public function getJobSites() : arraygetVillagerCount()
php
public function getVillagerCount() : intisInOmenRange()
php
public function isInOmenRange(\pocketmine\math\Vector3 $pos) : boolWhether a player there with Bad Omen gets Raid Omen (Bedrock: within 64x23x64 blocks around the centre).
isValid()
php
public function isValid() : boolWhether this counts as a village: a villager claimed one of its beds, or (fallback) it has at least one bed and a villager or a bell.
