MoveToBlockGoal 5.47.0
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
public const MAX_TICKS = 1200Longest run of the goal.
SEARCH_INTERVAL
public const SEARCH_INTERVAL = 200Ticks between two searches, plus up to as many at random.
Properties
$condition
public ?\Closure $condition$goalRadius
public float $goalRadius$mob
public \pocketmine\entity\Mob $mob$searchHeight
public int $searchHeight$searchRange
public int $searchRange$speedMultiplier
public float $speedMultiplierMethods
__construct()
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()
public function canContinue() : boolcanStart()
public function canStart() : boolfindTarget() protected
abstract protected function findTarget(int $x, int $y, int $z) : ?\pocketmine\math\Vector3Returns the block to go to (the position of the mob's feet there), or null.
getFlags()
public function getFlags() : intgetTarget()
public function getTarget() : ?\pocketmine\math\Vector3Returns the block the mob is going to, null when the goal isn't running.
linkOpposite()
public function linkOpposite(\pocketmine\entity\ai\goal\MoveToBlockGoal $other) : voidLinks 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()
public function resetSearchDelay() : voidMakes the next search happen right away (tests, plugins).
start()
public function start() : voidstop()
public function stop() : voidtick()
public function tick() : voidwantsToMove() protected
abstract protected function wantsToMove() : boolWhether 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.
