Villager

A Villager (previously called a Testificate) is an intelligent passive NPC.

Spawning
Villagers will not despawn even if the player wanders away from them.

Natural generation
Villagers naturally spawn in villages inside various buildings. They spawn at their respective buildings corresponding to the role they have.

Baby villagers
Villagers can be bred, spawning baby villagers. After exactly 20 minutes, the baby villager will grow up to an adult. See this section for more information.

Zombie villagers
Villagers will spawn if the player uses a Splash Potion of Weakness on a Zombie Villager and then feeds it a regular Golden Apple. It will then shake and turn into a villager within 5 minutes.

Behavior
Upon spawning, villagers will leave their homes and begin to explore the village. They will go and explore other buildings, make sounds and frequently open and close doors. Afterwards, they will begin to head to the outskirts of the village, though they will never actually leave the village itself. Occasionally, two villagers may stop, and turn to look at each other, in a behavior called socializing. They will do this with each other, other mobs and players, and even certain blocks.

Villagers will not willingly fall off high cliffs that would kill them, but may occasionally take fall damage. They will not stay away from fire or lava or change their behavior around fires. They will just carry on as usual, and rarely, but possibly, walk straight into the fire and cacti. They will not flee, run, or change their behavior when being damaged by fire or cacti.

At night, or during the rain, the villagers will run inside, closing doors behind them, staying indoors until the morning. In the morning, the villagers will head outside, fleeing from any remaining zombies. Once the Zombies are gone, the villagers will resume normal behavior.

There is evidence that villagers are prone to overcrowding certain areas of a village while leaving other areas completely empty. There is speculation that villagers will crowd predictably into set areas; however, exactly which areas has still not been discovered. It has been noticed they crowd their church/watchtower very often at certain times of the day. The overcrowding can lead to villagers swarming into a few houses at night rather than spreading themselves. The sheer amount of villagers trying to enter such a small area can result in a portion of the villagers taking more time to enter the safety of their homes. In extreme cases, some villagers will become stranded outside. There is no known way to prevent this type of overcrowding. A portion of this behavior is due to a bug. See issue for more details.

Farmers
As of, farmers will head out to check on their crops. If the farmer finds wheat that has fully grown in a 16 block radius, they will harvest and replant them, turning wheat to bread. They will keep most of the food for themselves, but can sometimes be seen giving food to other villagers. After their "inventories" have been filled up, they will continue to tend to crops, but will not pick up anything they collect. This can be used as an automated farm, with hopper minecarts under the farmland to pick up any crops the villager didn't pick up first. The villagers will pick up 8 stacks of items before their "inventory" is full.

Baby villagers


Baby villagers will sprint about, entering and leaving houses at will. They will also chase each other around the village to simulate that they are playing tag. They will sometimes stop sprinting to stare at an Iron Golem. If the Iron Golem is holding a poppy, the children will cautiously take the flower from its hands.

Unlike other breed-able mobs, the parents and child have no personal interactions other than socializing; except, when a baby villager is attacked, it usually runs towards its parents.

Zombies
Zombies will find villagers from up to 31 block radius, and will attempt to break down doors. However, the doors will only be destroyed if the difficulty is set to hard. Villagers will run away from zombies, which attempt to attack villagers. The villager's only "natural" defense are the Iron Golems, which protect villagers from nearby mobs.

Zombies will kill villagers, or convert them to zombie villagers. The chance that the villager will become a zombie villager on death is 0% on Easy, 50% on Normal, and 100% on Hard. Baby villagers can be infected by zombies as well. Baby zombie villagers will not burn in daylight and run faster.

Breeding


Villagers will mate depending on the number of valid doors. Villagers will then mate until the number of adult villagers equals 35% of the number of doors. Any remaining children will grow up as usual, resulting in a total number of adult villagers somewhere above one third of the number of nearby wooden doors. The type of villager that the child is doesn't depend on what type the parents are.

A valid door is any door within the city radius where the number of "outside" spaces within 5 blocks in a straight line on one side of the door is not the same as the number of "outside" spaces within 5 blocks on the other side of the door. A space is considered to be "outside" if it has nothing but transparent blocks above it all the way to the sky.

The game engine periodically takes a census to determine the current population of the village. All villagers within the horizontal boundary of the village and within 5 vertical blocks of the center will be counted as part of the population to determine if continued villager mating is allowed. However, any villager within the horizontal boundary of the village and within a vertical distance of 32 blocks downwards of the center of the village will attempt to enter mating mode as long as there is at least one villager within the boundary. If two villagers simultaneously enter mating mode while they are close to one another, they will mate with each other and produce a child.

