Search in sources :

Example 21 with EntityLiving

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

the class Charm method applyEffectEntity.

@Override
public boolean applyEffectEntity(ItemStack stack, World world, EntityLivingBase caster, Entity target) {
    if (!(target instanceof EntityCreature) || ((EntityCreature) target).isPotionActive(BuffList.charmed) || EntityUtilities.isSummon((EntityCreature) target)) {
        return false;
    }
    int duration = SpellUtils.instance.getModifiedInt_Mul(BuffList.default_buff_duration, stack, caster, target, world, 0, SpellModifiers.DURATION);
    duration = SpellUtils.instance.modifyDurationBasedOnArmor(caster, duration);
    int x = (int) Math.floor(target.posX);
    int y = (int) Math.floor(target.posY);
    int z = (int) Math.floor(target.posZ);
    if (RitualShapeHelper.instance.checkForRitual(this, world, x, y, z) != null) {
        duration += (3600 * (SpellUtils.instance.countModifiers(SpellModifiers.BUFF_POWER, stack, 0) + 1));
        RitualShapeHelper.instance.consumeRitualReagents(this, world, x, y, z);
    }
    if (target instanceof EntityAnimal) {
        ((EntityAnimal) target).func_146082_f(null);
        return true;
    }
    if (ExtendedProperties.For(caster).getCanHaveMoreSummons()) {
        if (caster instanceof EntityPlayer) {
            if (target instanceof EntityCreature) {
                BuffEffectCharmed charmBuff = new BuffEffectCharmed(duration, BuffEffectCharmed.CHARM_TO_PLAYER);
                charmBuff.setCharmer(caster);
                ((EntityCreature) target).addPotionEffect(charmBuff);
            }
            return true;
        } else if (caster instanceof EntityLiving) {
            if (target instanceof EntityCreature) {
                BuffEffectCharmed charmBuff = new BuffEffectCharmed(duration, BuffEffectCharmed.CHARM_TO_MONSTER);
                charmBuff.setCharmer(caster);
                ((EntityCreature) target).addPotionEffect(charmBuff);
            }
            return true;
        }
    } else {
        if (caster instanceof EntityPlayer) {
            ((EntityPlayer) caster).addChatMessage(new ChatComponentText("You cannot have any more summons."));
        }
        return true;
    }
    return false;
}
Also used : BuffEffectCharmed(am2.buffs.BuffEffectCharmed) EntityLiving(net.minecraft.entity.EntityLiving) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityAnimal(net.minecraft.entity.passive.EntityAnimal) ChatComponentText(net.minecraft.util.ChatComponentText) EntityCreature(net.minecraft.entity.EntityCreature)

Example 22 with EntityLiving

use of net.minecraft.entity.EntityLiving in project VoodooCraft by Mod-DevCafeTeam.

the class ItemShard method itemInteractionForEntity.

@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase target, EnumHand hand) {
    World world = player.getEntityWorld();
    ItemStack stackIn = player.getHeldItemMainhand();
    if (!world.isRemote) {
        if (checkNBTInfo(stack)) {
            if (target != null) {
                if (target instanceof EntityLiving) {
                    EntityLiving livingTarget = (EntityLiving) target;
                    target.attackEntityFrom(DamageSource.causePlayerDamage(player), 0.5F);
                    NBTHelper.setOwnerTag(stackIn, target);
                    livingTarget.enablePersistence();
                }
                return true;
            }
        }
    }
    return false;
}
Also used : EntityLiving(net.minecraft.entity.EntityLiving) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack)

Example 23 with EntityLiving

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

the class TileEntityInertSpawner method updateEntity.

