Tutorials/Zombie siege defense

Staying in a village overnight may result in a Zombie siege: Zombies will spawn near the outskirts of the village, regardless of light level, and attack the villagers.

Mechanics
While the villagers will try to hide in their houses, some may fail to get to safety, and on the Hard difficulty level zombies can break down doors. These sieges can kill off all the villagers within a couple of nights. (On Normal or Hard difficulties, most or all of the villagers would become zombies themselves, which would eventually despawn or burn.) Sufficiently large villages may have Iron Golems to help defend them, but almost any village is likely to become depopulated within a few sieges unless the player provides help. Even when two villagers survive, villager breeding is much too slow to recover from the regular deaths.

There is also the matter that Villager AI is woefully insufficient for their survival – even without sieges, they are prone to falling into nearby caves or pits and becoming lost, dancing on cactus, inviting zombies in, and otherwise committing suicide. Furthermore, even the naturally spawned zombies still hunt villagers, and have become much more dangerous: besides summoning aid and powering up when the player attacks, they can now see the player and sense villagers for a large distance. Note that if there are less than two villagers remaining at any time, they will be unable to breed their numbers back up, and the village will not be viable. Even with two villagers, there also need to be at least nine doors within range before they will breed.

If there are no valid spawning locations within the "siege zone" at Y values between 3 below and 2 above the village's center, sieges cannot start in that village. This can also be used to force any sieges to start at a particular location.

If all players in the Overworld sleep before midnight, sieges will not be able to start. Similarly, if all players remain outside the bounds of villages between midnight and dawn, there will be no candidate villages.

Tactics
Accordingly, player assistance is needed to help a village survive. Some suggestions:
 * 1) Surrounding a village with a wall and lighting it are staple defenses against normal hostile mobs, especially Creepers. A wall will work for sieges as well, as long as the wall is far enough inside the village boundary (i.e. if the village radius is 32, the wall must be within a circle with radius 20).
 * 2) Iron Golems will attempt to kill any zombies. Snow Golems may serve as a distraction, as their snowballs may cause the zombies to attack them rather than the villagers. Similarly, villagers trapped in a ring of fences may distract zombies from more vulnerable villagers.
 * 3) Until the village is secured (see below), players should not spend a waking night within 128 blocks (their mob despawning radius) of the village borders. Rather than risking a stray zombie getting in, set up a bed and sleep in it as soon as the sun reaches the horizon. Then go out the moment you wake up to finish off any monsters still within the town, even if they're already on fire. Trying to fight zombies at night is a bad idea, because each one you fight will call in more, and if there are any gaps in the lighting, those can spawn within the village. Daylight helps to break this vicious circle – but watch out for baby and helmeted zombies, neither of whom will burn.
 * 4) As a temporary measure until your barricades are done, you can wait until the villagers have gone indoors, then place blocks or fence gates outside doors, to barricade all the villagers inside their houses.  The villagers won't be able to wander, and the zombies won't be able to attack them.
 * 5) Remove any stairs in front of doors, and rehang the doors to face outwards. Zombies can only break the top half of a door; if they have to jump, they will never get through, but their knocking will announce their presence.
 * 6)  As quickly as possible, secure the village against nighttime monsters. While this won't protect against an actual siege, it will keep other monsters (especially creepers) from spawning or entering during the night, which they will do if a player is nearby. Left to themselves, mobs besides zombies will not attack villagers, but they will attack the player, and creepers coming after players may blow up parts of the village.
 * 7) * Light the entire area – outside, inside buildings, and even the flat parts of roofs. While you're lighting the well's roof, you might stick a ladder on the well's inside edge as another safety measure, or else top the well up to full.
 * 8) * Block off or remove any natural hazards in or near the town – caves, steep drops, open lava, and so on. For desert villages, clear all cacti out of the area.
 * 9) * Build a fence or cobblestone wall completely around the village, with gates for your convenience. As usual, make sure that nearby blocks do not allow mobs to jump over the wall from outside. Tree farming (especially a "jungle giant") and/or a cobblestone generator can provide enough material for the barricades. Some internal barricades may also help, dividing the town into sectors that can be defended separately.
 * 10) * If possible, post cats around the perimeter – you can post occasional dogs as well, but remember that dogs won't get into a fight until you do. (And remember to heal or replace them as needed!)
 * 11) Each morning, the player should quickly replace any doors that have been broken. However do not put a door on the blacksmith as it will kill villagers off (they will consider the outside to be the inside). Don't try replacing the doors with iron doors – the zombies can't break them, but neither will the villagers recognize an iron door as a "village door" for spawning purposes.
 * 12) Zombies will not merely kill villagers, but can convert them to Zombie Villagers (50% chance on Normal difficulty, 100% on Hard). Also, natural zombie spawns have a small chance of being Zombie Villagers. If a player has been to a Nether Fortress, they may be able to cure these unfortunates as follows:
 * 13) * Splash them with a Potion of Weakness
 * 14) * Feed them a Golden Apple (ingot version)
 * 15) * Wait. The cure takes several minutes, so you will want to prevent them from burning or otherwise dying (or despawning) before they recover. A covered corral will work, but it may be easier to prepare a house for them: Make sure there are at least two doors, and lock the villagers out by putting gates in front of those. Then you can lead the weakened zombie in there and escape by the other door. (A potion of Swiftness – or Slowing on the zombie – might help.) On Hard mode, you may need to add shade outside the exits, lest your patient break down the door and expose themselves to sunlight. If the zombie is damaged, splash potions of harming can be used to heal it a little, increasing its chances of surviving.
 * 16) Curing naturally-spawned Zombie Villagers can repopulate a desolate village. Once you have two villagers in the village, you can cause them to start breeding by trading with them or giving them appropriate food, provided the village is of a reasonable size. You can also build up the population or even create new villages this way (see below).
 * 17) Create new Iron Golems. You can never have too many.
 * 18) Fight back. If you see Iron Golems failing to do their job and a Villager is about to be killed, attack with everything you've got. A sword, an axe, your own fists, whatever it does to keep the villager alive. Even if Iron Golems are doing their job, that doesn't mean you can't help.
 * 19) Create new houses. Once your village has too many villagers, a house can overflow during a siege causing villagers to be automatically pushed out of the house when another villager enters it. Creating new houses with a door will allow these villagers to simply find another house and hide there instead.
 * 20) Place snow golems on roofs. Snow golems will die once it rains, so it is vital that you place something above them so they will be safe from rain. Snow golems can slow down the zombies during a zombie siege so the Iron Golems can attack without the zombie attacking fleeing villagers (Don't do this in a desert biome)