How to modify the enchantement of an already enchanted item?

I was wondering if there was a way to add enchantments (using commands) to an already enchanted item. For example, I have a command that enchants an item if you have enough levels, but what if you get enough levels and you want to enchant it further, such as the item having protection I but the person wanting to upgrade to protection II or protection III? (I am making an zombie apocalypse map on vanilla and do not want to use mods.) Would there be a way to remove the enchantments and then add them back on the higher level?
Best Answer
Basically, just enchant the item again with the already enchanted item on creative. You can't double enchant items in survival as far as I know, so this is the command;
/enchant (your username) (enchantment) (level)
Just do that twice, and you should be able to have two enchantments at once! (tested on 1.9)
Pictures about "How to modify the enchantement of an already enchanted item?"



Can you upgrade an enchantment already on an item?
Once an item is enchanted, it can't be further enchanted using an Enchanting Table. However, you can combine two enchanted items, or add a second enchantment from an enchanted book, using anAnvil.Can you add enchantments to an item that is already enchanted?
Nope. If an item is already Enchanted with one effect, you can't add another. If you enchanted a weapon, bought or found a weapon with one enchant you can't enchant it further.How do you change the enchantment on an item?
How to enchant items in MinecraftHow to Properly Use an Anvil and Apply more than 30 Enchantments to an Item.
More answers regarding how to modify the enchantement of an already enchanted item?
Answer 2
You could try replacing the item. For example:
/data merge entity @e[type=player] {ArmorItems:[{},{},{id:"minecraft:diamond_chestplate",Count:1b,tag:{Enchantments:[{id:"minecraft:protection",lvl:3s}]}},{}]}
Answer 3
You can use item modifiers for this.
This one removes all enchantments from an item:
{
"function": "minecraft:set_nbt",
"tag": "{Enchantments:[]}"
}
If you save this as a file named 'remove_enchants.json' in an item_modifiers folder in your datapack. You can remove the enchantments of an item being hold by a player with this command:
/item modify entity @s weapon.mainhand my_datapack:remove_enchants
Answer 4
you don't need a command - just get each desired enchantment individually on separate tools/weapons/armor, then combine them with an anvil to get the combined enchantments. you can also use enchanted books and combine them with the tool/weapon/armor with an anvil to get the enchantment you want.
i hope this helps!
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Heriberto Medina, Anete Lusina, Anete Lusina, Anete Lusina