Minecraft – Using custom enchanted books in an anvil (Minecraft)

minecraft-commandsminecraft-java-editionminecraft-java-edition-server

I recently started building some things with command blocks for a Minecraft server a friend is hosting. Is it possible through commands or some other way to combine a tool with an enchanted book that is unobtainable without commands? Whenever I have tried, it just gives the tool the highest survival level.

eg: Diamond sword + Unbreaking 5 book -> Diamond sword with unbreaking 5

Best Answer

Anvils cannot process the book because it is higher than the survival level, which the anvil is coded to use. The only way to do this would be the

give @s diamond_sword{Enchantments{id:unbreaking,lvl:5}}

command or /enchant command.