2

If you use commands to get a book with an enchantment past its max level, and then you try to combine it with a sword or other tool in an anvil, the anvil will only give you the maximum level of that enchantment, even if the level on the book is higher. Is there any way to bypass this?

The only way I know of is making a custom system where you would drop the enchanted book on the ground. But if I have many levels of enchantment books in my map it will require way too many command blocks unless there already is a datapack for it. There is probably a mod that will make this work, but I don't want to take the path of using mods unless this problem is unsolvable in vanilla.

See example video below:

1
  • It's easy to make/change crafting table recipes, but making/changing anvil recipes is a challenge that you probably don't want to take on. I would use the "drop item on floor" method to combine them, and I think there'll be an interesting shortcut... Sep 25, 2020 at 1:34

1 Answer 1

3

Here's a setup that works for one enchantment on the enchanted book only.

execute as @e[type=item,nbt={Item:{id:"minecraft:diamond_sword"}}] if entity @e[type=item,nbt={Item:{id:"minecraft:enchanted_book"}}] if entity @s[nbt={Item:{tag:{Enchantments:[]}}}] run data modify entity @s Item.tag.Enchantments set value []
execute as @e[type=item,nbt={Item:{id:"minecraft:diamond_sword"}}] at @s run data modify entity @s Item.tag.Enchantments append from entity @e[type=item,limit=1,distance=0..0.5,nbt={Item:{id:"minecraft:enchanted_book"}}] Item.tag.StoredEnchantments[0]
execute as @e[type=item,nbt={Item:{id:"minecraft:enchanted_book"}}] at @s if entity @e[type=item,nbt={Item:{id:"minecraft:diamond_sword"}},distance=0..0.5] run kill @s

Explanation:

  1. If there is a diamond sword next to an enchanted book, make sure that the diamond sword has the Enchantments tag. If it doesn't, add it.
  2. Tell the diamond sword to modify its NBT data to append the 1st enchantment from the book onto its own enchantment list.
  3. Get rid of the enchanted book if it is near a diamond sword.
4
  • Thank you so much. One question. Should the commands be in chain_command_blocks or can they just be in repeat command block and activated in any order? I had them in repeat command blocks and it works perfect but still...
    – zombie1111
    Sep 26, 2020 at 10:06
  • And is it possible to do so it works for all items? without having 3 command_block per item? I only need it for swords, armor, bow and stuff like that but it would be cool if it worked for everything!
    – zombie1111
    Sep 26, 2020 at 10:18
  • Yes you can! ExpertsCoder14 why didn´t you just replace "nbt={Item:{id:"minecraft:diamond_sword"}}" with "nbt=!{Item:{id:"minecraft:enchanted_book"}}" ?? Because if you do so it works for all items!
    – zombie1111
    Sep 26, 2020 at 14:14
  • @zombie1111 Because I didn’t think you wanted all items, and I didn’t think of using your idea yet. But I’m glad you were able to find a solution on your own. Sep 26, 2020 at 16:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .