Resolution: Awaiting Response
Snapshot 13w10a, Minecraft 1.5, Minecraft 1.9, Minecraft 1.9.1 Pre-Release 1, Minecraft 1.9.1 Pre-Release 2, Minecraft 1.9.1 Pre-Release 3, Minecraft 1.9.1, Minecraft 1.9.2, Minecraft 16w15b
Villages and all of their doors are written to the NBT. However, once a chunk containing village doors is unloaded those doors are removed from the village (and the village possibly destroyed if its the last door)
When the player enters the area again, a completely new village is recreated from scratch.
It seems the intent from writing villages to the NBT is to keep villages and their door associations correctly intact. However, this is not the case when travelling far away or to another dimension.
Suggestion: Don't remove a door from a village if the chunk containing the door is unloaded.
- Place a wooden door and two blocks behind it a solid block (for example sandstone)
- Summon a villager
- Pause the game and inspect the villages.dat file using for example the tool NBTExplorer
→ The village data contains the door data
- Kill the villager and wait one minute
- Pause the game and inspect the file again (with NBTExplorer you have to reopen it, refreshing does not always work)
→ The village does not contain the door anymore
The following is based on decompiled version of Minecraft 1.9 using MCP 9.24 beta. All method and class names are the names used in the decompiled version.
A door is added to a village if a wooden door is in a cuboid based on the villager's position with the following size:
- x: -16 to 15
- y: -4 to 3
- z: -16 to 15
If a door is already part of a village its net.minecraft.village.VillageDoorInfo.lastActivityTimestamp gets updated. If the difference between the current time and the timestamp is greater than 1200 ticks (1 minute) the door is removed by the method net.minecraft.village.Village.removeDeadAndOutOfRangeDoors().
One approach to changing this could be saving a village if all the chunks that are part of the village are unloaded instead of removing doors. There might be other checks needed to make sure this is not exploited for iron farms.