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

Some enchantments cannot appear in Villager trades

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Works As Intended
    • None
    • 1.19.2
    • None
    • Plausible
    • Trading

      Some enchantments doesn't appear in villager trades. This is the case for example of smite/ban of arthropods/sharpness on an axe (weaponsmith for example).

      This also happens with thorns on items other than the chestplate.

       

      Digging a bit into the code (though fabric) I can see the following points: 

      • DamageEnchantment uses the WEAPON category which allows SwordItem
      • canEnchant method of DamageEnchantment is overriden and checks if item is of type AxeItem otherwise it delegates the check to the category
      • The villager trade uses EnchantmentHelper and eventually ends up in the getAvailableEnchantmentResults where the following check is performed: enchantment.category.canEnchant(item)

       

      This leads to the incoherence as the logic code is inside the enchant instance itself, not the category.

       

      Shouldn't this make more sense to have a check that performs enchantment.canEnchant(itemStack) instead as this is where the final logic is (and is used by the anvil) ?

            Unassigned Unassigned
            RakSrinaNa Thomas Couchoud
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: