Search in sources :

Example 6 with EntityLiving

use of net.minecraft.entity.EntityLiving in project MineFactoryReloaded by powercrystals.

the class GrindingDamage method getDeathMessage.

@Override
public String getDeathMessage(EntityLiving par1EntityLiving) {
    EntityLiving entityliving1 = par1EntityLiving.func_94060_bK();
    String s = "death.attack." + this.damageType;
    if (_msgCount > 0) {
        int msg = _rand.nextInt(_msgCount);
        if (msg != 0) {
            s += "." + msg;
        }
    }
    String s1 = s + ".player";
    return entityliving1 != null && StatCollector.func_94522_b(s1) ? StatCollector.translateToLocalFormatted(s1, new Object[] { par1EntityLiving.getTranslatedEntityName(), entityliving1.getTranslatedEntityName() }) : StatCollector.translateToLocalFormatted(s, new Object[] { par1EntityLiving.getTranslatedEntityName() });
}
Also used : EntityLiving(net.minecraft.entity.EntityLiving)

Example 7 with EntityLiving

use of net.minecraft.entity.EntityLiving in project MineFactoryReloaded by powercrystals.

the class ItemSafariNet method releaseEntity.

public static Entity releaseEntity(ItemStack itemstack, World world, int x, int y, int z, int side) {
    if (world.isRemote) {
        return null;
    }
    Entity spawnedCreature;
    int blockId = world.getBlockId(x, y, z);
    x += Facing.offsetsXForSide[side];
    y += Facing.offsetsYForSide[side];
    z += Facing.offsetsZForSide[side];
    double spawnOffsetY = 0.0D;
    if (side == 1 && Block.blocksList[blockId] != null && Block.blocksList[blockId].getRenderType() == 11) {
        spawnOffsetY = 0.5D;
    }
    if (itemstack.getItemDamage() != 0) {
        spawnedCreature = spawnCreature(world, itemstack.getItemDamage(), x + 0.5D, y + spawnOffsetY, z + 0.5D);
    } else {
        spawnedCreature = spawnCreature(world, itemstack.getTagCompound(), x + 0.5D, y + spawnOffsetY, z + 0.5D, side);
    }
    if (spawnedCreature != null) {
        if ((spawnedCreature instanceof EntityLiving) && itemstack.itemID == MineFactoryReloadedCore.safariNetJailerItem.itemID && itemstack.hasDisplayName()) {
            ((EntityLiving) spawnedCreature).func_94058_c(itemstack.getDisplayName());
        }
        if (isSingleUse(itemstack)) {
            itemstack.stackSize--;
        } else if (itemstack.getItemDamage() != 0) {
            itemstack.setItemDamage(0);
        } else {
            itemstack.setTagCompound(null);
        }
    }
    return spawnedCreature;
}
Also used : Entity(net.minecraft.entity.Entity) EntityLiving(net.minecraft.entity.EntityLiving)

Example 8 with EntityLiving

use of net.minecraft.entity.EntityLiving in project MineFactoryReloaded by powercrystals.

the class EntitySafariNet method onImpact.

