How do I add an enchantment to another item that already has some enchantments?
I have a pickaxe with the enchantments Fortune I and Unbreaking I. I would like to add another enchantment, Mending, onto this pickaxe, without disturbing the other enchantments.
I think that the /data modify command will help me accomplish this. How can I do this?
3 Answers
Use /enchant:
/enchant @s minecraft:mendingNo where does it say in the wiki doubling up on /enchant won't work and I know it does in Bedrock, so it should still work.
You can append an enchantment to the item using the /data modify command, but you would need to throw the item outside your inventory or put it inside a container block, since it's not possible to modify player data. (There is a work-around, but it's rather complicated) Here's are some examples:
For targeting the item entity:
data modify entity <targetEntity> Item.tag.Enchantments append value {id: "minecraft:mending", lvl: 1s}<targetEntity>refers to the item entity that we'll be modifying the NBT of.Item.tag.Enchantmentsis the NBT path for the enchantments of an item. We'll be appending an object in this list.append valueindicates that the data after will be appended to the target NBT path, which in this case, isItem.tag.Enchantments{id: "minecraft:mending", lvl: 1s}is the mending enchantment we'll be appending to theItem.tag.Enchantmentslist
For targeting a container block that contains the item:
data modify block x y z Items[].tag.Enchantments append value {id: "minecraft:mending", lvl: 1s}x,y, andzrefers to the container block's coordinates. In this example, let's say the block is a chest.Items[].tag.Enchantmentsis the NBT path to the item that's stored in the chest.Items[]refers to the chest's NBT, which is used for storing items. You can select a certain index by adding a number inside[].
e.g:Items[0].tag.Enchantmentswould target the item in the first slot of the chest, likeItems[-1].tag.Enchantmentswould target the item in the last slot of the chest.
If you wish to do this, get a book with the mending enchant and use an anvil to do it. If you don't want to go through all that pain, then hold the pickaxe on your had, and type /enchant @p minecraft:mending.
Although if you want that book, it is best to find a village, make 2 fletching tables, and find a nitwit and place and break the fletching table until you get a mending trade. then trade with another villager for emeralds and get that mending book. Or you could try and get mending on a book through an enchantment table.
All the best and hope this helped.
2