Search in sources :

Example 16 with ExtendedProperties

use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.

the class Recall method applyEffectEntity.

@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
    if (!(target instanceof EntityLivingBase)) {
        return false;
    }
    if (caster.isPotionActive(BuffList.astralDistortion.id) || ((EntityLivingBase) target).isPotionActive(BuffList.astralDistortion.id)) {
        if (caster instanceof EntityPlayer)
            ((EntityPlayer) caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.cantTeleport")));
        return false;
    }
    int x = (int) Math.floor(target.posX);
    int y = (int) Math.floor(target.posY);
    int z = (int) Math.floor(target.posZ);
    ItemStack[] ritualRunes = RitualShapeHelper.instance.checkForRitual(this, world, x, y, z, false);
    if (ritualRunes != null) {
        return handleRitualReagents(ritualRunes, world, x, y, z, caster, target);
    }
    ExtendedProperties casterProperties = ExtendedProperties.For(caster);
    if (!casterProperties.getMarkSet()) {
        if (caster instanceof EntityPlayer && !world.isRemote)
            ((EntityPlayer) caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.noMark")));
        return false;
    } else if (casterProperties.getMarkDimension() != caster.dimension) {
        if (caster instanceof EntityPlayer && !world.isRemote)
            ((EntityPlayer) caster).addChatMessage(new ChatComponentText(StatCollector.translateToLocal("am2.tooltip.diffDimMark")));
        return false;
    }
    if (!world.isRemote) {
        ((EntityLivingBase) target).setPositionAndUpdate(casterProperties.getMarkX(), casterProperties.getMarkY(), casterProperties.getMarkZ());
    }
    return true;
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) ChatComponentText(net.minecraft.util.ChatComponentText) ParticleExpandingCollapsingRingAtPoint(am2.particles.ParticleExpandingCollapsingRingAtPoint) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Example 17 with ExtendedProperties

use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.

the class ManaDrain method applyEffectEntity.

@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
    if (!(target instanceof EntityLivingBase))
        return false;
    double manaStolen = 250;
    ExtendedProperties targetProperties = ExtendedProperties.For((EntityLivingBase) target);
    if (manaStolen > targetProperties.getCurrentMana()) {
        manaStolen = targetProperties.getCurrentMana();
    }
    targetProperties.setCurrentMana((float) (targetProperties.getCurrentMana() - manaStolen));
    targetProperties.forceSync();
    ExtendedProperties casterProperties = ExtendedProperties.For(caster);
    casterProperties.setCurrentMana((float) (casterProperties.getCurrentMana() + manaStolen));
    casterProperties.forceSync();
    return true;
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Example 18 with ExtendedProperties

use of am2.playerextensions.ExtendedProperties 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 19 with ExtendedProperties

use of am2.playerextensions.ExtendedProperties 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 20 with ExtendedProperties

use of am2.playerextensions.ExtendedProperties in project ArsMagica2 by Mithion.

the class ArmorHelper method HandleArmorInfusion.

//======================================================================================================
// Infusion
//======================================================================================================
public static void HandleArmorInfusion(EntityPlayer player) {
    ExtendedProperties extendedProperties = ExtendedProperties.For(player);
    float infusionCost = 0.0f;
    boolean bFullSet = getFullArsMagicaArmorSet(player) != -1;
    for (int i = 0; i < 4; ++i) {
        infusionCost += GetArsMagicaArmorInfusionCostFromSlot(player, i);
    }
    if (bFullSet) {
        infusionCost *= 0.75;
    }
    if (infusionCost > 0 && extendedProperties.getCurrentMana() > infusionCost) {
        //deduct mana
        extendedProperties.setCurrentMana(extendedProperties.getCurrentMana() - infusionCost);
        //bank infusion
        extendedProperties.bankedInfusionHelm += GetArsMagicaArmorRepairAmountFromSlot(player, 3);
        extendedProperties.bankedInfusionChest += GetArsMagicaArmorRepairAmountFromSlot(player, 2);
        extendedProperties.bankedInfusionLegs += GetArsMagicaArmorRepairAmountFromSlot(player, 1);
        extendedProperties.bankedInfusionBoots += GetArsMagicaArmorRepairAmountFromSlot(player, 0);
        //repair armor if infusion bank is above 1
        if (extendedProperties.bankedInfusionHelm > 1) {
            int repairAmount = (int) Math.floor(extendedProperties.bankedInfusionHelm);
            RepairEquippedArsMagicaArmorItem(player, repairAmount, 3);
            extendedProperties.bankedInfusionHelm -= repairAmount;
        }
        if (extendedProperties.bankedInfusionChest > 1) {
            int repairAmount = (int) Math.floor(extendedProperties.bankedInfusionChest);
            RepairEquippedArsMagicaArmorItem(player, repairAmount, 2);
            extendedProperties.bankedInfusionChest -= repairAmount;
        }
        if (extendedProperties.bankedInfusionLegs > 1) {
            int repairAmount = (int) Math.floor(extendedProperties.bankedInfusionLegs);
            RepairEquippedArsMagicaArmorItem(player, repairAmount, 1);
            extendedProperties.bankedInfusionLegs -= repairAmount;
        }
        if (extendedProperties.bankedInfusionBoots > 1) {
            int repairAmount = (int) Math.floor(extendedProperties.bankedInfusionBoots);
            RepairEquippedArsMagicaArmorItem(player, repairAmount, 0);
            extendedProperties.bankedInfusionBoots -= repairAmount;
        }
    }
}
Also used : ExtendedProperties(am2.playerextensions.ExtendedProperties)

Aggregations

ExtendedProperties (am2.playerextensions.ExtendedProperties)26 EntityPlayer (net.minecraft.entity.player.EntityPlayer)16 EntityLivingBase (net.minecraft.entity.EntityLivingBase)10 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)4 AMVector2 (am2.api.math.AMVector2)3 ItemStack (net.minecraft.item.ItemStack)3 IArmorImbuement (am2.api.items.armor.IArmorImbuement)1 BuffEffectSlowfall (am2.buffs.BuffEffectSlowfall)1 ItemSpellBook (am2.items.ItemSpellBook)1 AMDataWriter (am2.network.AMDataWriter)1 ParticleExpandingCollapsingRingAtPoint (am2.particles.ParticleExpandingCollapsingRingAtPoint)1 AffinityData (am2.playerextensions.AffinityData)1 RiftStorage (am2.playerextensions.RiftStorage)1 SkillData (am2.playerextensions.SkillData)1 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 Minecraft (net.minecraft.client.Minecraft)1 EntityRenderer (net.minecraft.client.renderer.EntityRenderer)1 IAttributeInstance (net.minecraft.entity.ai.attributes.IAttributeInstance)1 EntityItemFrame (net.minecraft.entity.item.EntityItemFrame)1