The Mending enchantment changes that mechanic, redirecting the XP you earn towards repairing your tools and armor.