Search in sources :

Example 1 with LivingDeathEvent

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;
}
Also used : LivingDeathEvent(net.minecraftforge.event.entity.living.LivingDeathEvent)

Example 2 with LivingDeathEvent

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;
}
Also used : DestructEntityEvent(org.spongepowered.api.event.entity.DestructEntityEvent) DamageSource(org.spongepowered.api.event.cause.entity.damage.source.DamageSource) LivingDeathEvent(net.minecraftforge.event.entity.living.LivingDeathEvent)

Example 3 with LivingDeathEvent

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;
}
Also used : IMixinEventBus(org.spongepowered.mod.interfaces.IMixinEventBus) DestructEntityEvent(org.spongepowered.api.event.entity.DestructEntityEvent) DamageSource(org.spongepowered.api.event.cause.entity.damage.source.DamageSource) IMixinEntityLivingBase(org.spongepowered.common.interfaces.entity.IMixinEntityLivingBase) EntityLivingBase(net.minecraft.entity.EntityLivingBase) LivingDeathEvent(net.minecraftforge.event.entity.living.LivingDeathEvent)

Aggregations

LivingDeathEvent (net.minecraftforge.event.entity.living.LivingDeathEvent)3 DamageSource (org.spongepowered.api.event.cause.entity.damage.source.DamageSource)2 DestructEntityEvent (org.spongepowered.api.event.entity.DestructEntityEvent)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 IMixinEntityLivingBase (org.spongepowered.common.interfaces.entity.IMixinEntityLivingBase)1 IMixinEventBus (org.spongepowered.mod.interfaces.IMixinEventBus)1