Example usage for net.minecraftforge.common ForgeHooks onLivingHurt

List of usage examples for net.minecraftforge.common ForgeHooks onLivingHurt

Introduction

In this page you can find the example usage for net.minecraftforge.common ForgeHooks onLivingHurt.

Prototype

public static float onLivingHurt(LivingEntity entity, DamageSource src, float amount) 

Source Link

Usage

From source file:com.blogspot.jabelarminecraft.magicbeans.entities.EntityGiant.java

License:Open Source License

/**
 * Deals damage to the entity. If its a EntityPlayer then will take damage from the armor first and then health
 * second with the reduced value. Args: damageAmount
 *//*from   w w  w.j av a2 s  .  co m*/
@Override
protected void damageEntity(DamageSource parDamageSource, float parDamageAmount) {
    // DEBUG
    System.out.println("EntityGiant damageEntity()");

    if (!isEntityInvulnerable(parDamageSource)) {
        parDamageAmount = ForgeHooks.onLivingHurt(this, parDamageSource, parDamageAmount);
        if (parDamageAmount <= 0)
            return;
        parDamageAmount = applyArmorCalculations(parDamageSource, parDamageAmount);
        parDamageAmount = applyPotionDamageCalculations(parDamageSource, parDamageAmount);
        float f1 = parDamageAmount;
        parDamageAmount = Math.max(parDamageAmount - getAbsorptionAmount(), 0.0F);
        setAbsorptionAmount(getAbsorptionAmount() - (f1 - parDamageAmount));

        if (parDamageAmount != 0.0F) {
            float f2 = getHealth();
            setHealth(f2 - parDamageAmount);
            getCombatTracker().trackDamage(parDamageSource, f2, parDamageAmount);
            setAbsorptionAmount(getAbsorptionAmount() - parDamageAmount);
        }
    }
}

From source file:org.spongepowered.mod.mixin.core.entity.living.MixinEntityLivingBase.java

License:MIT License

@Override
public float applyModDamage(EntityLivingBase entityLivingBase, DamageSource source, float damage) {
    return ForgeHooks.onLivingHurt(this.nmsEntityLiving, source, damage);
}