Village mechanics

If you're trying to spawn golems for an iron ingot farm, or just want a few more noses to trade with in your local villager township, then you've come to the right place.

Terminology
A village is defined by several factors: the village gathering sites, radius, number of job sites, number of houses, population (number of villagers), population cap (max. number of villagers, based on housing), cat population, iron golems.

A village needs at least one house and at least one villager in order to be a "village". A "house" is a bed. A village tries to maintain its population at 100% of the number of houses if there are at least two villagers.
 * House

The village gathering site is the gathering point of village (even when not located in the middle the of village), defined by claimed bells near claimed beds. When a bell is claimed, green particles appear above the bell. Once the bell is claimed, it is registered as a gathering site. The gathering sites are where the villagers spend their mingling time during the day. If a player is in a village, a wandering trader will spawn at the gathering site. Iron golems spawn near gathering sites when villagers gossip about iron golems while mingling.
 * Gathering site

The bell must be within the village boundary to be considered the centerpiece of the village, so it needs at least 1 villager and 1 bed. If only a villager and a bell are present without beds, the villagers will search for unclaimed beds rather than mingle.

During a raid, in Java Edition villagers will go to gathering sites and ring the bell to warn other villagers. In Bedrock Edition the bell rings automatically.

If the village is big enough, adding an extra bell in a different location, but still near claimed beds, will establish a new gathering site. Villagers will split their crowd into two different clusters, one for each gathering site. A villager remembers its gathering site and pathfinds toward it during mingling time, even if another gathering site is closer.

The village size is a rectangle 32 blocks from the village center, or 32 blocks from points of interest away from the center. The village center is typically the northwest corner of the village bell, or one of the claimed beds if there is no bell. The smallest rectangular size is 64×64 blocks.
 * Size

Housing
A "house" is defined as a claimed bed. Claimed beds are beds with at least one villager, however if the bed is obstructed by a solid block, villagers will have a hard time trying to pathfind to the beds which can cause them to fail claiming beds by showing anger particles over the villager's head and on top of the beds (losing ownership of the bed, but villagers will try to re-claim it). If a villager succeeds in sleeping in an obstructed bed, the villager will suffocate and likely die, causing the bed to become unclaimed.

Once a villager has claimed a bed, the claimed bed will be registered as a house in the village and the villager will remember the position of the claimed bed, even when underground. In the evening, villagers will return to their houses (beds); however, a villager who cannot reach the bed loses ownership of the bed, allowing other villagers to claim it. The previous bed owner then forgets the house location and searches for another unclaimed bed.

Job site
Naturally spawned villagers start as unemployed, but can also spawn as a nitwit. They will change their profession by seeking for an unclaimed job site block.

Naturally generated villages consist of two main buildings: a house (any building with beds) and a job site (a building with job site blocks). In the job site building, no villagers will spawn. If a naturally generated village consists of only job site buildings, then no villagers will spawn, and the village will not be registered as a village.

Employed villagers will spend their time working at their job site block, starting in the morning. Unemployed villagers, nitwits, and baby villagers have no job site. Just like claimed beds, once a villager chooses a job site block, the villager will remember its position. They work at morning and at afternoon after mingling at the gathering site.

Overlapping boundaries
Main article: Tutorials/Village_chaining

Transporting villagers
There are several ways to transport villagers. This can be very useful if you are planning to create a new village.

Minecart technique
The first technique is the minecart technique, where you build a minecart track from the village to the end destination, and push the villagers one by one into a cart and push the cart to the destination.

Water tunnel technique
The second is more tedious but requires less resources. Create a tunnel from one location to another, with no exits along the way (2×2, for example), then grab two water Buckets. Use water to push them down the path a few blocks, then use the second bucket to push them further, grab the first water, and repeat.

