Monster Spawner

Monster spawners are blocks that can spawn mobs.

Obtaining
Spawners can not be obtained at all in survival mode. The proper tool to mine them with is the pickaxe.

It is also not in Creative mode inventory (except in Pocket Edition) and as such must be obtained with commands.

Natural generation
Spawners can generate naturally in these places, spawning mobs chosen randomly when generated:
 * Dungeons
 * It may be a zombie spawner (50% chance), skeleton spawner(25%), or spider spawner (25%).


 * Abandoned mine shafts
 * Spawns Cave Spiders. Located in horizontal tunnels, heavily surrounded by cobwebs.
 * In Pocket Edition it spawns regular spiders instead.


 * Strongholds
 * Spawns silverfish. Located in the End Portal room. One per stronghold.


 * Nether Fortresses
 * Spawns Blazes. Located on Nether fortress balconies with stairs leading up to them.

Behavior
A spawner will spawn mobs in the surrounding area, provided suitable spawning locations for the block's mob type can be found in the area. Spawner blocks can spawn some mobs in mid-air, ignoring general rules about spawning on solid ground. The spawned mob can be changed by a spawn egg on the spawner.

A monster spawner is only active when a player is within a radius of 16 blocks from the spawner. While the block is active, it will spawn mobs within an 8×2×8 block volume (8 wide and 2 high and 8 long) centered on the center of the block, effectively meaning mobs can spawn in a 9x9 area, or 3.5 blocks from the spawner. Mobs can spawn anywhere in this range that is suitable, with mobs more likely to spawn closer to the spawner than farther away.

While mobs are spawned at fractional x and z-coordinates (i.e. not aligned to blocks), they are spawned at an integer y-coordinate. Horizontally, a mob can spawn with its center point anywhere within the 8 × 8 range, but vertically, mobs will spawn with their legs at either the same layer as the spawner block, one block above it, or one block below it. Therefore, there are 3 vertical blocks of space in which mobs can spawn even though the spawning volume is only two blocks in height.

For some types of mobs to spawn in the outer planes of the spawning volume, some planes outside the volume may also need to be free of opaque blocks to conform with the mobs' height, width, or other rules governing their individual spawn volumes. For mobs that are two or more blocks tall such as zombies, skeletons, or blazes to spawn in the top y-layer, the layer above that must contain only air.

In Creative Mode of Pocket Edition monster spawners are inside the player's creative inventory. However, when placed, it will appear as an empty cage. To trigger the spawner, the player must tap on it while holding the spawn egg of the desired mob. In Survival Mode they will function like their PC counterparts.

For all of the volumes listed in the table, the horizontal plane is centered on the center of the spawner block. While the spawning volume for pigs is 8.9×8.9×2.9, the requirement of grass blocks that are necessary for pigs to spawn will reduce the actual volume in which they successfully spawn.

The block will attempt to spawn 4 mobs at randomly chosen points within the spawning area, then wait anywhere from 200 to 799 ticks (10 to 39.95 seconds) before spawning again. As it waits, the mob inside the block will spin faster and faster. Except for spawning on a solid block, all of the usual requirements for spawning must be met (not in a solid block, correct light level, etc.), so the spawner will often produce fewer than 4 mobs. When it does spawn, it will "poof", and more lightless flames will temporarily appear around the Spawn block. If the block fails to spawn any mobs because it did not pick any suitable locations, it will repeat this process every tick until it succeeds. Only when it manages to spawn at least one mob will it start waiting for the next cycle. If, at the time of spawning, 6 or more mobs of the spawner's type are present within a 9×9×9 area, centered on the spawner block, the spawner "poofs" without creating any mobs and then waits for the next cycle.

In Peaceful difficulty, monster spawner blocks will still appear and work, but any spawned hostile mobs will disappear the instant they spawn. Zombie Pigmen, Magma Cubes, and Ghasts will not spawn at all.

An interesting quirk of monster spawners (and end portal frames and slime blocks) is that they are transparent in their rendering only - unlike all other transparent blocks, they can have torches and redstone placed on them, conduct a redstone current, will suffocate mobs, and more.

Detailed spawning algorithm
This pseudo-code is derived from the de-compiled source of 1.7.10 if (there is a player within the range of activatingRangeFromPlayer) {   if (spawner delay == -1) {       reset spawner delay }

if (spawner delay > 0) {       decrement spawner delay by 1 cancel this spawn }

loop for the number of entities we should spawn {       if (the number of entityTypeName in a 2*spawnRange+1 centered cube > maxNearbyEntities) { reset spawner delay exit loop }

X = Spawner.x + random(spawnRange*2)-spawnRange; Y = Spawner.y + random(3)-1; Z = Spawner.z + random(spawnRange*2)-spawnRange;

if (entity can spawn at (X,Y,Z)) {           Spawn entityTypeName at (X,Y,Z) Play Sound Effect Spawn Particles }   }

if (at least one entity was spawned) {       reset spawner delay } }

Default values: activatingRangeFromPlayer = 16 spawner delay = 20 maxNearbyEntities = 6 spawn range = 4 entityTypeName = Pig

