Ok so is there any way of detecting if mob takes damage. I found this thread but it was for 1.9 How to detect if a mob has been hit in minecraft with command blocks?

  • 1
    its just the same as in that thread? afaik that didn't change from 1.8 to 1.9 – Plagiatus Jan 29 '17 at 11:55

The "tagging" feature for /scoreboard used in the other answer was introduced in 1.9, but the process is still the same. You will instead need to use a score:

/scoreboard objectives add Hit dummy

And then on a clock, ensuring correct activation order, you would cycle the score between 1 and 0 depending on the value of the HurtTime tag:

/scoreboard players set @e[type=Creeper] Hit 1 {HurtTime:10s}
/scoreboard players set @e[type=Creeper] Hit 0 {HurtTime:9s}
/execute @e[type=Creeper,score_Hit_min=1] ~ ~ ~ /say I am a creeper that was hit.
  • Thank you for helping me. I have only one problem: This doesn't work when an entity dies. So in my case it doesn't do the playsound command when mob dies. Any solution for this? /execute @e[name=Ghost,score_Hit_min=1] ~ ~ ~ /playsound mob.endermen.hit @a ~ ~ ~ 0.5 1.6 (command i'm using) – Juiseboy Jan 31 '17 at 20:17
  • Nevermind i solved it! It took like 1.5h but hey it works now ^_^ – Juiseboy Feb 1 '17 at 11:32

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.