public void updateEntity() {
    super.updateEntity();
    if (!worldObj.isRemote && phylactery != null && ((ItemCrystalPhylactery) phylactery.getItem()).isFull(phylactery) && !worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) {
        if (this.powerConsumed < this.SUMMON_REQ) {
            this.powerConsumed += PowerNodeRegistry.For(worldObj).consumePower(this, PowerTypes.DARK, Math.min(this.getCapacity(), this.SUMMON_REQ - this.powerConsumed));
        } else {
            this.powerConsumed = 0;
            ItemCrystalPhylactery item = (ItemCrystalPhylactery) this.phylactery.getItem();
            if (item.isFull(phylactery)) {
                String clazzName = item.getSpawnClass(phylactery);
                if (clazzName != null) {
                    Class clazz = (Class) EntityList.stringToClassMapping.get(clazzName);
                    if (clazz != null) {
                        EntityLiving entity = null;
                        try {
                            entity = (EntityLiving) clazz.getConstructor(World.class).newInstance(worldObj);
                        } catch (Throwable t) {
                            t.printStackTrace();
                            return;
                        }
                        if (entity == null)
                            return;
                        setEntityPosition(entity);
                        worldObj.spawnEntityInWorld(entity);
                    }
                }
            }
        }
    }
}
Also used : EntityLiving(net.minecraft.entity.EntityLiving) ItemCrystalPhylactery(am2.items.ItemCrystalPhylactery) World(net.minecraft.world.World)

Example 24 with EntityLiving

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

the class AMSpawnEgg method onItemUse.

@Override
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) {
    if (par3World.isRemote) {
        return true;
    } else {
        Block block = par3World.getBlock(par4, par5, par6);
        par4 += Facing.offsetsXForSide[par7];
        par5 += Facing.offsetsYForSide[par7];
        par6 += Facing.offsetsZForSide[par7];
        double d0 = 0.0D;
        if (par7 == 1 && block != null && block.getRenderType() == 11) {
            d0 = 0.5D;
        }
        Entity entity = spawnCreature(par3World, par1ItemStack.getItemDamage(), par4 + 0.5D, par5 + d0, par6 + 0.5D);
        if (entity != null) {
            if (entity instanceof EntityLiving && par1ItemStack.hasDisplayName()) {
                ((EntityLiving) entity).setCustomNameTag(par1ItemStack.getDisplayName());
            }
            if (!par2EntityPlayer.capabilities.isCreativeMode) {
                --par1ItemStack.stackSize;
            }
        }
        return true;
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityLiving(net.minecraft.entity.EntityLiving) Block(net.minecraft.block.Block)

Example 25 with EntityLiving

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

the class AMSpawnEgg method spawnCreature.

public static Entity spawnCreature(World par0World, int par1, double par2, double par4, double par6) {
    Class entityClass = getSpawnClassFromMeta(par1);
    if (entityClass == null) {
        return null;
    } else {
        Entity entity = null;
        try {
            Constructor c = entityClass.getConstructor(World.class);
            entity = (Entity) c.newInstance(par0World);
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (SecurityException e) {
            e.printStackTrace();
        } catch (IllegalArgumentException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        if (entity != null && entity instanceof EntityLiving) {
            EntityLiving entityliving = (EntityLiving) entity;
            entity.setLocationAndAngles(par2, par4, par6, MathHelper.wrapAngleTo180_float(par0World.rand.nextFloat() * 360.0F), 0.0F);
            entityliving.rotationYawHead = entityliving.rotationYaw;
            entityliving.renderYawOffset = entityliving.rotationYaw;
            par0World.spawnEntityInWorld(entity);
            entityliving.playLivingSound();
        }
        return entity;
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityLiving(net.minecraft.entity.EntityLiving) Constructor(java.lang.reflect.Constructor) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

EntityLiving (net.minecraft.entity.EntityLiving)44 Entity (net.minecraft.entity.Entity)14 EntityPlayer (net.minecraft.entity.player.EntityPlayer)14 ItemStack (net.minecraft.item.ItemStack)11 EntityLivingBase (net.minecraft.entity.EntityLivingBase)7 World (net.minecraft.world.World)6 Block (net.minecraft.block.Block)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 PotionEffect (net.minecraft.potion.PotionEffect)4 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 EntityCreature (net.minecraft.entity.EntityCreature)3 BlockPos (net.minecraft.util.math.BlockPos)3 Pos (com.builtbroken.mc.imp.transform.vector.Pos)2 ArrayList (java.util.ArrayList)2 Random (java.util.Random)2 EntityItem (net.minecraft.entity.item.EntityItem)2 EntityXPOrb (net.minecraft.entity.item.EntityXPOrb)2 EntityMob (net.minecraft.entity.monster.EntityMob)2 EntityZombie (net.minecraft.entity.monster.EntityZombie)2