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

Villager can have all trades disabled

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Minecraft 1.4.2, Minecraft 1.4.6, Minecraft 1.4.7, Snapshot 13w07a, Snapshot 13w09a, Snapshot 13w09b, Snapshot 13w09c, Minecraft 1.5, Snapshot 13w11a, Minecraft 1.5.1, Minecraft 1.5.2, Snapshot 13w18c, Snapshot 13w19a, Minecraft 1.6.1, Minecraft 1.6.2, Minecraft 1.7.4, Minecraft 14w08a, Minecraft 1.7.5, Minecraft 14w10b, Minecraft 14w10c, Minecraft 14w11b, Minecraft 1.7.9, Minecraft 1.7.10-pre4, Minecraft 1.7.10, Minecraft 1.8, Minecraft 1.8.1-pre3, Minecraft 1.8.3, Minecraft 1.8.8, Minecraft 15w42a, Minecraft 15w44a, Minecraft 1.8.9, Minecraft 15w51b, Minecraft 16w02a, Minecraft 1.9, Minecraft 1.9.1 Pre-Release 3, Minecraft 1.9.2, Minecraft 1.9.3 Pre-Release 3, Minecraft 1.9.4, Minecraft 16w20a, Minecraft 16w21a, Minecraft 16w21b, Minecraft 1.10 Pre-Release 1, Minecraft 1.10 Pre-Release 2, Minecraft 1.10, Minecraft 1.10.1, Minecraft 1.10.2, Minecraft 16w32a, Minecraft 16w32b, Minecraft 16w33a, Minecraft 16w35a, Minecraft 1.11.2, Minecraft 17w06a, Minecraft 1.12, Minecraft 1.12.1 Pre-Release 1, Minecraft 1.12.1, Minecraft 1.12.2 Pre-Release 1, Minecraft 1.12.2, Minecraft 18w06a, Minecraft 18w07a, Minecraft 18w10c, Minecraft 18w10d, Minecraft 18w11a, Minecraft 18w16a, Minecraft 18w19a, Minecraft 18w20a, Minecraft 18w20c, Minecraft 18w21b, Minecraft 18w22c, Minecraft 1.13-pre1, Minecraft 1.13-pre2, Minecraft 1.13-pre3, Minecraft 1.13-pre4, Minecraft 1.13-pre5, Minecraft 1.13-pre8, Minecraft 1.13, Minecraft 18w30b, Minecraft 18w31a, Minecraft 1.13.1, Minecraft 1.13.2-pre1, Minecraft 1.13.2, Minecraft 18w43b, Minecraft 18w43c, Minecraft 18w47b, Minecraft 18w48a, Minecraft 18w48b, Minecraft 18w49a, Minecraft 18w50a, Minecraft 19w02a, Minecraft 19w03a, Minecraft 19w03b, Minecraft 19w03c, Minecraft 19w04b, Minecraft 19w05a, Minecraft 19w06a, Minecraft 19w07a, Minecraft 19w08b, Minecraft 19w09a
    • Confirmed

      The bug

      Villagers can get into a state where all there trades are locked.

      Cases

      Unloading villager during refresh

      This bug happens when you unload the villager before it refreshed its trades.

      How to reproduce
      1. Spawn a villager
      2. Get all items it wants for its first trades in your inventory. It is easier if you are in Creative to be able to clone items if you need more.
      3. Start trading with the villager
      4. Without closing the GUI use all trades until they are disabled
      5. Close the GUI and directly afterwards close the world
      6. Load the world again
        → The trades will still be disabled and won't be enabled again

      In some cases, such as when trading with Leather Workers or other villagers with low numbers of total trades, it is possible to skip steps 5 and 6 as those villagers can have all trades become locked without closing the world.

      Code analysis

      Based on 1.11.2 decompiled using MCP 9.35 rc1

      The fields net.minecraft.entity.passive.EntityVillager.timeUntilReset and net.minecraft.entity.passive.EntityVillager.needsInitilization are not saved to NBT.

      Suggested fix

      See this comment.

      Trade not being used for the first time and having bad luck

      Based on 1.11.2 decompiled using MCP 9.35 rc1

      As of 1.11.2 (and earlier versions) the method net.minecraft.entity.passive.EntityVillager.useRecipe(MerchantRecipe) only enables all disabled trades if a trade was used for the first time or with a one fifth chance. This means if you have bad luck, you can end up with all trades locked as well.

      It is not known if this is intended or if the developers just did not want that trading any trade always enables all disabled trades, but forgot that it might happen that all trades get disabled.

      Fix for affected villagers

      This comment describes a fix for already affected villagers in case it is not intended that villagers with only disabled trades exist.

      Remark: Consider adventure maps, where sometimes all trades are intentionally locked. Unlocking them when loading the villager might break the map, because players can get item they shouldn't have.

            FruBasilicum [Mojang] Agnes Larsson
            cubfan135 Jeremy
            Votes:
            107 Vote for this issue
            Watchers:
            35 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: