Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-10841

Villages are persisted to NBT, yet still destroyed/recreated on chunk reload



    • Icon: Bug Bug
    • Resolution: Awaiting Response
    • None
    • 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
    • None
    • Community Consensus
    • Survival


      The bug

      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.

      How to reproduce

      1. Place a wooden door and two blocks behind it a solid block (for example sandstone)
      2. Summon a villager
      3. Pause the game and inspect the villages.dat file using for example the tool NBTExplorer
        → The village data contains the door data
      4. Kill the villager and wait one minute
      5. 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 reason

      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.




            Unassigned Unassigned
            marcono1234 [Mod] Marcono1234
            70 Vote for this issue
            18 Start watching this issue