0

I am making a map in Minecraft where you would fight off hordes of hostile mobs.

I've been struggling to add a "lifesteal" effect because all "lifesteal" effect tutorials are only for Bedrock Edition and do not work in Java Edition. 

I need a command where, when an entity is hit or dies, it will give the player instant heal 1 (for the lifesteal effect, of course).

1

1 Answer 1

3

You can do it by using a scoreboard. Create a scoreboard called ZombieKills by running this in the chat /scoreboard objectives add ZombieKills minecraft.killed:minecraft.zombie This will track how many times a player has killed a zombie. Place a command block that is set to Repeat and Always Active, in that put the command execute as @a[scores={ZombieKills=1..}] run effect give @s minecraft:instant_health This will give instant_health to all players that have killed one or more zombies. Place another command block that is chained to the other one (Make sure it is also Always Active) and put in the command execute as @a[scores={ZombieKills=1..}] run scoreboard players reset @s ZombieKills this will reset the score if someone has one or more kills, this is so it doesn't infinitly give the player instant_health. To start it you need to add the scoreboard to all the players by doing /scoreboard players add @a ZombieKills 0 This will add the scoreboard to all the players, but you should automate this for servers. You probably want to disable command block output so it doesn't flood the chat, run this in the chat /gamerule commandBlockOutput false this will make it so it won't send the commandblock output in the chat. I can't find anyway to track all mobs using one scoreboard, so you might have to do this multiple times for each mob

2
  • thank you, i appreciate it Commented Apr 15 at 14:55
  • @MichaelKamado Remember, if this answers your question and works for you, then you should upvote and accept it.
    – Daemons
    Commented Apr 18 at 23:44

Not the answer you're looking for? Browse other questions tagged .