GoHomeGoal 5.47.0
Extends Goal
Goes back to the mob's home position (see \pocketmine\entity\HomeTrait) from time to time (vanilla behavior.go_home): with a 1 in $interval chance per tick while farther than $goalRadius blocks from it, the mob walks (swims, flies) there; once within $goalRadius $onHome runs (Bedrock on_home). A mob that is already home when the goal gets its chance runs $onHome straight away.
A home farther than GoHomeGoal::LEG_LENGTH blocks is reached in legs of that length towards it (a turtle swims back to the beach it hatched on from hundreds of blocks away): each leg is one bounded path search. When a leg ends without getting the mob at least a block closer (no way there), the goal fails: $onFailed runs (Bedrock on_failed) and the goal waits for its next chance.
Constants
LEG_LENGTH
public const LEG_LENGTH = 24.0Blocks of each leg towards a distant home.
Properties
$condition
public ?\Closure $condition$goalRadius
public float $goalRadius$interval
public int $interval$mob
public \pocketmine\entity\Mob $mob$onFailed
public ?\Closure $onFailed$onHome
public ?\Closure $onHome$speedMultiplier
public float $speedMultiplierMethods
__construct()
public function __construct(\pocketmine\entity\Mob $mob, float $speedMultiplier = 1.0, int $interval = 120, float $goalRadius = 0.5, ?\Closure $onHome = null, ?\Closure $onFailed = null, ?\Closure $condition = null)canContinue()
public function canContinue() : boolcanStart()
public function canStart() : boolgetFlags()
public function getFlags() : intstart()
public function start() : voidstop()
public function stop() : voidtick()
public function tick() : void