Search in sources :

Example 76 with EntityItem

use of net.minecraft.entity.item.EntityItem in project ArsMagica2 by Mithion.

the class TileEntityArcaneDeconstructor method transferOrEjectItem.

private void transferOrEjectItem(ItemStack stack) {
    if (worldObj.isRemote)
        return;
    boolean eject = false;
    for (int i = -1; i <= 1; ++i) {
        for (int j = -1; j <= 1; ++j) {
            for (int k = -1; k <= 1; ++k) {
                if (i == 0 && j == 0 && k == 0)
                    continue;
                TileEntity te = worldObj.getTileEntity(xCoord + i, yCoord + j, zCoord + k);
                if (te != null && te instanceof IInventory) {
                    for (int side = 0; side < 6; ++side) {
                        if (InventoryUtilities.mergeIntoInventory((IInventory) te, stack, stack.stackSize, side))
                            return;
                    }
                }
            }
        }
    }
    //eject the remainder
    EntityItem item = new EntityItem(worldObj);
    item.setPosition(xCoord + 0.5, yCoord + 1.5, zCoord + 0.5);
    item.setEntityItemStack(stack);
    worldObj.spawnEntityInWorld(item);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) EntityItem(net.minecraft.entity.item.EntityItem)

Example 77 with EntityItem

use of net.minecraft.entity.item.EntityItem in project ArsMagica2 by Mithion.

the class TileEntityCraftingAltar method checkForStartCondition.

private void checkForStartCondition() {
    if (this.worldObj.isRemote || !structureValid || this.isCrafting)
        return;
    List<Entity> items = this.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(xCoord - 2, yCoord - 3, zCoord - 2, xCoord + 2, yCoord, zCoord + 2));
    if (items.size() == 1) {
        EntityItem item = (EntityItem) items.get(0);
        if (item != null && !item.isDead && item.getEntityItem().getItem() == ItemsCommonProxy.rune && item.getEntityItem().getItemDamage() == ItemsCommonProxy.rune.META_BLANK) {
            item.setDead();
            setCrafting(true);
        }
    }
}
Also used : S35PacketUpdateTileEntity(net.minecraft.network.play.server.S35PacketUpdateTileEntity) Entity(net.minecraft.entity.Entity) EntityItem(net.minecraft.entity.item.EntityItem)

Example 78 with EntityItem

use of net.minecraft.entity.item.EntityItem in project ArsMagica2 by Mithion.

the class EntityFireElemental method onUpdate.

@Override
public void onUpdate() {
    int cookTargetID = dataWatcher.getWatchableObjectInt(19);
    if (cookTargetID != 0) {
        List<EntityItem> items = worldObj.getEntitiesWithinAABB(EntityItem.class, this.boundingBox.expand(cookRadius, cookRadius, cookRadius));
        EntityItem inanimate = null;
        for (EntityItem item : items) {
            if (item.getEntityId() == cookTargetID) {
                inanimate = item;
            }
        }
        if (inanimate != null && worldObj.isRemote) {
            AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(worldObj, "fire", posX, posY + getEyeHeight(), posZ);
            if (effect != null) {
                effect.setIgnoreMaxAge(true);
                effect.AddParticleController(new ParticleApproachPoint(effect, inanimate.posX + (rand.nextFloat() - 0.5), inanimate.posY + (rand.nextFloat() - 0.5), inanimate.posZ + (rand.nextFloat() - 0.5), 0.1f, 0.1f, 1, false).setKillParticleOnFinish(true));
            }
        }
    }
    if (worldObj.isRemote && rand.nextInt(100) > 75 && !isBurning())
        for (int i = 0; i < AMCore.config.getGFXLevel(); i++) worldObj.spawnParticle("largesmoke", posX + (rand.nextDouble() - 0.5D) * width, posY + rand.nextDouble() * height, posZ + (rand.nextDouble() - 0.5D) * width, 0.0D, 0.0D, 0.0D);
    super.onUpdate();
}
Also used : AMParticle(am2.particles.AMParticle) ParticleApproachPoint(am2.particles.ParticleApproachPoint) ParticleApproachPoint(am2.particles.ParticleApproachPoint) EntityItem(net.minecraft.entity.item.EntityItem)

Example 79 with EntityItem

use of net.minecraft.entity.item.EntityItem in project ArsMagica2 by Mithion.

the class EntityAirSled method interact.

@Override
public boolean interact(EntityPlayer par1EntityPlayer) {
    if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != par1EntityPlayer) {
        return true;
    } else {
        if (!this.worldObj.isRemote) {
            if (par1EntityPlayer.isSneaking()) {
                this.setDead();
                EntityItem item = new EntityItem(worldObj);
                item.setPosition(posX, posY, posZ);
                item.setEntityItemStack(ItemsCommonProxy.airSledEnchanted.copy());
                worldObj.spawnEntityInWorld(item);
            } else {
                par1EntityPlayer.mountEntity(this);
            }
        }
        return true;
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityItem(net.minecraft.entity.item.EntityItem)

Example 80 with EntityItem

use of net.minecraft.entity.item.EntityItem in project ArsMagica2 by Mithion.

the class LifeTap method applyEffectBlock.

@Override
public boolean applyEffectBlock(ItemStack stack, World world, int blockx, int blocky, int blockz, int blockFace, double impactX, double impactY, double impactZ, EntityLivingBase caster) {
    if (world.getBlock(blockx, blocky, blockz) == Blocks.mob_spawner) {
        ItemStack[] reagents = RitualShapeHelper.instance.checkForRitual(this, world, blockx, blocky, blockz);
        if (reagents != null) {
            if (!world.isRemote) {
                world.setBlockToAir(blockx, blocky, blockz);
                RitualShapeHelper.instance.consumeRitualReagents(this, world, blockx, blocky, blockz);
                RitualShapeHelper.instance.consumeRitualShape(this, world, blockx, blocky, blockz);
                EntityItem item = new EntityItem(world);
                item.setPosition(blockx + 0.5, blocky + 0.5, blockz + 0.5);
                item.setEntityItemStack(new ItemStack(BlocksCommonProxy.inertSpawner));
                world.spawnEntityInWorld(item);
            } else {
            }
            return true;
        }
    }
    return false;
}
Also used : ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Aggregations

EntityItem (net.minecraft.entity.item.EntityItem)284 ItemStack (net.minecraft.item.ItemStack)178 TileEntity (net.minecraft.tileentity.TileEntity)45 EntityPlayer (net.minecraft.entity.player.EntityPlayer)36 Entity (net.minecraft.entity.Entity)26 ArrayList (java.util.ArrayList)19 BlockPos (net.minecraft.util.math.BlockPos)19 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)18 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)16 World (net.minecraft.world.World)16 Random (java.util.Random)15 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)14 Item (net.minecraft.item.Item)13 IInventory (net.minecraft.inventory.IInventory)12 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)12 List (java.util.List)11 Block (net.minecraft.block.Block)11 EntityLivingBase (net.minecraft.entity.EntityLivingBase)11 IBlockState (net.minecraft.block.state.IBlockState)10 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)6