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

Duplicate Villager Trades

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • None
    • 1.18.2
    • None
    • Minecraft Java Edition, Most Recent Java Version that I am aware of, Windows 10 OS. Initially discovered in version 1.17, though it might still exist in later versions.
    • Unconfirmed
    • (Unassigned)

      The Bug:

      I was playing minecraft in a regular world a while back, and at one point, I had gotten a librarian villager, and said villager would trade me an enchanted book with Bane of Arthropods on it(Can't remember the specific enchantment level of the book, though I think it was II), at it's novice level. I believe that the villager wanted 15 or 16 emeralds in exchange for the enchanted book(note: the villager also wanted a regular book as a part of the trade, but that's not important here). I leveled the villager up to the apprentice level. That's where things started to get strange, as the villager wanted to sell me another enchanted book at a cost 3 or so more than the one sold at it's novice level. Problem was, though, the new enchanted book was the same as the one being sold at the novice level. It was even the same enchantment level as well, and I hadn't seen that before, though it was plausible that it could happen.

      Possible Cause:

      Although I haven't looked at the code for the villagers' trades myself, I can say with some certainty that there is a Math.random() portion to generate the enchantment type and level, for this to occur. As such, it's possible that the same villager could generate the same enchanted book as a different trade, though the chances of that are pretty low for that to happen. In this case, however, it did happen.

       

      My idea to potentially patch the glitch:

      If the code used to generate the villager's trade is also a part of the same file used to generate the villager itself, then maybe add a list of different enchantments to test for to see if the said villager has the trades; possibly in an arraylist if it's a java file. If so, then use the said array or arraylist to check the new enchanted book coming in to see if it matches any pre-existing enchanted books in the same villager. If it does match, then set the enchantment to be of a different type than that of the original enchanted book, or at least a different level, if possible.

       

      Further notes:

      Again, I haven't looked at the code itself for the villager's information, but seeing as I'm learning java, this might be the most likely scenario under the given circumstances. I may eventually add a video as a bit of proof if there is insufficient information to be contained, but it might take me a while. I still have the original world, but the villager may have died at some point. Note: any pre-existing villager affected by this bug may not be fixed when this issue is patched, but it will prevent it from occurring again.

            Unassigned Unassigned
            Mr_Tech41 TechionPrime34
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: