-4

I am currently building a minigame in 1.12 with only command blocks. I need to know how to give a player 1L of experience for every zombie that they kill. For instance, when a person kills one zombie, I want them to get 1 level. When they kill a second one, get one more level (Now they have two levels), and so on.

Does anyone have any command block solutions for this?

  • 3
    What have you tried yourself? I would immediately know multiple possible solutions, at least one of them should be findable with a quick research. (In case it already helps you, those ideas are: Advancement with mob kill trigger and XP reward, statistic scoreboard checking and /xp, detecting mob with 0 health closeby, summon XP orb, etc.) – Fabian Röling Jul 17 '18 at 13:46
0

For the XP part:

You can use the /xp command. The format for the command (on PC / MAC) looks like this:

/xp add <targets> <amount> [levels¦points]

You can also get the amount the player has:

/xp query <targets> <levels¦points>

And lastly, you can just set the level of XP:

/xp set <targets> <amount> [levels¦points]

Also, it's worth notin that to add specific points, you would do something like this:

/xp <amount> [player]

But to add levels, which is what you're wanting to do, you would do something like this:

/xp <amount>L [player]

Hope this helped, although I couldn't find a way for zombies to drop XP when they die without modding. You could potentially use a pressure plate (in a one block cell) and when the pressure plate isn't down you can give a certain level of XP with a command block. Not ideal, but it would work. Hope you find a better way to do this!

EDIT:

I'm assuming you're familiar with Command Blocks, but for reference, you would remove the '/' part of the command, and replace the targets with something like @p or @a depending on what you want to do

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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