@Override
protected void onImpact(MovingObjectPosition mop) {
    ItemStack storedEntity = dataWatcher.getWatchableObjectItemStack(13);
    if (mop.typeOfHit == EnumMovingObjectType.TILE) {
        if (ItemSafariNet.isEmpty(storedEntity)) {
            dropAsStack(storedEntity);
        } else {
            ItemSafariNet.releaseEntity(storedEntity, worldObj, mop.blockX, mop.blockY, mop.blockZ, mop.sideHit);
            if (ItemSafariNet.isSingleUse(storedEntity)) {
                dropAsStack(null);
            } else {
                dropAsStack(storedEntity);
            }
        }
    } else {
        if (ItemSafariNet.isEmpty(storedEntity) && mop.entityHit instanceof EntityLiving) {
            ItemSafariNet.captureEntity(storedEntity, (EntityLiving) mop.entityHit);
            dropAsStack(storedEntity);
        } else {
            if (!ItemSafariNet.isEmpty(storedEntity)) {
                Entity releasedEntity = ItemSafariNet.releaseEntity(storedEntity, worldObj, (int) mop.entityHit.posX, (int) mop.entityHit.posY, (int) mop.entityHit.posZ, 1);
                if (mop.entityHit instanceof EntityLiving) {
                    if (releasedEntity instanceof EntityLiving) {
                        //Functional for skeletons.
                        ((EntityLiving) releasedEntity).setAttackTarget((EntityLiving) mop.entityHit);
                    }
                    if (releasedEntity instanceof EntityCreature) {
                        //functional for mobs that extend EntityCreature (everything but Ghasts) and not Skeletons.
                        ((EntityCreature) releasedEntity).setTarget(mop.entityHit);
                    }
                }
                if (ItemSafariNet.isSingleUse(storedEntity)) {
                    dropAsStack(null);
                    return;
                }
            }
            dropAsStack(storedEntity);
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityLiving(net.minecraft.entity.EntityLiving) ItemStack(net.minecraft.item.ItemStack) EntityCreature(net.minecraft.entity.EntityCreature)

Example 9 with EntityLiving

use of net.minecraft.entity.EntityLiving in project MineFactoryReloaded by powercrystals.

the class TileEntityRancher method activateMachine.

@Override
public boolean activateMachine() {
    MFRLiquidMover.pumpLiquid(_tank, this);
    boolean didDrop = false;
    List<?> entities = worldObj.getEntitiesWithinAABB(EntityLiving.class, _areaManager.getHarvestArea().toAxisAlignedBB());
    for (Object o : entities) {
        EntityLiving e = (EntityLiving) o;
        if (MFRRegistry.getRanchables().containsKey(e.getClass())) {
            IFactoryRanchable r = MFRRegistry.getRanchables().get(e.getClass());
            List<ItemStack> drops = r.ranch(worldObj, e, this);
            if (drops != null) {
                for (ItemStack s : drops) {
                    if (LiquidContainerRegistry.isLiquid(s)) {
                        _tank.fill(new LiquidStack(s.itemID, LiquidContainerRegistry.BUCKET_VOLUME, s.getItemDamage()), true);
                        didDrop = true;
                        continue;
                    }
                    doDrop(s);
                    didDrop = true;
                }
                if (didDrop) {
                    setIdleTicks(20);
                    return true;
                }
            }
        }
    }
    setIdleTicks(getIdleTicksMax());
    return false;
}
Also used : LiquidStack(net.minecraftforge.liquids.LiquidStack) EntityLiving(net.minecraft.entity.EntityLiving) ItemStack(net.minecraft.item.ItemStack) IFactoryRanchable(powercrystals.minefactoryreloaded.api.IFactoryRanchable)

Example 10 with EntityLiving

use of net.minecraft.entity.EntityLiving in project MineFactoryReloaded by powercrystals.

the class TileEntityVet method activateMachine.

@Override
public boolean activateMachine() {
    List<?> entities = worldObj.getEntitiesWithinAABB(EntityLiving.class, _areaManager.getHarvestArea().toAxisAlignedBB());
    for (Object o : entities) {
        if (!(o instanceof EntityLiving) || o instanceof EntityPlayer || o instanceof EntityMob) {
            continue;
        }
        EntityLiving e = (EntityLiving) o;
        for (int i = 0; i < getSizeInventory(); i++) {
            ItemStack s = getStackInSlot(i);
            if (s != null && s.getItem() instanceof ISyringe) {
                if (((ISyringe) s.getItem()).canInject(worldObj, e, s)) {
                    if (((ISyringe) s.getItem()).inject(worldObj, e, s)) {
                        s.itemID = MineFactoryReloadedCore.syringeEmptyItem.itemID;
                        return true;
                    }
                }
            }
        }
    }
    setIdleTicks(getIdleTicksMax());
    return false;
}
Also used : EntityMob(net.minecraft.entity.monster.EntityMob) EntityLiving(net.minecraft.entity.EntityLiving) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ISyringe(powercrystals.minefactoryreloaded.api.ISyringe) ItemStack(net.minecraft.item.ItemStack)

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