Skip to content

Village 5.46.0 ​

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

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 PoiManager and \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 = 32

BORDER_VERTICAL ​

php
public const BORDER_VERTICAL = 12

EXPANSION_HORIZONTAL ​

php
public const EXPANSION_HORIZONTAL = 32

EXPANSION_VERTICAL ​

php
public const EXPANSION_VERTICAL = 52

OMEN_RANGE_HORIZONTAL ​

php
public const OMEN_RANGE_HORIZONTAL = 32.0

Half 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.5

Methods ​

__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) : bool

findAll() ​

php
public static function findAll(array $pois, array $villagers, array $claimed = []) : array

Groups POIs into villages. Villager positions decide which groups are villages (see the class doc).

getBeds() ​

php
public function getBeds() : array

getBells() ​

php
public function getBells() : array

getBounds() ​

php
public function getBounds() : \pocketmine\math\AxisAlignedBB

The village boundary: the box around the POIs, ±32 blocks horizontally and ±12 vertically.

getCenter() ​

php
public function getCenter() : \pocketmine\math\Vector3

getClaimedBedCount() ​

php
public function getClaimedBedCount() : int

Number of beds claimed by villagers.

getFreeBeds() ​

php
public function getFreeBeds() : array

Beds no villager claimed.

getJobSites() ​

php
public function getJobSites() : array

getVillagerCount() ​

php
public function getVillagerCount() : int

isInOmenRange() ​

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

Whether a player there with Bad Omen gets Raid Omen (Bedrock: within 64x23x64 blocks around the centre).

isValid() ​

php
public function isValid() : bool

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

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