Search in sources :

Example 41 with EntityItem

use of net.minecraft.entity.item.EntityItem in project BluePower by Qmunity.

the class TileProjectTable method craft.

protected void craft() {
    for (int i = 0; i < craftingGrid.length; ++i) {
        ItemStack itemstack1 = craftingGrid[i];
        if (itemstack1 != null) {
            boolean pulledFromInventory = false;
            if (craftingGrid[i].stackSize == 1) {
                ItemStack stackFromTable = ContainerProjectTable.extractStackFromTable(this, craftingGrid[i], false);
                pulledFromInventory = stackFromTable != null;
            }
            if (!pulledFromInventory) {
                craftingGrid[i].stackSize--;
                if (craftingGrid[i].stackSize <= 0)
                    craftingGrid[i] = null;
            }
            if (itemstack1.getItem().hasContainerItem(itemstack1)) {
                ItemStack itemstack2 = itemstack1.getItem().getContainerItem(itemstack1);
                if (itemstack2 != null && itemstack2.isItemStackDamageable() && itemstack2.getItemDamage() > itemstack2.getMaxDamage()) {
                    continue;
                }
                if (!itemstack1.getItem().doesContainerItemLeaveCraftingGrid(itemstack1)) {
                    ItemStack remainder = IOHelper.insert(this, itemstack2, 0, false);
                    if (remainder != null) {
                        worldObj.spawnEntityInWorld(new EntityItem(worldObj, xCoord, yCoord, zCoord, remainder));
                    }
                }
            }
        }
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 42 with EntityItem

use of net.minecraft.entity.item.EntityItem in project BluePower by Qmunity.

the class TileTransposer method suckItems.

private void suckItems() {
    for (EntityItem entity : (List<EntityItem>) worldObj.getEntitiesWithinAABB(EntityItem.class, ITEM_SUCK_AABBS[getFacingDirection().ordinal()].copy().offset(xCoord, yCoord, zCoord))) {
        ItemStack stack = entity.getEntityItem();
        if (isItemAccepted(stack) && !entity.isDead) {
            addItemToOutputBuffer(stack, getAcceptedItemColor(stack));
            entity.setDead();
        }
    }
}
Also used : List(java.util.List) ItemStack(net.minecraft.item.ItemStack) EntityItem(net.minecraft.entity.item.EntityItem)

Example 43 with EntityItem

use of net.minecraft.entity.item.EntityItem in project LogisticsPipes by RS485.

the class PipeItemsRequestLogisticsMk2 method dropDisk.

public void dropDisk() {
    if (disk != null) {
        EntityItem item = new EntityItem(getWorld(), getX(), getY(), getZ(), disk);
        getWorld().spawnEntityInWorld(item);
        disk = null;
    }
}
Also used : EntityItem(net.minecraft.entity.item.EntityItem)

Example 44 with EntityItem

use of net.minecraft.entity.item.EntityItem in project LogisticsPipes by RS485.

the class PipeItemsSystemDestinationLogistics method dropFreqCard.

private void dropFreqCard() {
    if (inv.getStackInSlot(0) == null) {
        return;
    }
    EntityItem item = new EntityItem(getWorld(), getX(), getY(), getZ(), inv.getStackInSlot(0));
    getWorld().spawnEntityInWorld(item);
    inv.clearInventorySlotContents(0);
}
Also used : EntityItem(net.minecraft.entity.item.EntityItem)

Example 45 with EntityItem

use of net.minecraft.entity.item.EntityItem in project LogisticsPipes by RS485.

the class PipeItemsSystemEntranceLogistics method dropFreqCard.

private void dropFreqCard() {
    if (inv.getStackInSlot(0) == null) {
        return;
    }
    EntityItem item = new EntityItem(getWorld(), getX(), getY(), getZ(), inv.getStackInSlot(0));
    getWorld().spawnEntityInWorld(item);
    inv.clearInventorySlotContents(0);
}
Also used : 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