Skip to content

NearestLivingTargetGoal 5.46.0 ​

class · pocketmine\entity\ai\hostile\goal\NearestLivingTargetGoal · source

Extends Goal

Targets the nearest living entity in range accepted by a filter (vanilla behavior.nearest_attackable_target with entity filters other than "player": endermen hunting endermites, zoglins attacking everything, piglins hunting hoglins...). Players are only accepted when they can be targeted (survival or adventure).

Properties ​

$filter ​

php
public \Closure $filter

$interval ​

php
public int $interval

$mob ​

php
public \pocketmine\entity\Mob $mob

$mustSee ​

php
public bool $mustSee

$playersOnly ​

php
public bool $playersOnly

$range ​

php
public float $range

Methods ​

__construct() ​

php
public function __construct(\pocketmine\entity\Mob $mob, \Closure $filter, float $range = 16.0, bool $mustSee = true, int $interval = 10, bool $playersOnly = false)

canContinue() ​

php
public function canContinue() : bool

canStart() ​

php
public function canStart() : bool

findTarget() protected ​

php
protected function findTarget() : ?\pocketmine\entity\Living

getFlags() ​

php
public function getFlags() : int

players() ​

php
public static function players(\pocketmine\entity\Mob $mob, \Closure $filter, float $range = 16.0, bool $mustSee = true, int $interval = 10) : self

Targets the nearest targetable player accepted by the filter.

start() ​

php
public function start() : void

stop() ​

php
public function stop() : void

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