Skip to content

MonsterSpawner ​

class · pocketmine\block\MonsterSpawner · source

Extends Transparent

Monster spawner. While a player (not a spectator) is within RequiredPlayerRange (16) blocks, the delay counts down; then SpawnCount (4) attempts each pick a spot within SpawnRange (4) blocks horizontally and one block up or down, and spawn the mob there if its box is free of blocks and liquids, monsters are allowed (not Peaceful) and it is dark enough for monsters (light 7 or less, 11 in the Nether). Nothing spawns while MaxNearbyEntities (6) mobs of the type are within SpawnRange of the spawner. After a spawn the delay is drawn again between MinSpawnDelay (200) and MaxSpawnDelay (800) ticks (vanilla BaseSpawner.serverTick).

Constants ​

MONSTER_LIGHT_LIMIT 5.46.0 ​

php
public const MONSTER_LIGHT_LIMIT = 7

NETHER_MONSTER_LIGHT_LIMIT 5.46.0 ​

php
public const NETHER_MONSTER_LIGHT_LIMIT = 11

Methods ​

getDropsForCompatibleTool() ​

php
public function getDropsForCompatibleTool(\pocketmine\item\Item $item) : array

getSupportType() ​

php
public function getSupportType(int $facing) : \pocketmine\block\utils\SupportType

getXpDropAmount() protected ​

php
protected function getXpDropAmount() : int

onInteract() 5.46.0 ​

php
public function onInteract(\pocketmine\item\Item $item, int $face, \pocketmine\math\Vector3 $clickVector, ?\pocketmine\player\Player $player = null, array &$returnedItems = []) : bool

Using a spawn egg on a spawner sets the mob it shows (and would spawn). The egg is consumed outside creative.

onScheduledUpdate() ​

php
public function onScheduledUpdate() : void

tickSpawner() 5.46.0 ​

php
public function tickSpawner(\pocketmine\block\tile\MonsterSpawner $tile, int $elapsed = 1) : int

Runs the spawner for the elapsed ticks while a player is near. Returns the number of mobs spawned.

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