Example usage for net.minecraftforge.event.entity.living LivingHealEvent getAmount

List of usage examples for net.minecraftforge.event.entity.living LivingHealEvent getAmount

Introduction

In this page you can find the example usage for net.minecraftforge.event.entity.living LivingHealEvent getAmount.

Prototype

public float getAmount() 

Source Link

Usage

From source file:org.blockartistry.DynSurround.server.services.HealthEffectService.java

License:MIT License

@SubscribeEvent(priority = EventPriority.LOW)
public void onLivingHeal(@Nonnull final LivingHealEvent event) {
    if (!ModOptions.enableDamagePopoffs)
        return;/*  w w w.  ja  va 2  s .  c  o m*/

    if (event == null || event.getEntity() == null || event.getEntity().world == null
            || event.getEntity().world.isRemote)
        return;

    // Just in case
    if (event.getAmount() <= 0 || event.getEntityLiving() == null
            || event.getEntityLiving().getHealth() == event.getEntityLiving().getMaxHealth())
        return;

    final Entity entity = event.getEntityLiving();
    final Locus point = new Locus(entity, RANGE);
    final PacketHealthChange packet = new PacketHealthChange(entity.getEntityId(), (float) entity.posX,
            (float) entity.posY + (entity.height / 2.0F), (float) entity.posZ, false, -(int) event.getAmount());
    Network.sendToAllAround(point, packet);
}

From source file:org.blockartistry.mod.DynSurround.client.HealthEffectHandler.java

License:MIT License

@SubscribeEvent(priority = EventPriority.LOW)
public void onLivingHeal(final LivingHealEvent event) {
    if (event == null || event.getEntity() == null || event.getEntity().worldObj == null
            || event.getEntity().worldObj.isRemote)
        return;/*from   ww w. ja va  2  s.  c om*/

    // Just in case
    if (event.getAmount() <= 0 || event.getEntityLiving() == null
            || event.getEntityLiving().getHealth() == event.getEntityLiving().getMaxHealth())
        return;

    final HealthData data = new HealthData(event.getEntityLiving(), false, -(int) event.getAmount());
    Network.sendHealthUpdate(data, event.getEntity().worldObj.provider.getDimension());
}