Outcomes (default): A player must be within a 16 block centered sphere There must not be more than 6 pigs within a 9x9x9 centered cube The pig must be able to spawn at the chosen location (must not be inside a block, meet lighting conditions etc.) If all mobs fail to spawn, it will try again on the very next tick.

Custom spawners
Monster spawners are capable of much more than they are used for in survival Minecraft. Using commands, they can be customized in many ways:
 * They can be made to spawn any kind of entity.
 * A single spawner can spawn multiple different entities, chosen at random from a list.
 * Properties can be set on the spawned entities.
 * Various range and timing properties of the spawner can be altered.

Detailed technical information about custom spawners can be found in the chunk format reference.

Block entity

 * Tile entity data
 * : X coordinate of the Tile Entity.
 * : Y coordinate of the Tile Entity.
 * : Z coordinate of the Tile Entity.
 * : Optional. List of possible entities to spawn. If this tag does not exist, but SpawnData exists, Minecraft will generate it the next time the spawner tries to spawn an entity. The generated list will contain a single entry derived from the EntityId and SpawnData tags.
 * : A potential future spawn. After the spawner makes an attempt at spawning, it will choose one of these entries at random and use it to prepare for the next spawn.
 * : Overwrites EntityId when preparing the next spawn.
 * : The chance that this spawn will be picked as compared to other spawn weights. Must be non-negative and at least 1.
 * : Overwrites the contents of SpawnData when preparing the next spawn. Not optional; an empty one will be created if it does not exist.
 * : The Entity ID of the next entity(s) to spawn. Both Mob Entity IDs and other Entity IDs will work. Warning: If SpawnPotentials exists, this tag will get overwritten after the next spawning attempt: see above for more details.
 * : Contains tags to copy to the next spawned entity(s) after spawning. Any of the Entity or Mob tags may be used. Note that if a spawner specifies any of these tags, almost all variable data such as mob equipment, villager profession, sheep wool color, etc., will no longer be automatically generated, and must also be manually specified (note that this does not apply to position data, which will be randomized as normal unless Pos is specified. Similarly, unless Size and Health are specified for a Slime or Magma Cube, these will still be randomized). This, together with EntityId, also determines the appearance of the miniature entity spinning in the spawner cage. Note: this tag is optional: if it does not exist, the next spawned entity will use the default vanilla spawning properties for this mob, including potentially randomized armor (this is true even if SpawnPotentials does exist). Warning: If SpawnPotentials exists, this tag will get overwritten after the next spawning attempt: see above for more details.
 * : How many mobs to attempt to spawn each time.
 * : The radius around which the spawner attempts to place mobs randomly. The spawn area is square, includes the block the spawner is in, and is centered around the spawner's x,z coordinates - not the spawner itself. It is 2 blocks high, centered around the spawner's y coordinate (its bottom), allowing mobs to spawn as high as its top surface and as low as 1 block below its bottom surface. Vertical spawn coordinates are integers, while horizontal coordinates are floating point and weighted towards values near the spawner itself. Default value is 4.
 * : Ticks until next spawn. If 0, it will spawn immediately when a player enters its range. If set to -1 (this state never occurs in a natural spawner; it seems to be a feature accessed only via NBT editing), the spawner will reset its Delay, and (if SpawnPotentials exist) EntityID and SpawnData as though it had just completed a successful spawn cycle, immediately when a player enters its range. Note that setting Delay to -1 can be useful if you want the game to properly randomize the spawner's Delay, EntityID, and SpawnData, rather than starting with pre-defined values.
 * : The minimum random delay for the next spawn delay. May be equal to MaxSpawnDelay.
 * : The maximum random delay for the next spawn delay. Warning: Setting this value to 0 crashes Minecraft. Set to at least 1.
 * : Overrides the maximum number of nearby (within a box of spawnrange*2+1 x spawnrange*2+1 x 8 centered around the spawner block) entities whose IDs match this spawner's entity ID. Note that this is relative to a mob's hitbox, not their physical position. Also note that all entities within all chunk sections (16x16x16 cubes) overlapped by this box are tested for their ID and hitbox overlap, rather than just entities which are within the box, meaning a large amount of entities outside the box (or within it, of course) can cause substantial lag.
 * : Overrides the block radius of the sphere of activation by players for this spawner. Note that for every gametick, a spawner will check all players in the current world to test whether a player is within this sphere. Note: Requires the MaxNearbyEntities property to also be set.
 *  (removed) : Unknown.
 *  (removed) : Unknown.
 *  (removed) : Unknown.
 *  (removed) : Unknown.
 *  (removed) : Unknown.
 *  (removed) : Unknown.

Trivia

 * Unlike most other solid blocks, the monster spawner supports texture with transparent areas, without showing what's behind.
 * When mining near a monster spawner that has no valid places to spawn, sometimes a monster will spawn immediately after a block is mined. It's speculated this might happen because the spawner gets a chance to spawn before the lighting calculation for the space the block occupied.
 * If a spawner is made to spawn a Giant, Ghast, or Iron Golem; the mob inside will be larger than the spawner and will appear to physically extend beyond the confines of the spawner block's sides.
 * The miniature mob inside the monster spawner is an actual mob of that type. Thus, if a spawner is configured to spawn Ender Dragons or Withers, their boss health bar is visible while looking at the spawner.