With the revisions to the water mechanics introduced in Update Aquatic, this is an effective technique: Place a water source block and allow it to flow over several empty blocks at the same level. Place an ice block topped with a pressure plate or sign under the last block of flowing water. Repeat the process until you reach your intended destination. (This works best when buried underground and while well lit to keep mobs from killing your villagers in transit. Otherwise, you need to build a cover over the area you're using to keep them safe.) Then, if you need to move them upwards, create an upward bubble column and lift the villagers to the destination.

Boat technique
A third technique is to transport villagers using a boat. Since Java Edition 1.9, mobs may enter boats, and players can enter the same boat and operate it while the mob sits in the back. This allows players to transport villagers over water, but also over land (albeit very slowly). To move the boat upwards, you have to use a piston to travel up one block or create a bubble column to travel up multiple levels.

Using Nether portals
The final and potentially least tedious method of transporting villagers is the "Nether Portal Method". Most entities, including villagers, can travel through Nether Portals. Keep in mind that this strategy involves more complications if Nether portals have already been constructed in the Nether (see here for more details). Create a portal in the destination, enter Nether through that portal, and immediately return to the Overworld. Then travel to the nearest Village (it must be within 1024 distance of the first portal) and build another portal there. You can either use a minecart or manually push the villagers into the portal to transport them to the Nether. (pushing villagers in is easier if the portal's bottom blocks are level to the ground) Enter the portal and push the villagers out of the portal in the Nether, then wait about 30 seconds. After the villagers undergo "cooldown", they can be pushed back through the portal and should exit from the first portal that you constructed.

After reaching the destination, they may accidentally reenter the portal, so it is a good idea to block off the portal by surrounding it with a fence.

Breeding and population cap
Villagers breed without player intervention, but there must be at least two adult villagers who can reach each other. If you are starting a village from scratch, or recovering from zombie villagers and there are no villagers left (or only one), then you need to acquire more, using one of these methods:
 * Hauling them in from another village, possibly using a method in the above section
 * Bringing them up from an igloo basement
 * Curing zombie villagers
 * Using commands or Spawn Eggs

Villagers will go into love mode (indicated by red heart particles above both their heads), if they have enough food to make themselves and their partner willing. They will enter love mode based on their amount of food, not the population cap (ie. the number of beds). If the population cap is already met, the villagers will also have angry particles above their heads (along with the heart particles), preventing them from mating. Much like with farm animals, when two villagers are in love mode and can see each other, they will pathfind towards the other and stare for a few seconds, after which a baby villager will spawn next to them. Breeding villagers does not drop experience. This new villager will take on clothing dependent on the biome the village is in. It will not acquire a job until it has grown up and there is a valid, unclaimed job site.

Willingness
Villagers must be "willing" in order to breed. After mating, they will no longer be willing and must be traded with again before becoming willing again.

Villagers can become willing if the player trades with them. Willingness is granted the first time a new offer is traded, or at a one-in-five chance on subsequent trades. This will not cause them to immediately seek out a mate, however.

Villagers can also become willing by having either 3 bread, 12 carrots 12 potatoes, or 12 beetroots in their inventory. Farmer villagers will throw harvested crops at villagers, allowing them to pick them up to obtain enough food to become willing.

Curing zombie villagers
Players can cure Zombie Villagers by a Golden Apple on them while they are affected by weakness. Players can usually apply weakness by brewing potions. In Nether-disabled servers, you will need to get a witch and a zombie villager. Witches sometimes throw a Splash Potion of Weakness (if a player is within 3 meters), which you can use to your advantage.

After you've used the splash potion of weakness and the golden apple, the zombie will make a loud sizzling sound, emit orange swirly particles, and begin to shake violently. It takes up to 5 minutes for them to convert, so go ahead and trap them somewhere, and make sure they won't burn in the sunlight or hurt any nearby villagers. After a few minutes, they will turn into regular villagers.

5% of zombies are zombie villagers, so it shouldn't take you too long to find two that you can cure. Additionally, when a villager is attacked by a zombie (any zombie) there is a chance (50% on normal difficulty, and 100% on hard) that they will turn into a zombie villager instead of just being killed. Zombie villagers are a great way to start an artificial village, because unlike villagers, zombie villagers will follow the player long distances. Then when they arrive at the desired location, they can be cured.

Popularity
A player's popularity starts at zero and ranges between −30 and 10. The following can alter a player's popularity: A player's popularity does not reset on death, and players cannot alter other players' popularity. Popularity is stored per village; a player may have a high popularity in one village and a very low one in another. When a player acts directly on a villager, particles around that villager will indicate the change in popularity. Conversely, because popularity is stored per village, if the entire village is destroyed, any accumulated popularity, positive or negative, is also eliminated.

If a player has -15 popularity or less, the village's naturally-spawned iron golems act hostile to that player until the player's popularity is increased by trading. Golems constructed by the player, however, are always passive toward the player.

Cats
The number of cats spawned in a village is based on the number of beds in that village. Cats require only one villager, and one cat can spawn for every four beds. The beds don't need to be claimed. Up to 40 beds can be present for a max of 10 cats, and cats will respawn based on the number of beds.

If there are two villages, each already with 10 cats, merging the villages into single village will not cause any cats to despawn. However, the number of cats is still capped at 10, so no new cats will spawn until the number of cats is below 10.

Iron golems
Iron golem always spawn at the meeting point in naturally generating villages. However iron golems can also spawn from villagers who meet near gathering sites.

Zombie sieges
At night, there is a chance that a zombie siege might occur. This is when a large number of zombies spawn in or near a village, attacking what villagers they can reach, crowding around and pounding on the doors of those they can't. On hard or hardcore mode, they can actually break down the wooden doors (this is true of all zombies, not just during sieges.) A zombie siege requires a village of at least 10 houses and at least 20 villagers.

Zombies in sieges ignore light levels and the 24-block minimum distance from the player, but other than that, behave absolutely normal (i.e., they will not spawn on glowstone or any other transparent or half block, need a 2×1×1 minimum space, etc.). They can also spawn INSIDE doors, making Iron Golem farms difficult to build on hard, as zombies beat down doors on hard (they'll attempt to beat them down on other difficulties, but not succeed). However, zombies won't spawn 128 blocks away from you, even though the siege is technically happening in the game code, so you're safe if you build it high up. You can make houses virtually zombie-proof simply by taking out one ground block from directly in front of the door, and, if necessary, rehanging the door such that the outside is "smooth," i.e. the door's position on its ground block runs consistent with the outside wall. This is because zombies can break only the top half of a door, and if they have to jump, they will never get through.

Raids
When a player with the 'Bad Omen' debuff enters a village, the Bad Omen effect will disappear and a raid will occur. Raids are groups of Illagers (Pillagers, Vindicators, Evokers, Ravagers, and Witches) attacking the village with the intent of killing villagers. You can remove the 'Bad Omen' debuff by drinking milk before entering a village to prevent raids; however, you can also defend a village from a raid, at which point you will gain the 'Hero of the Village' buff. This will cause villagers to give you steep discounts during trading, as well as bestow various gifts upon you.