use of net.minecraftforge.event.entity.living.LivingDeathEvent in project ArsMagica2 by Mithion.
the class LifeSaving method applyEffect.
@Override
public boolean applyEffect(EntityPlayer player, World world, ItemStack stack, ImbuementApplicationTypes matchedType, Object... params) {
LivingDeathEvent event = (LivingDeathEvent) params[0];
event.setCanceled(true);
player.setHealth(10);
player.isDead = false;
return true;
}
use of net.minecraftforge.event.entity.living.LivingDeathEvent in project SpongeForge by SpongePowered.
the class SpongeForgeEventFactory method createLivingDeathEvent.
public static LivingDeathEvent createLivingDeathEvent(Event event) {
DestructEntityEvent.Death spongeEvent = (DestructEntityEvent.Death) event;
Optional<DamageSource> source = spongeEvent.getCause().first(DamageSource.class);
if (!source.isPresent()) {
return null;
}
LivingDeathEvent forgeEvent = new LivingDeathEvent((EntityLivingBase) spongeEvent.getTargetEntity(), (net.minecraft.util.DamageSource) source.get());
return forgeEvent;
}
use of net.minecraftforge.event.entity.living.LivingDeathEvent in project SpongeForge by SpongePowered.
the class SpongeForgeEventFactory method callLivingDeathEvent.
// unused
public static DestructEntityEvent.Death callLivingDeathEvent(Event event) {
DestructEntityEvent.Death spongeEvent = (DestructEntityEvent.Death) event;
if (!spongeEvent.getCause().first(DamageSource.class).isPresent()) {
return spongeEvent;
}
EntityLivingBase entity = (net.minecraft.entity.EntityLivingBase) spongeEvent.getTargetEntity();
net.minecraft.util.DamageSource damageSource = (net.minecraft.util.DamageSource) spongeEvent.getCause().first(DamageSource.class).get();
LivingDeathEvent forgeEvent = new LivingDeathEvent(entity, damageSource);
((IMixinEventBus) MinecraftForge.EVENT_BUS).post(forgeEvent, true);
return spongeEvent;
}
Aggregations