DefendTrustedTargetGoal 5.47.0
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
public const DEFAULT_RANGE = 25.0within_radius of foxes.
Properties
$canTarget
public ?\Closure $canTarget$mob
public \pocketmine\entity\Mob $mob$onDefend
public ?\Closure $onDefend$onStop
public ?\Closure $onStop$range
public float $range$trustedEntities
public \Closure $trustedEntitiesMethods
__construct()
public function __construct(\pocketmine\entity\Mob $mob, \Closure $trustedEntities, float $range = self::DEFAULT_RANGE, ?\Closure $onDefend = null, ?\Closure $onStop = null, ?\Closure $canTarget = null)canContinue()
public function canContinue() : boolcanStart()
public function canStart() : boolgetFlags()
public function getFlags() : intstart()
public function start() : voidstop()
public function stop() : void