Search in sources :

Example 46 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase 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 47 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase 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 48 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase 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 49 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase 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 50 with EntityLivingBase

use of net.minecraft.entity.EntityLivingBase in project ArsMagica2 by Mithion.

the class AffinityData method onAffinityAbility.

public void onAffinityAbility() {
    if (getAffinityDepth(Affinity.ENDER) >= 0.75) {
        if (this.entity.isSneaking()) {
            this.hasActivatedNightVision = !this.hasActivatedNightVision;
        } else {
            if (this.lastGroundPosition != null) {
                if (positionIsValid(lastGroundPosition)) {
                    spawnParticlesAt(lastGroundPosition);
                    spawnParticlesAt(new AMVector3(entity));
                    this.entity.setPosition(this.lastGroundPosition.x, this.lastGroundPosition.y + 1, this.lastGroundPosition.z);
                    ExtendedProperties.For((EntityLivingBase) this.entity).setFallProtection(20000);
                    this.entity.worldObj.playSoundEffect(entity.posX, entity.posY, entity.posZ, "mob.endermen.portal", 1.0F, 1.0F);
                    this.setCooldown(AMCore.config.getEnderAffinityAbilityCooldown());
                } else {
                    ((EntityPlayer) this.entity).addChatMessage(new ChatComponentText("am2.affinity.enderTPFailed"));
                }
            } else {
                ((EntityPlayer) this.entity).addChatMessage(new ChatComponentText("am2.affinity.enderTPFailed"));
            }
        }
    }
//beyond here we can handle other affinities that have activatable abilities
}
Also used : AMVector3(am2.api.math.AMVector3) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ChatComponentText(net.minecraft.util.ChatComponentText)

Aggregations

EntityLivingBase (net.minecraft.entity.EntityLivingBase)270 EntityPlayer (net.minecraft.entity.player.EntityPlayer)100 Entity (net.minecraft.entity.Entity)72 PotionEffect (net.minecraft.potion.PotionEffect)43 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)39 ItemStack (net.minecraft.item.ItemStack)36 Vec3d (net.minecraft.util.math.Vec3d)25 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)25 BlockPos (net.minecraft.util.math.BlockPos)24 TileEntity (net.minecraft.tileentity.TileEntity)23 World (net.minecraft.world.World)20 IBlockState (net.minecraft.block.state.IBlockState)19 AMVector3 (am2.api.math.AMVector3)15 IArsMagicaBoss (am2.bosses.IArsMagicaBoss)15 ArrayList (java.util.ArrayList)15 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)15 Block (net.minecraft.block.Block)12 EntityItem (net.minecraft.entity.item.EntityItem)11 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)11 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)10