The Meaning of Life, the Universe, and Everything.
Join Date:
7/16/2017
Posts:
56
Member Details
I have a map and I need to do that every time you kill a zombie it gives you 5 sunflowers (In my pack it looks like a coin). So how do I do that every time someone is killing a zombie it will give him 5 sunflowers? btw my version is 1.12
Using a custom advancement would probably be the easiest, at least the most reliable.
Set up a custom advancement which gets triggered on the player_killed_entity trigger. The advancement should be hidden, not announced in chat nor by showing a toast. As a criteria you obviously need to specify a zombie, and as a reward you need to make it trigger a function.
In the function you simply use the /give command to give out the item(s). @s is a thing here; that will target the player who triggered the function thus also killed the zombie.
Then as the last command you immediately revoke the advancement again. /advancement revoke @s only <advancement>. This will effectively reset the whole thing so that the player gets new items whenever the next zombie is killed.
Alternatively, if you want players to receive coins for any zombies killed, you can use a custom loot table for zombies. Sadly, I can't explain the details, but it's a vanilla game feature that lets you set what items should drop from mobs. Google it up, there are tutorials. It's equivalent to what command_block_shadow suggested, except his solution modifies existing zombies every tick, and mine will make the game spawn all zombies that way.
I have a map and I need to do that every time you kill a zombie it gives you 5 sunflowers (In my pack it looks like a coin). So how do I do that every time someone is killing a zombie it will give him 5 sunflowers? btw my version is 1.12
Ok thanks!
Thanks ill try this one!
Ok I didn't really understand can you just say the command and thank you so much xD.
Alternatively, if you want players to receive coins for any zombies killed, you can use a custom loot table for zombies. Sadly, I can't explain the details, but it's a vanilla game feature that lets you set what items should drop from mobs. Google it up, there are tutorials. It's equivalent to what command_block_shadow suggested, except his solution modifies existing zombies every tick, and mine will make the game spawn all zombies that way.
Thanks ill try this one