How to add an enchantment onto held item in Minecraft with command blocks

I want to have a button to enchant a piece of armor in my hand with Unbreaking V, if and only if:
- The tool is already enchanted witch has Unbreaking III
- The player has a minimum of 30 levels
I tried using /testfor
for a certain enchantment on a certain item ID range, taking away 30 lvls, and then enchanting the item in-hand with /enchant
. But it turns out you cannot use /enchant
to make higher than default enchantment levels, you can only do that with the /give
command.
I do not know how I am supposed to use the /give
command because the item given has to have all the enchantments it had before it was enchanted with Unbreaking V.
Best Answer
Correct me if I'm wrong, but the only way would be to add command blocks for every single armor enchant and level combo in the game. (Unless you wanted to host a server on your computer running bukkit and just not allow anyone in. Then you could download essentials and use /enchant )
Pictures about "How to add an enchantment onto held item in Minecraft with command blocks"



How do you enchant a held item in command?
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 put custom enchants on a command block?
You cannot transfer an enchantment from a tool onto a book in vanilla survival without cheats. You can however combine two books (or any two items of the same type) and merge the enchantments with an anvil.✔️ How To Use Minecraft Enchant Command + How To Enchant Players Items When On Certain Blocks! ✔️
More answers regarding how to add an enchantment onto held item in Minecraft with command blocks
Answer 2
Unless you have a two command blocks constantly checking for the tool in one hand and the armour in the other, and have command blocks testing for all enchantment combinations AND testing for the xp level, and somehow linking them all to one output, this system is impossible.
The problem with this task is format. A villager generated through a command generator that gives you specific trade that takes a tool (eg. sword) and an item only accessible through a testfor command that detects a certain amount of xp, notifies the player, then gives the second item(eg. emerald). Therefore the villager would trade a Sharpness III sword and 1 paper to give you a Sharpness V sword. This can obviously be adapted for anything you like. A website I recommend is called MCStacker.
Answer 3
Well here's the problem: you are unable to hold multiple objects in your hand! You are trying to enchant armor while holding a tool and that's an issue. Try holding the armor instead and enchanting it that way.
Answer 4
Have you tried using /testfor to find a player with the item then using /replaceitem entity Bob slot.hotbar.0 minecraft:diamond_sword 1 0 {ench:[{id:34,lvl:5}]} -That sets the first hotbar slot of the player named "Bob" to a diamond sword.
Answer 5
well the first thing to do is see if you need to verify/enchant.... so check for the level 3 you require for the upgrade.
if less than three skip the rest and reject...... but if three (or more for lazy way,) you need to figure out everything it holds so>>>>
the following will assume no over enchantments will exist and if it finds an over enchantment this LAZY WAY will set that enchantment to the maximum. this method is already very long and complimented so this assumption will give you more hair pulling before you decide to kill yourself due to how complicated it is (jk on kill yourself but really, redstone is very simple) so , on to it
there was a list of enchantments listed by what they enchant.... it was down voted by at least three people with their heads so far up their "where the sun don't shine" that you should immediately ignore everything they say.... too bad we don't have a complete list of them.... on to the list.
that list helps to limit what to check for so on the list of the item in question, the range is 32 - 35 but you already know unbreaking so don't have to check for that.
after each check (32, 33, and 35) you will need to save the value returned... rs latch for each level and each enchantment (don't forget an rs latch for level zero of each) then simply set the correct latch for each three
now you have over a dozen rs latches but only three of them are set. a command block tree can select the correct /give command for giving your upgraded tool. to allow multiple overclocked enchantments would be easier if there is a way to pass a number to the /give command but i doubt that is possible so while this lazy way has only 48 possible /give commands if you were trying to jump increase armor the command tree would be 80,000 - 200,000 depending on what enchantment you were increasing
that all said, I have a less than automatic way to do this but WAY WAY simpler it is different from you intention so i will place in a separate answer
Answer 6
All you need to do is:
/give <username> minecraft:diamond_sword 1 0 {each:[{id:16,lvl:10}]}
This is for a sharp X
diamond sword.
This goes all the way up to level 32780.
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Pixabay, Sharon McCutcheon, Joshua Miranda, Joshua Miranda