Search in sources :

Example 91 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.

the class CompendiumUnlockHandler method onEntityDeath.

/**
 * This should handle all mobs and the Astral Barrier
 *
 * @param event
 */
@SubscribeEvent
public void onEntityDeath(LivingDeathEvent event) {
    if (event.entityLiving.worldObj.isRemote && event.source.getSourceOfDamage() instanceof EntityPlayer) {
        if (event.entity instanceof EntityEnderman) {
            ArcaneCompendium.instance.unlockEntry("blockastralbarrier");
        } else {
            EntityRegistration reg = EntityRegistry.instance().lookupModSpawn(event.entityLiving.getClass(), true);
            if (reg != null && reg.getContainer().matches(AMCore.instance)) {
                String id = reg.getEntityName();
                ArcaneCompendium.instance.unlockEntry(id);
            }
        }
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityEnderman(net.minecraft.entity.monster.EntityEnderman) EntityRegistration(cpw.mods.fml.common.registry.EntityRegistry.EntityRegistration) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 92 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.

the class AMEventHandler method onBucketFill.

@SubscribeEvent
public void onBucketFill(FillBucketEvent event) {
    ItemStack result = attemptFill(event.world, event.target);
    if (result != null) {
        event.result = result;
        event.setResult(Result.ALLOW);
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 93 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.

the class AMEventHandler method onEntityConstructing.

@SubscribeEvent
public void onEntityConstructing(EntityConstructing event) {
    if (event.entity instanceof EntityLivingBase) {
        event.entity.registerExtendedProperties(ExtendedProperties.identifier, new ExtendedProperties());
        ((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.maxManaBonus);
        ((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.maxBurnoutBonus);
        ((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.xpGainModifier);
        ((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.burnoutReductionRate);
        ((EntityLivingBase) event.entity).getAttributeMap().registerAttribute(ArsMagicaApi.manaRegenTimeModifier);
        if (event.entity instanceof EntityPlayer) {
            event.entity.registerExtendedProperties(RiftStorage.identifier, new RiftStorage());
            event.entity.registerExtendedProperties(AffinityData.identifier, new AffinityData());
            event.entity.registerExtendedProperties(SkillData.identifier, new SkillData((EntityPlayer) event.entity));
        }
    } else if (event.entity instanceof EntityItemFrame) {
        AMCore.proxy.itemFrameWatcher.startWatchingFrame((EntityItemFrame) event.entity);
    }
}
Also used : RiftStorage(am2.playerextensions.RiftStorage) SkillData(am2.playerextensions.SkillData) EntityItemFrame(net.minecraft.entity.item.EntityItemFrame) AffinityData(am2.playerextensions.AffinityData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ExtendedProperties(am2.playerextensions.ExtendedProperties) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 94 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.

the class AMEventHandler method onEntityHurt.

@SubscribeEvent
public void onEntityHurt(LivingHurtEvent event) {
    if (event.source.isFireDamage() && event.entityLiving instanceof EntityPlayer && ((EntityPlayer) event.entityLiving).inventory.armorInventory[3] != null && ((EntityPlayer) event.entityLiving).inventory.armorInventory[3].getItem() == ItemsCommonProxy.fireEars) {
        event.setCanceled(true);
        return;
    }
    if (event.entityLiving.isPotionActive(BuffList.magicShield))
        event.ammount *= 0.25f;
    if (event.entityLiving.isPotionActive(BuffList.manaShield)) {
        float manaToTake = Math.min(ExtendedProperties.For(event.entityLiving).getCurrentMana(), event.ammount * 250f);
        event.ammount -= manaToTake / 250f;
        ExtendedProperties.For(event.entityLiving).deductMana(manaToTake);
        ExtendedProperties.For(event.entityLiving).forceSync();
        for (int i = 0; i < Math.min(event.ammount, 5 * AMCore.config.getGFXLevel()); ++i) AMCore.proxy.particleManager.BoltFromPointToPoint(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY + event.entityLiving.worldObj.rand.nextFloat() * event.entityLiving.getEyeHeight(), event.entityLiving.posZ, event.entityLiving.posX - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, event.entityLiving.posY + event.entityLiving.getEyeHeight() - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, event.entityLiving.posZ - 1 + event.entityLiving.worldObj.rand.nextFloat() * 2, 6, -1);
        event.entityLiving.worldObj.playSoundAtEntity(event.entityLiving, "arsmagica2:misc.event.mana_shield_block", 1.0f, event.entityLiving.worldObj.rand.nextFloat() + 0.5f);
        if (event.ammount <= 0) {
            event.setCanceled(true);
            return;
        }
    }
    Entity entitySource = event.source.getSourceOfDamage();
    if (entitySource instanceof EntityPlayer && ((EntityPlayer) entitySource).inventory.armorInventory[2] != null && ((EntityPlayer) entitySource).inventory.armorInventory[2].getItem() == ItemsCommonProxy.earthGuardianArmor && ((EntityPlayer) entitySource).getCurrentEquippedItem() == null) {
        event.ammount += 4;
        double deltaZ = event.entityLiving.posZ - entitySource.posZ;
        double deltaX = event.entityLiving.posX - entitySource.posX;
        double angle = Math.atan2(deltaZ, deltaX);
        double speed = ((EntityPlayer) entitySource).isSprinting() ? 3 : 2;
        double vertSpeed = ((EntityPlayer) entitySource).isSprinting() ? 0.5 : 0.325;
        if (event.entityLiving instanceof EntityPlayer) {
            AMNetHandler.INSTANCE.sendVelocityAddPacket(event.entityLiving.worldObj, event.entityLiving, speed * Math.cos(angle), vertSpeed, speed * Math.sin(angle));
        } else {
            event.entityLiving.motionX += (speed * Math.cos(angle));
            event.entityLiving.motionZ += (speed * Math.sin(angle));
            event.entityLiving.motionY += vertSpeed;
        }
        event.entityLiving.worldObj.playSoundAtEntity(event.entityLiving, "arsmagica2:spell.cast.earth", 0.4f, event.entityLiving.worldObj.rand.nextFloat() * 0.1F + 0.9F);
    }
    ExtendedProperties extendedProperties = ExtendedProperties.For(event.entityLiving);
    EntityLivingBase ent = event.entityLiving;
    if (extendedProperties.getContingencyType() == ContingencyTypes.DAMAGE_TAKEN) {
        extendedProperties.procContingency();
    }
    if (extendedProperties.getContingencyType() == ContingencyTypes.HEALTH_LOW && ent.getHealth() <= ent.getMaxHealth() / 3) {
        extendedProperties.procContingency();
    }
    if (ent.isPotionActive(BuffList.fury.id))
        event.ammount /= 2;
    if (entitySource instanceof EntityLivingBase && ((EntityLivingBase) entitySource).isPotionActive(BuffList.shrink))
        event.ammount /= 2;
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ExtendedProperties(am2.playerextensions.ExtendedProperties) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 95 with SubscribeEvent

use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.

the class AMEventHandler method onEntityDeathChrono.

@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onEntityDeathChrono(LivingDeathEvent event) {
    EntityLivingBase soonToBeDead = event.entityLiving;
    if (soonToBeDead.isPotionActive(BuffList.temporalAnchor.id)) {
        event.setCanceled(true);
        PotionEffect pe = soonToBeDead.getActivePotionEffect(BuffList.temporalAnchor);
        if (pe instanceof BuffEffectTemporalAnchor) {
            BuffEffectTemporalAnchor buff = (BuffEffectTemporalAnchor) pe;
            buff.stopEffect(soonToBeDead);
        }
        soonToBeDead.removePotionEffect(BuffList.temporalAnchor.id);
        return;
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) BuffEffectTemporalAnchor(am2.buffs.BuffEffectTemporalAnchor) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)138 EntityPlayer (net.minecraft.entity.player.EntityPlayer)57 ItemStack (net.minecraft.item.ItemStack)48 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)18 Minecraft (net.minecraft.client.Minecraft)14 EntityLivingBase (net.minecraft.entity.EntityLivingBase)14 World (net.minecraft.world.World)14 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)12 ArrayList (java.util.ArrayList)10 EntityItem (net.minecraft.entity.item.EntityItem)10 SideOnly (cpw.mods.fml.relauncher.SideOnly)9 ChunkPosition (net.minecraft.world.ChunkPosition)9 ChatComponentText (net.minecraft.util.ChatComponentText)8 PlayerPointer (riskyken.armourersWorkshop.common.data.PlayerPointer)8 Block (net.minecraft.block.Block)7 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)6 AffinityData (am2.playerextensions.AffinityData)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 ChunkCoordIntPair (net.minecraft.world.ChunkCoordIntPair)5