[The last major rewrite of this guide was for version 1.3/1.4, as such, some of this info may be outdated; particularly, the iron golems' aggression behavior is incorrect, and doesn't account for the new "reputation" mechanic, but there may be other errors as well. I do plan to take care of this soon; in the meantime, if you see anything else that needs attention, please let me know either by posting in the thread or shoot me a PM.]
(video courtesy of qmagnet)
VILLAGE MECHANICS: A NOT-SO-BRIEF GUIDE
...or "Everything you (n)ever wanted to know about NPC villages, but were afraid to ask." 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 testificate township, then you've come to the right place. Much of what's in here comes from another forum thread originally posted by Marfagames. Special thanks also go out to forum members trunkz and KyoShinda, both frequent posters in that same thread. Together the three of them made most of this information available in the first place -- all I did was digest what they wrote and re-word it into something that I, and I'm hoping you as well, could understand a little easier. For a more detailed look at what's going on with your village, you might want to try out the Village Info mod created by trunkz. It adds a few lines to your F3 screen indicating if you're in or near a village, and info about its size, population (both current and maximum,) number of houses, etc. If you're interested in farming iron golems for their ingots, he's also put together a tutorial video for a really excellent iron golem farm. Links to both can be found at the end of this post. And now, on to the good stuff!
SECTION ZERO: TERMINOLOGY
...or "What is this I don't even." A village is defined by several factors: the village center, radius, number of houses, population (number of villagers), population cap (max. number of villagers, based on housing), number of golems, and golem cap (based on population).
You might be asking yourself, "what does it take to make a village?" A village needs two things, in order to be a "village." It needs houses (at least one) and villagers (again, at least one.) A "house" is defined simply as a wooden door with an "inside" and an "outside" (see the next section for details.) A village's population is capped at 35% of the number of "houses" (doors.) Under ideal conditions, villagers will breed up to this limit, and then stop.
The village center is the geometric center point, or "average coordinates" of all the doors. The village radius is the distance from this center point to the furthest door, or 32 blocks, whichever is greater. This means that the radius is always at least 32, no matter what, but it can be more than that if there are any houses further than 32 blocks from the center. If there are any, then the radius is the distance to the furthest one, instead. Both the center point and radius are rounded to whole numbers; I'm actually not sure if they round up, down, or to the nearest.
SECTION 1: HOUSING
...or "You can't park here." A "house" is defined as a wooden door with an "inside" and an "outside." The "inside" is the side which has more spaces covered by "roof" blocks than the other, within five spaces horizontally of the door in the two directions it faces. A "roof" block is an opaque block at any height that blocks direct sunlight from reaching the spaces below it.
Another way to put it would be to say that an "outside" space has a direct view of the sky, and so has a "SL" (sky light) value of 15. An "inside" space does not have a direct view of the sky (not looking straight up, anyway) and a "SL" value of less than 15. The "inside" is the side which has more "inside spaces" than the "outside" (which, in turn, has more "outside spaces" than the "inside.")
A door is not counted as a house without a "roof," or with the same number of covered spaces on either side.
Example - The door is placed on the wooden planks. The game checks the spaces represented by the light blue wool, to see if they are covered by a "roof" block or not:
The simplest house looks something like this. Just a wooden door, with a dirt block on the ground next to it:
Not much to look at, is it? But it fits the criteria. The dirt blocks the light from reaching the space below it, and so counts as a roof block. There is one "inside" space, covered by a roof block, on the right side of the image (represented by the red wool below) and zero on the left. Since one is more than zero, there are more covered spaces on one side of the door than there are on the other, and so the game counts this as a house:
The following are all examples of houses as well:
It doesn't matter what you build, except for what's directly above the colored wool. Anything to the sides of this can be whatever you want, or nothing at all:
A door is two blocks tall, and this check is performed twice per door, if necessary. If the inital "roof check" (see Fig. 1) fails, then the bottom-most layer is ignored and the check is performed a second time, starting one layer higher. This time, only the spaces above the lime-green wool are checked for roof blocks:
Example - For the door pictured below, the initial roof check finds there are two spaces covered by roof blocks on the left side, and two covered spaces on the right also. With the same number of covered spaces on each side, neither one can be designated the "inside" or the "outside," and so the door is not counted as a house (yet. But but we're not through yet, either.):
Then since the initial check failed, the bottom layer is ignored, and we perform the test again, this time checking for roof blocks only above (not level with) the green wool. This time, only the two spaces on the left-hand side of the image are covered. Since the "roof check" passed on this second try, the door counts as a house, and its "inside" is on the left where the more covered spaces are:
In the next example, the door passes the test on the initial first check. It has one covered space on the left side and two on the right. This makes it a house with the "inside" to the right. The second check would pass as well (with the "inside" on the left this time), but since the first one already passed, we don't even bother testing again. This door counts as a house, with the "inside" on the right:
The covered spaces don't have to be contiguous. The door below is a house, with the "inside" on the right, which has three covered spaces within the 5-space limit, while the left side has only two:
This next door has three covered spaces on each side, and is not a house:
A house is initiated by a nearby villager. Without a villager nearby, it is not considered a "house," just some blocks and a door:
But as soon as that villager shows up, it becomes a house (and a village):
Villagers will recognize a house within sixteen blocks along both horizontal axes, and up to three blocks above or five blocks below the level of the ground the villager is standing on:
When two villages' boundaries overlap, they will merge into a single, larger village. A new house that's within (radius + 32) of an existing village would, were it considered a village in its own right, overlap with the existing village and so just becomes a part of that village. This causes a recalculation of the village's radius and center point, which can sometimes cause it to overlap with another already-existing village. When this happens, the game doesn't always handle it correctly right away. It is possible to end up with a situation where two villages overlap and are still treated as separate villages.
The same thing can happen in reverse: if houses are removed from the center of a large village, the remaining ones may constitute two separate, smaller villages whose radii do not overlap, but the game may still treat them as a single, large village.
When the placing or removal of blocks causes what-was-once-a-house to become no-longer-a-house, the game can fail to update this as well and still treat the door as if it should count as a house. Relogging used to fix this issue, reevaluating the village from scratch when you came back, but now, since 1.4 and later, the village is saved to the world file and so simply relogging does not cause a reevaluation. You will actually have to bust out and replace the door itself (or use the fix presented below) for it to stop being counted as a "house."
In all three circumstances, the fix is rather simple. Just walk, ride, or boat far enough away that the chunks are unloaded from memory, and this will cause a reevaluation upon your return, correctly identifying only whatever houses remain. You can also visit the nether or the end and stay there for at least 60 seconds. If the village(s) are within your world's always-loaded spawn chunks, they will never get unloaded from memory, and so the village never gets reevaluated, no matter how far you run. In this case, you can either bust out and replace all the doors manually, or visit an alternate dimension as mentioned before.
It seems there are two kinds of transparent blocks. There are fully transparent blocks such as glass, torches, and fences, and then there are what I call "partially transparent" blocks such as slabs, stairs, and leaves, which are treated as transparent by the rendering engine (since they don't fill up the entire block space -- you can see through to what's behind them, so the game has to know to draw that part of the world anyway, even though there's a block between you and it. It knows to do this because the block that's in the way is flagged as a "transparent" block), yet they still block light from passing through (at least partially, as is the case with leaves or water), so they're still somehow considered opaque to the lighting engine, which appears to be where it counts. These partially transparent blocks will block the sunlight, and so will count as roof blocks. Fully transparent blocks still do not count. Water and lava (both flowing and source blocks) are partially transparent, and will count as roof blocks. Leaves count as roof blocks. Slabs and stairs count as roof blocks (and they don't even have to be upside-down.) I haven't tested every single block type so I don't have a full list of what does and does not count, but I know that torches don't count, fences don't count, chests don't count. The list goes on...
There is a rumor going around, that two doors facing within a certain distance of each other will somehow cancel each other out, and neither one of them (or sometimes only one, depending on who you hear it from) will count as "houses." This is not a thing! It is nothing more than a misconception, a rumor, brought about by a misinterpretation of the significance of a particular image posted by Marfagames, who did much of the initial testing on villager houses:
Let's take another look at what he wrote there: And here left are 0 houses and the right 2 are 2 houses. That's true, the two doors on the left do not count as houses, and the two on the right do. But then look at what he says immediately after that: The doors on the left get not negated through the other door, but through the one "roof" tile only in the range of 5 left and right from it.
Marfagames' english is a little rusty, but what he is saying is basically this: The reason the doors on the left do not count as houses is not because they are facing each other, but rather because each one has exactly one space covered by a roof block on either side. So as you can see, even he said from the very beginning that it has nothing to do with the fact that they are facing each other!
Here is an image that demonstrates the overlap between the areas checked for roof blocks by each of the two doors. The door on the left checks above the pink blocks, and the door on the right checks above the blue ones (but only in the center row that's inline with the doors, of course.) Purple blocks represent the area where the two zones overlap, and these spaces are checked by both doors:
So looking at the blue door, it has one covered space on the left side, and one also on the right:
And likewise with the pink door:
Since these doors both have the same number of covered spaces on either side, they don't have an "inside" or an "outside," and therefore can't be called "houses." However If you put additional blocks behind these (or just move them back by one space) then they will be 6 blocks away from the far door, too far to be counted, but are still within range of the nearer door, creating the imbalance necessary to call them "houses":
With these additional blocks in place, the doors now are valid houses. This is my understanding, and the Village Info mod agrees!:
SECTION 2: BREEDING AND POPULATION CAP
...or "How is babby formed?" A village's population is capped at a certain amount, based on available housing. Villagers will breed, provided there are at least two to begin with, until the number of (adult?**) villagers reaches but does not exceed 0.35 times the number of "houses" (defined above.) Residents of a village which has not yet reached its population cap will occasionally go into "love mode," indicated by animated hearts above their head (only visible if you have particle effects enabled, but still works even when you can't see it working.) Much like with farm animals, when two villagers are feeling "romantic" and can see each other, they will pathfind towards the other and "kiss" for a few seconds, after which a third, smaller ("baby") villager will spawn next to them (the baby spawns in the same block space as one of the parents.) This new villager will be assigned a random profession (indicated by the style and color of its clothing,) not necessarily the same as either parent.
**The wiki used to state that "once the cap is reached, any remaining baby villagers will grow to adulthood, but no new babies will be born, bringing the total population to somewhere slightly above the actual population cap," indicating that only adult villagers are counted towards the cap. I have not seen any evidence of this, and all my testing indicates that baby villagers are counted just the same as adults are. As soon as that last baby is born, all "love mode" animations cease to occur; killing either a baby or adult villager at that point will cause them to start up again.
Breeding requires at least two villagers to begin with. If you are starting a village from scratch, or if yours was wiped out by zombies and there are no villagers left (or only one), then the only ways to acquire more are hauling them in from another village (such as by minecart, or leading them away at night with a trail of "fake" houses, destroying visited ones along the way to force them onward), curing infected zombie villagers, or to cheat them in using creative mode spawn eggs.
To cure an infected zombie villager, you must first travel to the nether and collect at least one blaze rod, to craft a brewing stand. Then you need to brew a splash potion of weakness, and craft a golden apple (the cheap one, that just takes nuggets to craft. Not the "enchanted" kind that uses entire gold blocks.) When you find a zombie villager, toss the potion of weakness at it, and then right-click it with the golden apple. The zombie will make a loud sizzling sound, emit orange swirly particles, and begin to shake violently. It takes a couple of minutes for them to convert, so go ahead and trap him somewhere, and make sure he won't burn in the sunlight. After a few minutes, he will turn into a regular villager, at which point you can let him out to roam the village or do whatever.
Finding zombie villagers in the first place shouldn't be all that difficult. Each zombie has a 5% (1/20) chance to be a villager zombie instead, so it shouldn't take you too long (only about forty zombies, total) to find two of them you can cure back into villagers and get the population booming by more..."natural" means. Additionally, when a villager is attacked by a zombie (any zombie) there is a chance (I think the wiki says it's 50% on normal difficulty, and 100% on hard) that they will turn into a villager zombie instead of just being killed.
There is also a bug or glitch where sometimes the villagers will continue to breed indefinitely without regard to the population cap. Here's a quote from trunkz explaining how this works:
You can simply reproduce/abuse this behavior by building 6 houses on the ground level (enough to set the villager limit to 2), drop 2 (or more) villagers into a 6 blocks deep hole, and leave one villager at the top to keep the houses "alive". The villagers in the hole will breed indefinitely, because they're not counted against the cap.
This nine blocks high is the same height as the range in which a villager can identify a house. I have not confirmed this, but perhaps these two are related -- that is to say that maybe a villager would be counted towards the cap if they are up to three blocks below or five blocks above (or exactly on) the level of the village center point.
SECTION 3: IRON GOLEMS
...or "It's okay, he's with me." An iron golem's main purpose, "in-world," is to protect villagers from zombie sieges. In practice, they actually do a rather poor job at this, but it is also possible to "farm" them for the iron ingots they produce. Golems will roam the village and attack any hostile or neutral mobs they see except for creepers, slimes, wolves, ghasts, and magma cubes (although only zombies will actually attack the villagers themselves.) They have extremely high health (100 points, or 50 hearts) and do not suffer fall or drowning damage. Their long arms can reach an enemy through a solid wall one block thick with a long-range melee attack that deals anywhere from 3.5 to 10.5 hearts of damage (7 to 21 half-heart "points") as well as tossing enemies into the air, likely causing fall damage in addition to this. When provoked by attacking them or a nearby villager, naturally-spawned golems will become hostile towards the player, moving toward and attacking the player whenever they are in sight. They can sense an attack on a villager even without direct line-of-sight, they don't actually have to see it take place. Attacking one golem will not cause any other golems to become hostile, but attacking a single villager will bring the wrath of every golem within range (~12 blocks.) Running far enough away from a hostile golem will cause it to become neutral towards you again. Additionally, contact with water momentarily renders them passive -- they will not attack any players or mobs while standing in water and their neutrality towards players will be reset.
Iron golems will spawn naturally in a village of sufficient size, but can also be constructed in-world by the player, by placing four iron blocks in a T-shape (physically build it, not on a crafting table) and then placing a pumpkin or jack-o-lantern on top (the pumpkin/jack-o-lantern must be placed last, or else it won't work.) Player-created golems will never attack the player who made them, even when directly provoked.
Upon death, golems will drop 3-5 iron ingots (and 0-2 roses), making farming them a viable alternative or addition to caving or mining for your iron.
Golems will spawn near the center of a village if it has at least ten villagers (previously sixteen, before 1.4) and 21 houses. Additional houses beyond the 21st will make no difference as far as golem spawning is concerned, but you will need 29 of them, at least initially, in order to spawn ten villagers naturally (although after that you can cut them back down to 21 if you want to.) However, having additional villagers beyond the tenth will allow more golems to spawn, in increments of one golem for every ten villagers (so 0-9 villagers allows no golems to spawn, the cap is set at zero; 10-19 raises that cap to one, 20-29 raises it to two, etc.) This cap only limits the number of golems in a village at any one time; as soon as one is killed or leaves the village boundaries, a new one can spawn in its place immediately.
The golem spawning zone is a 16 x 16 x 6 area centered around the center point of the village. As long as all the conditions are met (10 villagers, 21 houses, golem cap not reached,) then each game tick (1/20 of a second) there is a 1/7000 chance the game will try to spawn a golem. Basically it picks a random number between 0 and 6999, and if it picks 0, then up to ten attempts are made to spawn a golem. A random spot is chosen inside the spawning zone, and if that spot contains a solid block with at least 2x2 x4-high space above it (liquids are okay here -- golems can spawn in water, which is key to the iron farm designs linked below), then a golem is spawned there. [NOTE: For a long time, I had "3-high" written here. But it looks like that was incorrect, and while the golems themselves are only 3 blocks high, they actually need a four-high space to spawn in.]
This is repeated up to ten times or until a golem is spawned, whichever comes first. Then, the check is repeated each game tick, until enough golems have been spawned to reach the cap, at which point spawning is put on hold until either a golem is eliminated or the cap is raised. This means that, as long as the cap isn't reached, you can expect one golem spawn about every six minutes, on average, or roughly ten golems (30-50 ingots) per hour. Remember, though, that this is just an average, and the actual interval between spawns will necessarily vary to some degree. If you watch vigilantly, you will likely see spawns spaced much closer or farther apart than this six-minute average, but in the long run, it should all even out.
An iron farm is an artificial village (or several of them, spaced far enough apart to remain separate) in which golems are spawned and then either killed immediately, or moved to a holding cell (outside the village boundary, so that new ones can spawn in their place) for later killing. If you opt for the first method, you will either need to go AFK while camping out at the collection point, or else check back periodically to collect your items before they despawn. This necessity can be avoided by using the holding cell method, which allows the golems to collect while you are working nearby, and then you can harvest them all at once when you are ready so that you don't miss any drops.
There are several ways to build an iron farm, but the most effective versions seem to be the ones that utilize two floors in the central golem-spawning zone, and keep all doors and villagers outside the zone, either above and below the center or in an outer "ring" on the same level. This is in order to maximize the number of available spaces for the golems to spawn in, which in turn will reduce the number of failed attempts, and keep the spawning rate as high as possible. This is much more effective than simply increasing the villager count to raise the golem cap, which only matters for the few seconds between the time when a golem spawns and when it is flushed out or killed, anyway. To further increase your output rate, you can build several separate "modules" and bring the golems or their drops to a central collection area. Since golems are immune to falling or drowning damage, the available killing methods are lava or suffocation (or a combination of the two, as in docm77's video.)
I have linked several iron farm tutorials at the end of this post. MAGUS-APPROVED™ designs are those presented by trunkz, docm77, and MegaTrain. CSPerspective's videos detail earlier incarnations of the idea that do work, but fall short on efficiency in some of the areas I mentioned in the previous paragraph. He also has a fourth iron farm video which does remedy these shortcomings, but I did not put a link to it as it's basically just a rehash of JL2579's design (from docm77's video, which I feel has a better presentation.) If you're going to follow the designs exactly, stick with docm77's or trunkz' video. If you want to design a farm yourself from the ground up, go ahead and watch them all to get some ideas.
SECTION 4: ZOMBIE SIEGES
"...braaains!" 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 of the villagers' homes (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. I don't know the specifics of where exactly they will spawn or how often, so if you have any additional info on this subject please post or PM. Here is some additional info provided by LeMasterTJ:
Notable bugs: Also, whenever you log out and log back in in a SP world on a difficulty where mobs can spawn, a siege will most likely occur once you log back in. Someone reported a while back that zombies can spawn in a siege on Peaceful, but there is no proof of this bug's existance, and I even tested it myself.
SECTION 5: SOURCES AND ADDITIONAL INFO
I don't look at the game code myself, or anything. My info comes from in-game observations and the word of others. This is how it works, according to my understanding as of version 1.3.2 (edit: still correct in 1.6.4 to my knowledge). I haven't included anything on trading in here yet, but for the time being, the wiki covers it pretty well. We also have a discussion going on over here about all the math and stuff behind how a villager's trade offers are generated.
We're all human (or most of us are, anyway) so there's always the chance that I have made a typo, or even that I am just plain wrong about something in here. If you see anything that you feel needs attention, please post it in this thread or shoot me a PM.
Sources: the wiki; trunkz' Village Info mod; various posts on these forums; and personal experience from building three different types of iron farm (trunkz' iron farm, JL2579's iron farm as presented by docm77, and a third style presented by YouTuber CSPerspective [version 3]), from fixing up and expanding two NPC villages in my main survival world, and from my own testing in creative mode.
Marfagames' original post on village mechanics - Much of this information came from there initially, but it's a little hard to follow since everything is mixed in with discussion and scattered across over 500 posts on more than 20 pages, plus I think English is not his first language
Village Info mod by trunkz
Imgur gallery by Derrick - A briefer, more compact visualization of what makes a "house," and a bonus "villager breeding unit" that can support up to 35 villagers in an 11 x 10 or so space (the unit takes up that much space, the villagers themselves wander around outside of it, gettin' freaky in the daylight.)
[Tutorial] Guide to Breeding Villagers in Minecraft - A video crash-course in villager breeding and housing presented by qmagnet
trunkz' iron golem farm tutorial video
Another iron golem farm design by JL2579 (tutorial video by docm77)
MegaVillage: Manage 100+ villager trades + iron golem farm - A trading village with built-in iron farm (or vice versa) presented by MegaTrain
CSPerspective's iron farm (version 3 - 1.2.4) (version 2 - 1.2.3) - Still working in 1.3 (and later? I haven't tested these designs recently, but I don't see any reason why they shouldn't still work as before.)
CSPerspective's iron farm version 1 - 1.2.1 - OUTDATED! No longer works as of 1.2.3
Minecraft Wiki page on NPC Villagers - WARNING! Some of the information this page is inaccurate, outdated, or just plain false. If you see something in there that conflicts with something I've said here, chances are good that it's the wiki that has got it wrong, and not me. Maybe someday I'll fix it myself (if none of you get around to it first! )
Minecraft Wiki page on Villager Trading
Minecraft Wiki page on Iron Golems
Minecraft Wiki page on Zombie Sieges
SECTION 6: DONATIONS
I've put a lot of work into this. If you'd like to make a donation, you can show your support by clicking the button below:
Edited by IronMagus, 11 November 2013 - 11:22 PM.