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

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

Introduction

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

Prototype

public LivingEntity getEntityLiving() 

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;/*from  w  w w .  j a  v  a 2 s . c  om*/

    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   w  w  w  .  ja va 2s . c  o  m

    // 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());
}