Reproduction Steps:
Hold leather horse armor in your offhand
Hold another item (like coal) in your main hand
Right-click, and notice how the items were swapped
Issue:
Equipable#swapWithEquipmentSlot calls LivingEntity#getEquipmentSlotForItem to get the slot for the item. The issue is that getEquipmentSlotForItem returns MAINHAND if the item is not usable by that entity (which in this case, leather horse armor returns false for canUseSlot)
So this causes swapWithEquipmentSlot to incorrectly swap the items, as it thinks that item can be used.
Linked issues
Attachments
Comments 3
This seems to duplicate MC-273300.
Can confirm. Please note that this only affects leather horse armor, contrary to what your summary would suggest. Also affects all other types of horse armor, as well as wolf armor.