0

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.

  • I have tried this /give @p bow 1 0 {ench:[{id:51,lvl:1},{id:34,lvl:3}]} – Clark Nelson Jul 1 '17 at 1:29
1

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.

| improve this answer | |
  • yes, but Although /enchant enforces maximum levels and compatibility, other commands (such as /give, /replaceitem, and /data) can bypass these restrictions. – Michael May 10 at 21:32
  • @Michael The last time I tried, that doesn't work on PE/BE. – cherryblossom May 11 at 0:10
1

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...

| improve this answer | |
0

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

| improve this answer | |
0

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

| improve this answer | |
-1

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

| improve this answer | |
  • 1
    How do you do that. I am not very good with commands. – Clark Nelson Jul 1 '17 at 1:28
  • 3
    If you cannot answer, PLEASE DON'T ANSWER. – aytimothy Jul 1 '17 at 11:22
-3

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}]}}

| improve this answer | |
  • 1
    PE does not have NBT data. If it did and matched the structure of JE, that would not work because the NBT data for /give already starts in the tag compound. – Skylinerw Dec 23 '17 at 0:44
  • Same to do with Skylinerw... I've tried everything, de-compiling MCPE's data and trying to type stuff like that in commands, using caps and no-caps, strings and no-strings, but to no avail. Looks like we'll just have to wait until it comes in a future update. Expect it soon though, as the next update is major. – machinebuilder Jan 24 '18 at 3:20
  • it's been over 2 years, did it happen? – Michael May 10 at 21:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.