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.

13

9 Answers

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 )

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.

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.

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.

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

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.

1

You can use 'clear', then 'give' to give an enchanted item.

First, make a command block with 'clear @p diamond_sword', then add a comparator leading into another command block:

'give @p diamond_sword 1 0 {ench:[{id:diamond_sword,lvl:5}]}'

You can do the same for armor and other tools.

2

Easy to do! just go the minecraftcommand.science and there you can make your own commands for example a diamond sword with sharpness 1000000000

(even though that will only do 8 damage as it passes the limit)

1

Here is a list of enchantments:

Armor

  • 0.protection
  • 1.fire_protection
  • 2.feather_falling
  • 3.blast_protection
  • 4.projectile_protection
  • 5.resperation
  • 6.aqua infinity
  • 7.thorns
  • 8.depth_strider Weapons

  • 16.sharpness

  • 17.smite
  • 18.bane of atropods
  • 19.knockback
  • 20.fire aspect
  • 21.looting

Tools

  • 32.efficiency
  • 33.silk touch
  • 34.unbreaking
  • 35.fortune

Bows

  • 48.power
  • 49.punch
  • 50.flame
  • 51.infinity
2

You Might Also Like