Possible I've just got the syntax wrogn, but for wont of a tutorial showing how to do it correctly, I'mma report it as a bug.
Enchanted books crafted using custom recipes from datapacks behave differently compared to enchanted books obtained through other means.
Firstly, they cannot be used in an anvil as enchanted books to add their enchantments to equipment.
Secondly, they display a cyan name (like other enchanted items) rather than the typical enchanted book yellow.
Please find attached, a screenshot of my mending.json file which I used to create a book, and my attempt to use it in an anvil to add mending to an diamond axe, as well as me hovering over the enchanted book to demonstrate its' atypical name color.
Linked issues
Attachments
Comments 3
Thank you for your report!
We're tracking this issue in MC-51744, so this ticket is being resolved and linked as a duplicate.
That ticket has already been resolved as invalid. Please take a look at the parent ticket (MC-51744) and see if an explanation is provided there in the description of the ticket or in the comments for why this issue is invalid.
If you haven't already, you might like to make use of the search feature to see if the issue has already been mentioned.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki
Further investigation:
Other enchantable items produced by crafting behave as expected, and can be combined in anvils as expected.
Crafted enchanted books can be further enchanted by legitimate books in anvil, displaying both names, but when the merged book is used resulting book is used to enchant gear, the crafted enchantment disappears.
Enchanted books given using the command "/give @p minecraft:enchanted_book[minecraft:enchantments={mending:1}]" display similar bugged behavior.