setHealth(health - amount);
playEffect(EntityEffect.HURT);
// play sounds, handle death
if (health <= 0.0) {
Sound deathSound = getDeathSound();
if (deathSound != null) {
world.playSound(location, deathSound, 1.0f, 1.0f);
}
// todo: drop items
} else {
Sound hurtSound = getHurtSound();
if (hurtSound != null) {
world.playSound(location, hurtSound, 1.0f, 1.0f);
}
}
}