Tutorials/Village chaining

Village chaining is the process by which one can move village centers abnormally close to, or within, each other. This is a process that is commonly used in making highly efficient and compact iron farms. It was first discovered in 1.4.2, and has been used ever since. The process was originally discovered and introduced to the majority by TangoTek.

This tutorial will teach you how to chain villages - typically used in the spawning part of large, efficient iron farms - from scratch. If you only want examples, visit the iron golem farming tutorial. This is also created specifically for the computer edition. Info may be inaccurate when applied to other versions.

The new village info mod will definitely help, as it is the only village info mod that helps you visualize villages while not being glitchy.

Non-Concentrical and Concentrical
Non-concentrical chained villages are the first to be discovered. Their component villages' centers is usually arranged on a line and are not put in the same position.

On the other hand, concentrical chained villages are discovered much later. They have all component villages' centers in the exact same spot.

Comparing the non-concentrical version to the concentrical version

 * Pros
 * Easier and simpler to create.
 * Cons
 * Less space-efficient.
 * Require a whole lot more door placing and breaking if it is non-resettable, and a lot more doors if it's auto-resettable.
 * Require more villagers.

Non-Resettable and Resettable
Because even the quickest reloading of chunks(usually done in autosaving, and affects most kind of chunk loaders) can break chained villages, chunks containing them must never unload as long as the game is open, or else the whole thing will merge.

The solution to this is either putting the whole chained village in spawn chunk or its equivalent, then use a little trick to continue loading the chunks even when no player is in the same dimension as it - a.k.a. the non-resettable solution - or use redstone to rechain the village whenever the player needs - a.k.a. the resettable solution.

The resettable solution is primarily used when chunk permaloading can not be achieved(for example in a Spigot server), or when the chaining process is so complex it can not be done manually(such as in concentrical chained villages).

Game mechanics and mechanisms used in village chaining
''Note: 1. Before getting to the advanced, please visit the tutorial on village mechanics first to learn the basics.

2. Mechanisms discussed in this section are for 1.8 and above only, however game mechanics discussion are for all versions that have villages.

3. To prevent itself from being unnecessarily long or wide, figures in this section use wood planks and fences to represent valid door positions and village radius, respectively. Side-view log represents a village center that contains a valid door, while top-view log represents a doorless center. The barrier icons just represent unimportant things. More important icons may overlay less important ones. The minimum village radius in those figures is 5 blocks and the merging range is radius + 5 blocks instead of 32 blocks and radius + 32 blocks like the real game.''

Village merging priority & Border extender
If all the chunks containing villages are not reloaded, village merging will only be considered when a villager detects new doors(technically only the bottom block of the door is counted). If there are multiple villages in range, only the most eligible village to merge with a door will get merged with it. All the other in-range villages are ignored. Thus, villages with overlapping boundaries are possible.

Before 1.8, the older a village is the more eligible it is to merge with a new village. Consequently, village chaining back then primarily used the merging range to prevent villages from merging initially. From 1.8 however, the nearer a village to a door the more eligible it is to merge with the door. If multiple villages have the same distance between their centers and a door, the door will prefer the older village more. This makes village chaining tougher, but also much more predictable, allowing a village to extend from a far spot to overlapping with a preexisting village. It also doesn't break chained villages from older versions as long as it is kept loaded, but old reset mechanisms no longer work.

Border extender
''The process of making village boundaries overlap, with the oak village getting closer and closer to the birch village each chaining cycle, until it can not get any more closer with this method. The oak village is created first, thus the game prefers it over the birch village. Note the rounding that shifted the center to the west. This is also almost exactly the same way TangoTek chained villages in his Iron Titan.''

The village border extender is a valid house that, as the name suggests, extends the border of a village so that the center is closer to the center of another village. The extender should always be placed as close as possible to the other village, but must still be closer to the village that needs extension. After that, the further door(s) to the other village's center is removed, so that the extender becomes the center of the village, allowing it to use another extender to continue the process until it can not get anymore closer with this method. After the extended village has reached that spot, more doors can be added to it & the other village so they both have enough doors to spawn iron golems.

Properties of the village center & Center anchor
The village center is the centroid of the shape formed if all the valid houses' positions are connected, however it can also be confused with the center(or centroid, it is the same in case of a sphere) of the bounding sphere of the village(the smallest sphere possible that contains all the doors of the village). Consequently, the more populated with valid houses a section of the village is, the nearer the village center is to the centroid of that specific section.

Center anchor
Using a big cluster of valid houses, one can "anchor" the village center so that it is more likely to be near the centroid of the cluster, then use extenders to extend the village radius way past the anchor itself. This technique is crucial if you want to make it so that an old village is completely inside another, new village, which in turn is crucial for concentrical village chaining.

One villager in multiple village
A villager can be inside multiple villages as long as they are inside the border of those villages, which is the prime advantage of concentrical chained villages over non-concentrical chained villages, and of any type of chained village over traditional iron golem farming. This can reduce the villagers cost from hundreds down to 30 or so.

House detection mechanics & Layered chained village + Keeping doors detected
As the villagers move around, the area near them (a 16x16 square centered at the northwest of the block the villager is standing plus a height of 10, starting at 2 blocks above their head and ending 6 blocks below their feet) is occasionally checked for new valid doors ("houses"). Valid doors take variable amount of time to be detected, sometimes almost instantly, sometimes after 3 seconds or so, however TangoTek appears to believe that after about 6 seconds, it is safe to assume that all valid doors in-range of a villager have been detected as houses. This limitation can be used to prevent new doors from being added, however as villagers can not move vertically freely, the vertical detection range is more limited and houses that need to be separated are usually stacked on top of each other, only the vertical limitation is often used.

Additionally, after getting detected as houses, doors no longer need an "outside" or "inside" to be kept being considered as houses. This is especially crucial in stacking mutiple doors.

Aside from having itself destroyed, a door can stop being considered as a house if there is no villager to detect it for about 60 to 64 seconds. This is both useful and harmful as it allows chaining mechanisms to be reused without player interaction, but can also break a chained village.

Layered chained village + Keeping doors detected
Knowing these mechanics, making a layered chained village and keeping doors detected is quite easy. These videos are example of those mechanics being used in practice:

The north-west-downward preference & Direction-dependency
As the game's internal integer rounding always rounds integers down, village centers are always placed further to the north(negative Z direction), the west (negative X direction) and the downward direction(negative Y direction) from the actual centroid of the village. This also affects the golem spawning box. The golems spawn inside a 16*6*16 box that has to fit perfectly into the block grid. As a result, the center of that box is never the center of the village, and the center of the village is always 0.5 block further to all 3 positive directions than the center of the golem spawning box.

Direction-dependency
The rounding mentioned above makes chained villages direction dependency. This should be kept in mind when designing any chained villages, as this can both break and help village chaining.