Minecraft – Armor enchantment on a held item 1.14

minecraft-commandsminecraft-java-edition

How do I enchant a held item with a working armor enchantment (eg. a stick with respiration)?
I can use commands to give the item the enchantment, but it currently seems to have no effect when I am holding it.
I'm using 1.14

Best Answer

You can only do that by editing the item's "Enchantments" NBT tag, which is not possible in a playet's inventory. You can only use /replaceitem to overwrite it with a new item or ask the player to drop it, then you can modify the drop.

Example for /replaceitem:

/replaceitem entity @p weapon.mainhand stick{tag:{Enchantments:[{id:"knockback",lvl:8}]}}