Is there a way I can give players enchanted items and armor in MCPE with commands? [duplicate]

I am making a minigame and want to be able to give players enchanted items by the click of a button. I know how to use /give but can you also enchant it?

I have tried this:

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

If it does not work I can just have them click buttons while holding the items.

1

6 Answers

As of 1.1.3, there is no way you can use the /give command to give already enchanted items as you can't edit the NBT tag.

However, you could connect the button to multiple command blocks. One of them would say /give @p diamond_sword. The other ones would say /enchant @p smite 2 and /enchant @p knockback 2.

I’m assuming the ids you’ve given are for the Java Edition, because the ids for PE are different and id 19 in PE is power, which is not available on a sword. Smite on PE is 10 and knockback is 12. A list of all the ids can be found on the wiki.

NOTE: The /enchant commands won’t work if the player is not holding the dimaond sword.

2

Sadly, json only supports CanPlaceOn and CanDestroy functions for adventure and you can give yourself enchanted items only with custom mods. I hope Mojang is working on this...

Use this: /replaceitem entity [Player/@p/@a/@e/@r/@s] slot.weapon.mainhand 0 diamond_swordThen after do /enchant @p -enchantment-

You could clone a dispenser of the enchanted item of your liking and have a command block triggering dispenser as well as teleporting that item to @p. A little harder to set up then a single command but an easy way to not have to use /enchant in case they switch what they are holding on accident

I'm not sure that's possible, unless you change an items ID

2

Yes! I think I've found the solution! It might not work though, but here :

/give @p diamond_sword 1 0 {tag:{ench:[{id:10,lvl:1},{id:12,lvl:1}]}}

3

You Might Also Like