MobPreSpawnEvent 5.46.0
Extends Event
Implements Cancellable
Called before the natural spawner creates a mob (or a herd), like Paper's PreCreatureSpawnEvent: nothing has been created yet, so cancelling costs nothing. A plugin with its own mobs can use it to stop the server's natural spawning of some types, e.g. cancel every "minecraft:zombie" with reason SpawnReason::NATURAL.
EntityNaturalSpawnEvent follows for each mob that is created.
Methods
__construct()
php
public function __construct(string $entityIdentifier, \pocketmine\world\Position $position, string $reason)getEntityIdentifier()
php
public function getEntityIdentifier() : stringThe mob's identifier, e.g. "minecraft:zombie".
getPosition()
php
public function getPosition() : \pocketmine\world\PositionWhere the mob (or the first mob of the herd) would spawn.
getReason()
php
public function getReason() : stringOne of the SpawnReason constants.
