Skip to content

EntityNaturalSpawnEvent 5.46.0 ​

class · pocketmine\event\entity\EntityNaturalSpawnEvent · source

Extends EntityEvent
Implements Cancellable

Called when the world spawns a mob by itself (natural spawning around players, structure spawns, wandering traders, village cats), after the mob was created and before it is shown to players. The mob can still be changed (equipment, name...). Cancelling it closes the mob.

Constants ​

CAUSE_NATURAL ​

php
public const CAUSE_NATURAL = 0

Bedrock cluster spawning with the spawn rules (including herd members and phantoms).

CAUSE_STRUCTURE ​

php
public const CAUSE_STRUCTURE = 1

Structure spawns (e.g. witch huts, nether fortresses) registered by a structure spawn provider.

CAUSE_VILLAGE_CAT ​

php
public const CAUSE_VILLAGE_CAT = 3

A stray cat of a village.

CAUSE_WANDERING_TRADER ​

php
public const CAUSE_WANDERING_TRADER = 2

A wandering trader and its trader llamas.

Methods ​

__construct() ​

php
public function __construct(\pocketmine\entity\Living $entity, int $cause, bool $surface)

getCause() ​

php
public function getCause() : int

One of the CAUSE_* constants.

isSurface() ​

php
public function isSurface() : bool

Whether the mob spawned on the surface (Bedrock counts surface and underground mobs separately for the caps).

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