Skip to content

DefendTrustedTargetGoal 5.47.0 ​

class · pocketmine\entity\ai\goal\DefendTrustedTargetGoal · source

Extends Goal

Attacks whoever hurt an entity the mob trusts (vanilla behavior.defend_trusted_target of foxes bred by players, within_radius 25, must_see false; Java Fox.DefendTrustedTargetGoal). $onDefend runs when the mob takes the attacker as its target (the fox growls and switches to its defending_fox group), $onStop when it gives up the target. $canTarget can rule attackers out (a fox never turns on another player it trusts).

The trusted entities are looked up every 10 ticks only (Java: a 1 in 10 chance per tick), and only while the mob has no target of its own. Only hits which happened since the previous look-up count: the damage a trusted entity took before the mob first saw it (a fox just bred or loaded, a player who just came back to the world) is old and ignored (Java: only the last 100 ticks of getLastHurtByMob count).

Constants ​

DEFAULT_RANGE ​

php
public const DEFAULT_RANGE = 25.0

within_radius of foxes.

Properties ​

$canTarget ​

php
public ?\Closure $canTarget

$mob ​

php
public \pocketmine\entity\Mob $mob

$onDefend ​

php
public ?\Closure $onDefend

$onStop ​

php
public ?\Closure $onStop

$range ​

php
public float $range

$trustedEntities ​

php
public \Closure $trustedEntities

Methods ​

__construct() ​

php
public function __construct(\pocketmine\entity\Mob $mob, \Closure $trustedEntities, float $range = self::DEFAULT_RANGE, ?\Closure $onDefend = null, ?\Closure $onStop = null, ?\Closure $canTarget = null)

canContinue() ​

php
public function canContinue() : bool

canStart() ​

php
public function canStart() : bool

getFlags() ​

php
public function getFlags() : int

start() ​

php
public function start() : void

stop() ​

php
public function stop() : void

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