Zombie siege



Zombie sieges are in-game events that occur when many zombies spawn in a village, regardless of how well lit or walled off a village is.

Mechanics
At midnight each night (18000 in Minecraft time), there is a 10% chance that a zombie siege will spawn, and attempt to invade a house that night. If a siege is to occur, attempts will be made each tick to start the siege until either a siege is successfully started, or the sun rises. Specifically, the siege attempt is abandoned when the sky light level reaches 12; however, inclement weather can allow siege start attempts to continue well past dawn, since it reduces the sky light level.

Siege start checks


Each village has a center (defined as the geometric center of all the village's doors) and a size (either 32 or the euclidean distance of the farthest door from the center, whichever is greater). For each player, the village with the center nearest to that player is a candidate for a siege when the player is less than the village's size + 1 blocks away from the center (by euclidean distance). In other words, the player must essentially be within the village for a siege to be considered.

If the candidate village has fewer than 10 doors, fewer than 20 villagers, or the village has not been "stable" (no doors added or removed) for at least 20 ticks (1 second), the next player's village is considered.

Ten attempts are made to choose a random siege starting point on a circle with a radius 0.9 times that of the village's size centered upon a village that is not within the bounds of any other village. The Y value of the chosen point is that of the center of the village. If all ten attempts fail, the entire siege attempt fails, but another siege may be attempted on the next game tick.

If a valid siege starting point is found, a location is chosen (as described below) as if to spawn one zombie. If that succeeds in finding a valid zombie spawning point, the siege is started at the chosen starting point. Otherwise, the next player's village is considered.

Zombie spawning


During a siege, 20 attempts are made to spawn a zombie over the course of 2 seconds. For each zombie, 10 attempts are made to randomly choose a valid spawning point within a 16×16×6 box around the chosen point. If a valid spawn point is found, a zombie is spawned.

Zombies spawned within a siege ignore player proximity, light levels, and the presence of other mobs. Only the minimal spawning conditions are checked: Note in particular that siege zombies can spawn inside transparent blocks such as slabs that normally prevent mob spawning.
 * the spawning block must be transparent and non-fluid
 * the block directly below it must have a solid top surface
 * this includes upside down stairs and slabs
 * the block directly below it must not be bedrock
 * the block directly above it must be transparent as well
 * the block must be within the target village

Zombie villagers and Husks are never spawned as part of a siege, but all other variations (e.g. baby, jockey, and equipment) are determined as for normal random spawns.

For the most part, the zombies that spawn as part of a siege will behave in the same manner as normally-spawned zombies; they will attack all villagers within sight, and villagers and iron golems will react accordingly. The zombies will also despawn as usual if the player is far enough away. If the zombies happen to wander away a certain distance (greater than the size of the village) from the center of the village, they will return towards the village center if they are not actively pursuing a target.

Recovery
If at least two villagers survive the siege and doors are rebuilt as necessary, the villagers can mate and repopulate the village. The village will be safe from future sieges until the population reaches 20. Without player intervention, however, it is likely that villages will be wiped out by sieges and randomly-spawned zombies.

Even if no villagers survive, a village may be repopulated by curing zombie villagers, or by luring in villagers from another village.

Trivia

 * Sieges can occur on mushroom islands, despite zombies not spawning on mushroom islands naturally.