Skip to content

StrollTowardsVillageGoal 5.47.0 ​

class · pocketmine\entity\ai\goal\StrollTowardsVillageGoal · source

Extends Goal

Walks to a village nearby (vanilla behavior.stroll_towards_village of foxes at night: search_range 32, start_chance 0.005, cooldown 10 s, goal_radius 3; that is how foxes end up among the chickens of villages): a random point of interest of a village (a bell first, else a bed or a job site) within $searchRange blocks.

The points of interest come from the world's cached POI data (World::getPoiManager()), asked only when the start chance is met (about once every 10 seconds per mob), and only while $condition allows it (night).

Properties ​

$condition ​

php
public ?\Closure $condition

$cooldown ​

php
public int $cooldown

$goalRadius ​

php
public float $goalRadius

$mob ​

php
public \pocketmine\entity\Mob $mob

$searchRange ​

php
public int $searchRange

$speedMultiplier ​

php
public float $speedMultiplier

$startChance ​

php
public float $startChance

Methods ​

__construct() ​

php
public function __construct(\pocketmine\entity\Mob $mob, float $speedMultiplier = 1.0, int $searchRange = 32, float $startChance = 0.005, int $cooldown = 200, float $goalRadius = 3.0, ?\Closure $condition = null)

canContinue() ​

php
public function canContinue() : bool

canStart() ​

php
public function canStart() : bool

getFlags() ​

php
public function getFlags() : int

pickTarget() ​

php
public function pickTarget(\pocketmine\world\World $world, \pocketmine\math\Vector3 $from) : ?\pocketmine\math\Vector3

Returns a random point of interest of a village within the search range farther than the goal radius: a bell if there is one, else a bed or a job site.

start() ​

php
public function start() : void

stop() ​

php
public function stop() : void

tick() ​

php
public function tick() : void

VanillaMine is a fork of PocketMine-MP. Not affiliated with the PMMP team or Mojang.