Willingness
As of, villagers must "willing" inorder to breed. After mating, they will no longer be willing and must be traded with again before becoming willing again.

Villagers can become willing by the player trading 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 them having either 3 bread, 12 carrots or 12 potatoes in their inventory. Farmer villagers will throw harvested crops at villagers, allowing them to pick it up to obtain enough food to become willing.

Professions and Careers
Each villager has a profession, which can be identified by their clothing.

In Snapshot 14w02b and later, villagers also have careers specific to their profession. The player can identify a villager's profession by reading the title at the top of the trading interface. Below is a table listing the various villagers, with their careers in relation to their professions, as well as the IDs specifying these.

Notes:
 * Generic villagers can only be spawned via summon command or external editing.
 * Currently, Generic Villagers can trade 9 Gold Ingots for 1 Emerald and will only make this offer 6 more times and will not make any more trade offers after this.
 * As of 14w04b, the game will crash if you attempt to trade with them.

Trading


The trading system is a gameplay mechanic that allows players to trade emeralds for items and vice-versa with villagers.

Right-clicking a villager will allow a player to trade with them, and display their career. Villagers will make offers based on their profession and career, and will only make trades based on whatever offers they are making. Different offers may be viewed by pressing the left and right buttons next to the currently displayed offer. Most offers involve emerald as a currency, and some item pertinent to the villager's profession and career. Trading allows the acquisition of uncommon items that would otherwise be fairly difficult to obtain, such as chain armor. It is also the only legitimate method of acquiring a Bottle o' Enchanting in survival mode. When villagers get a new trade, purple particles and green cross particles appear.

After trading once, the villager will open a new trade after a short period of time. After a few trades the villager will lock the trade offer. When this happens you will have to use the last trade offer in the villager's window once and then wait for a short time and all previous trades will reopen. There is a maximum number of trades each villager can possess. Once the villager has maxed out its number of trades, it will not open any new ones. However, then you will be able to renew all offers by trading for the last item in the villager's list.

When a villager gives off particles from a new trade, they get 10 seconds of regeneration, which gives them 8 health points or 4 hearts.

In, villagers can now spawn with more than one initial trade, depending on the first tier of their career. Villagers also unlocked trades in tiers, and have a maximum amount of tiers they can unlock. Trades can also be unlocked by trading any available offer.

Trivia

 * The villagers were inspired by the shop keepers in Dungeon Master 2.
 * Notch has agreed that villagers look like "Caveman Squidwards".
 * Sometimes, when children are playing tag, a child may grow up and still be playing tag until the villagers stop for a break. The adult will then continue with a normal life.
 * Originally, the mobs populating villages were to be pigmen.
 * Villagers treat Zombie Pigmen as Zombies, running from them. However, Zombie Pigmen will not chase or attack Villagers.
 * This is because the Zombie shares code with the Zombie Pigman
 * In Pocket Edition, villagers flee from all hostile mobs, as well as endermen and spiders.
 * You can manually spawn baby villagers in creative by right-clicking the villager with their spawn egg.
 * Since villagers will buy renewable resources from you for emeralds, emeralds and anything purchased with them may be considered renewable.
 * If you sleep in the presence of villagers, they will look at the spot where your head would be if you were standing on the bed.
 * It is possible to name baby villagers with name tags but not adult villagers without the help of another player trading while you use the name tag.
 * When a villager gets infected by a zombie, they also have a chance to spawn as a baby.
 * Renaming a Zombie Villager and curing it will not create a Villager with the same name.
 * A child villager infected by a zombie can rarely spawn as a generic baby zombie.
 * When villagers walk along a walkway, they prefer to remain near the edges of the walkway rather than the center of the walkway.
 * A blue robed villager makes a cameo in the promotional image for the Horse Update along with a generic villager.
 * setting the game rule  to false disables farmer villagers ability to harvest crops.

April fools
On April 1st 2014, Mojang announced that villagers have taken over the skin servers and content delivery networks (CDN) as an April Fools joke. This caused players' current skin to turn into villager skins. This also caused users to unable to change their skins. Different career villager skins were used, including the unused generic villager (green robe).

Many of the sounds were also changed, supposedly by the villagers. They seem to be similar to a villager talking (with words, rather than their normal sounds). The in-game music has also been altered to include villager like noises, and also features a villager version of the "Game of Thrones" theme on the title screen. The sounds originate from the sound resource pack created by Element Animation, titled The Element Animation Villager Sound Resource Pack (T.E.A.V.S.R.P), which is based on the villagers appearing in their fan videos.