EntityNaturalSpawnEvent 5.46.0
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 = 0Bedrock cluster spawning with the spawn rules (including herd members and phantoms).
CAUSE_STRUCTURE
php
public const CAUSE_STRUCTURE = 1Structure spawns (e.g. witch huts, nether fortresses) registered by a structure spawn provider.
CAUSE_VILLAGE_CAT
php
public const CAUSE_VILLAGE_CAT = 3A stray cat of a village.
CAUSE_WANDERING_TRADER
php
public const CAUSE_WANDERING_TRADER = 2A 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() : intOne of the CAUSE_* constants.
isSurface()
php
public function isSurface() : boolWhether the mob spawned on the surface (Bedrock counts surface and underground mobs separately for the caps).
