eventCause = (Cause<?>) cause;
} else {
eventCause = new NullDamageCause(cause.getType());
}
// TODO take potion effects into account
EntityDamageEvent event = getEngine().getEventManager().callEvent(new EntityDamageEvent(getOwner(), amount, eventCause, sendHurtMessage));
if (event.isCancelled()) {
return;
}
setHealth(getHealth() - event.getDamage(), HealthChangeCause.DAMAGE);
lastDamager = event.getDamager();
lastDamageCause = cause;
// Add exhaustion to damaged
Hunger hunger = getOwner().get(Hunger.class);
if (hunger != null) {
hunger.setExhaustion(hunger.getExhaustion() + 0.3f);
}
if (event.getSendMessage()) {
getOwner().getNetwork().callProtocolEvent(new EntityAnimationEvent(getOwner(), Animation.DAMAGE_ANIMATION));
getOwner().getNetwork().callProtocolEvent(new EntityStatusEvent(getOwner(), EntityStatusMessage.ENTITY_HURT));
//getHurtEffect().playGlobal(getParent().getParent().getPosition());
}
}