-
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) ?