Skip to content

MobPreSpawnEvent 5.46.0 ​

class · pocketmine\event\entity\MobPreSpawnEvent · source

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() : string

The mob's identifier, e.g. "minecraft:zombie".

getPosition() ​

php
public function getPosition() : \pocketmine\world\Position

Where the mob (or the first mob of the herd) would spawn.

getReason() ​

php
public function getReason() : string

One of the SpawnReason constants.

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