Search in sources :

Example 1 with ExtendedProperties

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

the class ItemBoundHoe method onUpdate.

@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int slotIndex, boolean par5) {
    if (par3Entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) par3Entity;
        if (player.capabilities.isCreativeMode)
            return;
        ExtendedProperties props = ExtendedProperties.For(player);
        if (props.getCurrentMana() + props.getBonusCurrentMana() < this.maintainCost()) {
            UnbindItem(par1ItemStack, (EntityPlayer) par3Entity, slotIndex);
            return;
        } else {
            props.deductMana(this.maintainCost());
        }
        if (par1ItemStack.getItemDamage() > 0)
            par1ItemStack.damageItem(-1, (EntityLivingBase) par3Entity);
    }
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Example 2 with ExtendedProperties

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

the class ItemBoundPickaxe method onUpdate.

@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int slotIndex, boolean par5) {
    if (par3Entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) par3Entity;
        if (player.capabilities.isCreativeMode)
            return;
        ExtendedProperties props = ExtendedProperties.For(player);
        if (props.getCurrentMana() + props.getBonusCurrentMana() < this.maintainCost()) {
            UnbindItem(par1ItemStack, (EntityPlayer) par3Entity, slotIndex);
            return;
        } else {
            props.deductMana(this.maintainCost());
        }
        if (par1ItemStack.getItemDamage() > 0)
            par1ItemStack.damageItem(-1, (EntityLivingBase) par3Entity);
    }
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Example 3 with ExtendedProperties

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

the class ItemBoundShovel method onUpdate.

@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int slotIndex, boolean par5) {
    if (par3Entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) par3Entity;
        if (player.capabilities.isCreativeMode)
            return;
        ExtendedProperties props = ExtendedProperties.For(player);
        if (props.getCurrentMana() + props.getBonusCurrentMana() < this.maintainCost()) {
            UnbindItem(par1ItemStack, (EntityPlayer) par3Entity, slotIndex);
            return;
        } else {
            props.deductMana(this.maintainCost());
        }
        if (par1ItemStack.getItemDamage() > 0)
            par1ItemStack.damageItem(-1, (EntityLivingBase) par3Entity);
    }
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Example 4 with ExtendedProperties

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

the class ItemBoundSword method onUpdate.

@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int slotIndex, boolean par5) {
    if (par3Entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) par3Entity;
        if (player.capabilities.isCreativeMode)
            return;
        ExtendedProperties props = ExtendedProperties.For(player);
        if (props.getCurrentMana() + props.getBonusCurrentMana() < this.maintainCost()) {
            UnbindItem(par1ItemStack, (EntityPlayer) par3Entity, slotIndex);
            return;
        } else {
            props.deductMana(this.maintainCost());
        }
        if (par1ItemStack.getItemDamage() > 0)
            par1ItemStack.damageItem(-1, (EntityLivingBase) par3Entity);
    }
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Example 5 with ExtendedProperties

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

the class LifeTap method applyEffectEntity.

@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
    if (!(target instanceof EntityLivingBase))
        return false;
    if (!world.isRemote) {
        double damage = SpellUtils.instance.getModifiedDouble_Mul(2, stack, caster, target, world, 0, SpellModifiers.DAMAGE);
        ExtendedProperties casterProperties = ExtendedProperties.For(caster);
        float manaRefunded = (float) (((damage * 0.01)) * casterProperties.getMaxMana());
        if ((caster).attackEntityFrom(DamageSource.outOfWorld, (int) Math.floor(damage))) {
            casterProperties.setCurrentMana(casterProperties.getCurrentMana() + manaRefunded);
            casterProperties.forceSync();
        } else {
            return false;
        }
    }
    return true;
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) 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