13

I'm making a map where I want players to be able to choose there kits/classes. The problem I'm having with it though is giving players already enchanted Tools/Armour/Weapons.

I'm not sure if you can use the /give [player] [item] [amount] because you'll have to use the whole {} thing and I'm not sure how to make enchanted Tools/Armour/Weapons using that.

Can anyone help?

3 Answers 3

16

This answer is for 1.12 or before. Refer to this answer by pppery for 1.13 to 1.20.4 and this other answer by pppery for 1.20.5+.

You can set up some simple commands with command blocks, and let players click the button of each command block so that they receive the enchanted items.

You can use the following command to give players enchanted items (in this example, 1 diamond sword with Smite 2 and Knockback 30)

/give @p diamond_sword 1 0 {ench:[{id:17,lvl:2},{id:19,lvl:30}]}

This is the general command:

/give @p <ID> <amount> 0 {ench:[{id:<0-62>,lvl:<1-32767>},{id:<0-62>,lvl:<1-32767>},...]}

You put all enchantment tags between [ ], each with both id and lvl tags wrapped together by curly braces { }.

You can also add in the clear inventory command to ensure they don't get kits twice.

/clear @p

Remember the highest level for the enchantment is level 32767. You can stack enchants as many times as you want such as:

/give @p diamond_sword 1 0 {ench:[{id:17,lvl:32767},{id:17,lvl:32767}]}

After setting up the command blocks, put buttons and the players can choose by clicking them.

You can also put enchantments onto things that normally cannot be enchanted or have that specific enchantment. For example, you can do the command stated above to give you enchanted blocks. But, enchantments will NOT affect how the thing works normally. For example, enchanting Thorns on a dirt block will not hurt players when they come into contact with the enchanted block.

16
This answer is for 1.13-1.20.4 See my other answer for the syntax for 1.20.5 and later.

The syntax for enchanted items has changed a bit in 1.13, meaning the accepted answer no longer works.

  1. The ench tag has been renamed to Enchantments
  2. The id field of an enchantment is now a string, rather than an integer.

Thus, to give a player a diamond sword with Smite 2 and Knockback 30, one would now use:

/give @p diamond_sword{Enchantments:[{id:"minecraft:smite",lvl:2s},{id:"minecraft:knockback",lvl:30s}]}
3
  • Note: this doesn't work on bedrock. Allegedly bedrock doesn't have the ability to give and enchant in a single command.
    – Chris
    Commented Nov 15, 2022 at 8:17
  • This is a minecraft-java-edition question, so shouldn't be expected to work on Bedrock @Chris. You're looking for How do I give a player an item with custom properties?, which can be done with one command and a bit of awkward setup.
    – pppery
    Commented Nov 15, 2022 at 14:29
  • I agree - though the fact that the question is tagged java doesn't mean the answer doesn't apply to bedrock. This part was less clear.
    – Chris
    Commented Nov 16, 2022 at 23:18
2

1.20.5+ syntax:

/give @s minecraft:diamond_sword[minecraft:enchantments={levels:{"minecraft:smite":2,"minecraft:knockback":30}}]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .