Search in sources :

Example 41 with EntityLiving

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

the class TileEntitySummoner method updateEntity.

@Override
public void updateEntity() {
    super.updateEntity();
    prevSummonCooldown = summonCooldown;
    summonCooldown--;
    if (summonCooldown < 0)
        summonCooldown = 0;
    if (!worldObj.isRemote && summonCooldown == 0 && prevSummonCooldown > 0) {
        worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
    }
    if (!worldObj.isRemote) {
        EntityLiving ent = getSummonedCreature();
        if (ent == null) {
            summonEntityID = -1;
        }
        if (isRedstonePowered() && inventory[SUMMON_SLOT] != null) {
            if (PowerNodeRegistry.For(this.worldObj).checkPower(this, maintainCost)) {
                if (ent == null && canSummon()) {
                    summonCreature();
                } else {
                    if (ent != null) {
                        PowerNodeRegistry.For(this.worldObj).consumePower(this, PowerNodeRegistry.For(this.worldObj).getHighestPowerType(this), maintainCost);
                    }
                }
            } else {
                unsummonCreature();
            }
        } else {
            if (ent != null) {
                unsummonCreature();
                PowerNodeRegistry.For(this.worldObj).insertPower(this, PowerTypes.NEUTRAL, summonCost / 2);
            }
        }
    }
}
Also used : EntityLiving(net.minecraft.entity.EntityLiving)

Example 42 with EntityLiving

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

the class TileEntitySummoner method unsummonCreature.

private void unsummonCreature() {
    if (worldObj.isRemote)
        return;
    EntityLiving ent = getSummonedCreature();
    if (ent == null)
        return;
    ent.attackEntityFrom(DamageSources.unsummon, 1000000);
    this.summonEntityID = -1;
    worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
Also used : EntityLiving(net.minecraft.entity.EntityLiving)

Example 43 with EntityLiving

use of net.minecraft.entity.EntityLiving in project SecurityCraft by Geforce132.

the class BlockSecurityCamera method mountCamera.

public void mountCamera(World world, int par2, int par3, int par4, int par5, EntityPlayer player) {
    if (!world.isRemote && player.getRidingEntity() == null) {
        PlayerUtils.sendMessageToPlayer(player, I18n.translateToLocal("tile.securityCamera.name"), I18n.translateToLocal("messages.securityCamera.mounted"), TextFormatting.GREEN);
    }
    if (player.getRidingEntity() != null && player.getRidingEntity() instanceof EntitySecurityCamera) {
        EntitySecurityCamera dummyEntity = new EntitySecurityCamera(world, par2, par3, par4, par5, (EntitySecurityCamera) player.getRidingEntity());
        world.spawnEntityInWorld(dummyEntity);
        player.startRiding(dummyEntity);
        return;
    }
    EntitySecurityCamera dummyEntity = new EntitySecurityCamera(world, par2, par3, par4, par5, player);
    world.spawnEntityInWorld(dummyEntity);
    player.startRiding(dummyEntity);
    for (Object e : world.loadedEntityList) {
        if (e instanceof EntityLiving) {
            if (((EntityLiving) e).getAttackTarget() == player)
                ((EntityLiving) e).setAttackTarget(null);
        }
    }
}
Also used : TileEntitySecurityCamera(net.geforcemods.securitycraft.tileentity.TileEntitySecurityCamera) EntitySecurityCamera(net.geforcemods.securitycraft.entity.EntitySecurityCamera) EntityLiving(net.minecraft.entity.EntityLiving)

Example 44 with EntityLiving

use of net.minecraft.entity.EntityLiving in project Realistic-Terrain-Generation by Team-RTG.

the class NecronomiconSummonRitual method completeRitualServer.

@Override
protected void completeRitualServer(World world, BlockPos pos, EntityPlayer player) {
    EntityLivingBase entityliving = null;
    try {
        entityliving = entity.getConstructor(World.class).newInstance(world);
    } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
        e.printStackTrace();
    }
    if (entityliving != null) {
        entityliving.setLocationAndAngles(pos.getX(), pos.getY() + 1, pos.getZ(), entityliving.rotationYaw, entityliving.rotationPitch);
        ((EntityLiving) entityliving).onInitialSpawn(world.getDifficultyForLocation(pos.up()), (IEntityLivingData) null);
        world.spawnEntity(entityliving);
    }
}
Also used : EntityLiving(net.minecraft.entity.EntityLiving) EntityLivingBase(net.minecraft.entity.EntityLivingBase) 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