Skip to content

EntityTargetEvent 5.46.0 ​

class · pocketmine\event\entity\EntityTargetEvent · source

Extends EntityEvent
Implements Cancellable

Called when a mob picks a new attack target (like Paper's EntityTargetLivingEntityEvent): a monster spotting a player, a zombie going for a villager, a wolf hunting, a mob fighting back... Cancelling it keeps the mob without a target; the target can also be replaced. NPC plugins use it so that mobs leave their NPCs alone.

Methods ​

__construct() ​

php
public function __construct(\pocketmine\entity\Mob $entity, \pocketmine\entity\Living $target)

getTarget() ​

php
public function getTarget() : \pocketmine\entity\Living

setTarget() ​

php
public function setTarget(\pocketmine\entity\Living $target) : void

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