@Override
    public void hurt(Entity entity, int amount) {
        if (!level.creativeMode) {
            if (health > 0) {
                if (ai != null) {
                    ai.hurt(entity, amount);
                }
                if (invulnerableTime > invulnerableDuration / 2F) {
                    if (lastHealth - amount >= health) {
                        return;
                    }

                    health = lastHealth - amount;
                } else {
                    lastHealth = health;
                    invulnerableTime = invulnerableDuration;
                    health -= amount;
                    hurtTime = hurtDuration = 10;
                }

                hurtDir = 0F;
                if (entity != null) {
                    float distanceX = entity.x - x;
                    float distanceY = entity.z - z;
                    hurtDir = (float) (Math.atan2(distanceY, distanceX) * 180D / Math.PI) - yRot;
                    knockback(entity, amount, distanceX, distanceY);
                } else {
                    hurtDir = (int) (Math.random() * 2D) * 180;
                }

                if (health <= 0) {
                    die(entity);
                }

            }
        }
    }