Minecraft – How to give players an enchanted book

minecraft-commandsminecraft-java-edition

I want to set a command to give a player an Unbreaking V book (rare item in crate) however I'm not sure how to do it, as the way I normally give enchanted items just gives me a enchanted book with Unbreaking V but it can't be applied to items through an anvil, so I'm assuming it's different for books?

Or, alternatively, is it that it's impossible to give out-of-vanilla-Minecraft enchanted book, as Unbreaking III books would still be sufficient!

Best Answer

Enchanted books store the enchantments that they're going to pass onto other items slightly differently than normal enchantments actually on an item. Otherwise, the enchantments on the book intended for passing on would be usable (set mobs on fire with a fire aspect book, or get more loot with a fortune book).

Rather than the ench list, the pass-on enchantments are in a StoredEnchantments list, everything else is the same.

For 1.13+:

/give @p enchanted_book{StoredEnchantments:[{id:"minecraft:unbreaking",lvl:5s}]}

For previous versions:

/give @p enchanted_book 1 0 {StoredEnchantments:[{id:34s,lvl:5s}]}