Skip to content

MoveToBlockGoal 5.47.0 ​

abstract class · pocketmine\entity\ai\goal\MoveToBlockGoal · source

Extends Goal

Walks (or swims) to a block of some kind found nearby while the mob is somewhere it doesn't want to be: out of water, in water, off lava (vanilla behavior.move_to_water, move_to_land, move_to_lava and move_to_liquid). The search only runs while the mob wants to move, and at most once every 10-20 seconds (Java MoveToBlockGoal), the first one right away. The goal ends when the mob is where it wanted to be (being within $goalRadius of the block is not enough: a wide mob stops at its edge), after 60 seconds, when the path found doesn't lead there (fenced in water...), or when it can't get any closer.

Constants ​

MAX_TICKS ​

php
public const MAX_TICKS = 1200

Longest run of the goal.

SEARCH_INTERVAL ​

php
public const SEARCH_INTERVAL = 200

Ticks between two searches, plus up to as many at random.

Properties ​

$condition ​

php
public ?\Closure $condition

$goalRadius ​

php
public float $goalRadius

$mob ​

php
public \pocketmine\entity\Mob $mob

$searchHeight ​

php
public int $searchHeight

$searchRange ​

php
public int $searchRange

$speedMultiplier ​

php
public float $speedMultiplier

Methods ​

__construct() ​

php
public function __construct(\pocketmine\entity\Mob $mob, float $speedMultiplier = 1.0, int $searchRange = 16, int $searchHeight = 5, float $goalRadius = 0.5, ?\Closure $condition = null)

canContinue() ​

php
public function canContinue() : bool

canStart() ​

php
public function canStart() : bool

findTarget() protected ​

php
abstract protected function findTarget(int $x, int $y, int $z) : ?\pocketmine\math\Vector3

Returns the block to go to (the position of the mob's feet there), or null.

getFlags() ​

php
public function getFlags() : int

getTarget() ​

php
public function getTarget() : ?\pocketmine\math\Vector3

Returns the block the mob is going to, null when the goal isn't running.

linkOpposite() ​

php
public function linkOpposite(\pocketmine\entity\ai\goal\MoveToBlockGoal $other) : void

Links two goals of a mob which take it to opposite places (move_to_water and move_to_land): once one of them got the mob there, the other one waits a full search interval, so the mob stays a while instead of going straight back.

resetSearchDelay() ​

php
public function resetSearchDelay() : void

Makes the next search happen right away (tests, plugins).

start() ​

php
public function start() : void

stop() ​

php
public function stop() : void

tick() ​

php
public function tick() : void

wantsToMove() protected ​

php
abstract protected function wantsToMove() : bool

Whether the mob wants to go somewhere else (out of water for move_to_water...). Called on every goal evaluation while the goal can start: must be cheap.

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