This answer is for 1.12 or before. Refer to this answer by pppery for 1.13 and later.
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.
Best Answer
This is a simple matter of our friend, the scoreboard. First, setup a scoreboard for mob kills:
This will automatically keep track of a player's mob kills. We can also manipulate it manually. We'll get into that. Now, we want to detect (on a clock) when a player has a Kills score of 1, and give them 1 experience level, and then set their Kills score to 0
These two commands should run at the same time to work right, though if redstone quirks cause it to not work right, you can run
/testfor @p[score_Kills_min=1]
on a clock, and send the output of that command block to the/xp
and/scoreboard
commands in sequence.Note this will also count passive mobs; chickens etc. There's no real way to avoid this, unless you want to keep track of each entity killed with
/scoreboard objectives add KillEntity stat.killEntity.<entity>
(e.g./scoreboard objectives add KillZombie stat.killEntity.Zombie
). Which you can do, but you'll need a set of/xp
and/scoreboard
reset commands for each one.