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}]}
The mechanic in question here is the so-called Prior Work penalty.
Enchantable items, including books, have a Prior Work penalty stored in their NBT data (RepairCost
). The prior work penalty is added to the base level cost of working the item in the anvil.
For a new item, this cost is 0, and it is independent of the enchantments on the item. Each time you do anything with the item in the anvil, such as repair, combine or rename1, the prior work penalty is doubled, and 1 is added. E.g. it is 1 after 1 working, 3 after 2 workings, 7 after 3, or (generally) 2N – 1 after N workings. After 6 workings, the prior work penalty of that item will be 63, making it impossible to work that item any longer outside of creative mode.
When combining two items, both penalties are added to the cost, but the new item's penalty is calculated using only the higher of the two penalties. The optimal strategy is therefore to start high up and combine items with similar prior work penalties.
For example, you want to get a Power V, Infinity I, Flame I, Punch II bow: From enchanting/loot/villager trading, you have a Power IV bow, and Power IV, Infinity I, Flame I and Punch II as separate books. All 5 items have a penalty of 0.
If you just go and put everything on the bow, the bow will have been worked 4 times. Instead, you start by combining the Bow and 1 Book (1 working), and the 3 other books into one (2 workings), then combine those two. You'll end up with only 3 workings this way. You could even combine the bow with yet another book (or bow) before that and still end up with 3 workings on the final bow.
1 Renaming does not apply prior work penalty in 1.9.
Best Answer
You can't.
But you can make it so when they reach 10 XP levels, the empty book in their inventory (make it so it was originally empty) is replaced with a written book like this:
/testfor @p[lm=10]
This will test if the closest player to the command block has 10 XP levels. If they do, a signal will be sent through the redstone comparator to.../give
command for the book is:/give KingBspd written_book 1 0 {title:"Book name",author:"Your name",pages:["{text:\"John woke up\nJhon went to work\"}"]}
, but you can find more info on that online.If you need any additional help, leave a comment.