Skip to content

Goal 5.46.0 ​

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

A behaviour of a mob (wander, panic, attack...). Goals are run by a GoalSelector: a goal starts when Goal::canStart() returns true and no running goal with a higher priority holds any of its control flags, and stops when Goal::canContinue() returns false or a more important goal needs one of its flags.

Constants ​

FLAG_JUMP ​

php
public const FLAG_JUMP = 4

The goal makes the mob jump.

FLAG_LOOK ​

php
public const FLAG_LOOK = 2

The goal turns the mob's head (look control).

FLAG_MOVE ​

php
public const FLAG_MOVE = 1

The goal moves the mob (pathfinding, move control).

FLAG_TARGET ​

php
public const FLAG_TARGET = 8

The goal selects the mob's attack target.

Methods ​

canContinue() ​

php
public function canContinue() : bool

Returns whether the running goal should keep running. Called every AI tick.

canStart() ​

php
abstract public function canStart() : bool

Returns whether the goal should start now. Called only every few ticks (see GoalSelector), so it may do moderately expensive checks.

getFlags() ​

php
public function getFlags() : int

Returns a bitmask of the FLAG_* constants this goal needs exclusively while it runs.

isInterruptible() ​

php
public function isInterruptible() : bool

Returns whether a goal with a higher priority may stop this goal to take its flags.

start() ​

php
public function start() : void

stop() ​

php
public function stop() : void

tick() ​

php
public function tick() : void

Called every AI tick while the goal runs.

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