Skip to content

RandomPos 5.46.0 ​

final class · pocketmine\entity\ai\navigation\RandomPos · source

Picks random standable positions around a mob (wandering, panicking, fleeing).

Methods ​

getAirPos() ​

php
public static function getAirPos(\pocketmine\entity\Mob $mob, int $horizontal, int $vertical, int $maxAboveGround = 6, ?\pocketmine\math\Vector3 $awayFrom = null) : ?\pocketmine\math\Vector3

Returns the centre of a random air block within range (not water, nothing dangerous) with ground at most $maxAboveGround blocks below it, or null after 10 failed tries. Used by flying mobs.

getLandPos() ​

php
public static function getLandPos(\pocketmine\entity\Mob $mob, int $horizontal, int $vertical, ?\pocketmine\math\Vector3 $awayFrom = null, bool $allowWater = false) : ?\pocketmine\math\Vector3

Returns a random block (feet position) within $horizontal blocks around the mob and $vertical blocks up or down where it can stand, or null after 10 failed tries.

getWaterPos() ​

php
public static function getWaterPos(\pocketmine\entity\Mob $mob, int $horizontal, int $vertical, ?\pocketmine\math\Vector3 $awayFrom = null) : ?\pocketmine\math\Vector3

Returns the centre of a random water block within range where the mob fits (water up to its height), or null after 10 failed tries. Used by swimming mobs.

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