• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • Minecraft 1.16.220 Update + Bug/Crash Fixes
    Added MCPE 1.16.220 version and fixed crashes for multiple plugins. You can view the full changelist here.
  • Forum Updates - 4/11/2021
    Various changes have been made to the forums and a few categories. You can view the full changelist here.

Custom Enchantments Tutorial (weapons)

Warning!
Hello , there have been no replies in this thread for more than 30 days.
Please make sure you have a valid reason before you reply to this thread or you may face moderation action.
#1
To make CEs (Custom Enchantments), you have to use the itemtags if you want them to be stackable. You can view the tags on the item you're currently holding with this code:
Code:
cmd create gettags
cmd add gettags %hand% = playerhand(%p%)
cmd add gettags %tags% = %hand%[\"tags\"]
cmd add gettags message %p% %tags%
Those tags are actually NBT tags in hexadecimals. If you want to know more about it, you can DM me on discord (ChinaGirlNL#5723) or google it yourself.

The code for your CE has to check if the damage was caused by another player, so start like this:
Code:
cmd create damage
cmd add damage %d% = %args%[3]
cmd add damage if %d% = %p% then exit
cmd add damage %on% = onlineplayers()
cmd add damage if %d% notin %on% then exit
Then you need the tags of the weapon:
Code:
cmd add damage %h% = playerhand(%d%)
cmd add damage %t% = %h%[\"tags\"]
Then you check if the name of your enchantment is in your item's tags (usually in the item lore). As I mentioned earlier, it's written in hexadecimals. You can just search a hexadecimal translator to translate your CE's name into tags. Because you only want to know if parts of the tags contain your CE's name, you use in instead of =. If the item has the right tags, your code will execute the enchantment part.
Code:
cmd add damage if \"466c79\" in %t% then goto 100
cmd add damage if \"46616c6c\" in %t% then goto 200
cmd add damage exit
I made for example the CEs Fly and Fall, but you can do whatever you want. I would recommend not to use sleep, because the enchantments aren't executed all at once. Make sure your enchantment's code doesn't end with exit, but with a goto to the next check for a CE:
Code:
cmd edit damage 99 #Fly
cmd add damage %c% = random(1, 2)
cmd add damage if %c% = 1 then goto 8
cmd add damage ascon /effect %p% levitation 2 1 true
cmd add damage goto 8

cmd edit damage 199 #Fall
cmd add damage %c% = random(1, 2)
cmd add damage if %c% = 1 then goto 9
cmd add damage %yy% = %y% + 10
cmd add damage move %p% %level% %x% %yy% %z%
cmd add damage goto 9