The Bug:
The enchant_randomly and enchant_with_levels loot functions remove the custom names of books.
Enchanting a named book in an enchanting table or with the set_enchantments loot function keeps its custom name. However, the enchant_randomly and enchant_with_levels loot functions replace books with new enchanted books that have no custom name, therefore introducing an inconsistency.
Steps to Reproduce:
Obtain a book and rename it in an anvil.
Hold the book in your main hand and enchant it by using the command provided below.
/item modify entity @s weapon.mainhand {type:"minecraft:enchant_randomly",options:"minecraft:unbreaking"}Observe if the enchanted book still has its custom name.
Observed Behavior:
The enchant_randomly and enchant_with_levels loot functions remove the custom names of books.
Expected Behavior:
The enchant_randomly and enchant_with_levels loot functions would keep the custom names of books.