Search in sources :

Example 96 with IInventory

use of net.minecraft.inventory.IInventory in project PneumaticCraft by MineMaarten.

the class IOHelper method insert.

/**
     * Inserts on all sides
     * @param tile
     * @param itemStack
     * @param simulate
     * @return
     */
public static ItemStack insert(TileEntity tile, ItemStack itemStack, boolean simulate) {
    IInventory inv = getInventoryForTE(tile);
    ItemStack insertingStack = itemStack.copy();
    for (int i = 0; i < 6; i++) {
        insertingStack = insert(inv, insertingStack, i, simulate);
        if (insertingStack == null || insertingStack.stackSize != itemStack.stackSize)
            return insertingStack;
    }
    return insertingStack;
}
Also used : IInventory(net.minecraft.inventory.IInventory) ItemStack(net.minecraft.item.ItemStack)

Example 97 with IInventory

use of net.minecraft.inventory.IInventory in project PneumaticCraft by MineMaarten.

the class IOHelper method getInventoryForTE.

public static IInventory getInventoryForTE(TileEntity te) {
    if (te instanceof IInventory) {
        IInventory inv = (IInventory) te;
        Block block = te.getBlockType();
        if (block instanceof BlockChest) {
            inv = ((BlockChest) block).func_149951_m(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord);
        }
        return inv;
    } else {
        return null;
    }
}
Also used : IInventory(net.minecraft.inventory.IInventory) BlockChest(net.minecraft.block.BlockChest) Block(net.minecraft.block.Block)

Example 98 with IInventory

use of net.minecraft.inventory.IInventory in project LogisticsPipes by RS485.

the class PipeItemsBasicLogistics method getPointedInventory.

@Override
public IInventoryUtil getPointedInventory(boolean forExtraction) {
    IInventoryUtil inv = super.getPointedInventory(forExtraction);
    if (inv == null) {
        Optional<Pair<IInventory, ForgeDirection>> first = new WorldCoordinatesWrapper(container).getConnectedAdjacentTileEntities(ConnectionPipeType.ITEM).filter(adjacent -> adjacent.tileEntity instanceof IInventory).map(adjacentInventory -> new Pair<>(InventoryHelper.getInventory((IInventory) adjacentInventory.tileEntity), adjacentInventory.direction)).filter(inventoryDirectionPair -> inventoryDirectionPair.getValue1() != null).findFirst();
        if (first.isPresent()) {
            Pair<IInventory, ForgeDirection> p = first.get();
            inv = SimpleServiceLocator.inventoryUtilFactory.getInventoryUtil(p.getValue1(), p.getValue2().getOpposite());
        }
    }
    return inv;
}
Also used : OrientationsUtil(logisticspipes.utils.OrientationsUtil) LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule) Textures(logisticspipes.textures.Textures) Item(net.minecraft.item.Item) TreeSet(java.util.TreeSet) LogisticsPowerJunctionTileEntity(logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity) LogisticsSecurityTileEntity(logisticspipes.blocks.LogisticsSecurityTileEntity) InventoryHelper(logisticspipes.utils.InventoryHelper) ModulePositionType(logisticspipes.modules.abstractmodules.LogisticsModule.ModulePositionType) ConnectionPipeType(logisticspipes.routing.pathfinder.IPipeInformationProvider.ConnectionPipeType) Collection(java.util.Collection) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) Set(java.util.Set) TextureType(logisticspipes.textures.Textures.TextureType) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IInventoryUtil(logisticspipes.interfaces.IInventoryUtil) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) PipeTransportLogistics(logisticspipes.transport.PipeTransportLogistics) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ModuleItemSink(logisticspipes.modules.ModuleItemSink) Pair(logisticspipes.utils.tuples.Pair) IInventory(net.minecraft.inventory.IInventory) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) Optional(java.util.Optional) TileEntity(net.minecraft.tileentity.TileEntity) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) IInventory(net.minecraft.inventory.IInventory) IInventoryUtil(logisticspipes.interfaces.IInventoryUtil) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) Pair(logisticspipes.utils.tuples.Pair)

Example 99 with IInventory

use of net.minecraft.inventory.IInventory in project LogisticsPipes by RS485.

the class PipeItemsInvSysConnector method isConnectedInv.

public boolean isConnectedInv(TileEntity tile) {
    for (int i = 0; i < 6; i++) {
        ForgeDirection dir = ForgeDirection.values()[i];
        DoubleCoordinates p = CoordinateUtils.add(new DoubleCoordinates(this), dir);
        TileEntity lTile = p.getTileEntity(getWorld());
        if (lTile instanceof IInventory) {
            if (lTile == tile) {
                return this.container.canPipeConnect(lTile, dir);
            }
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 100 with IInventory

use of net.minecraft.inventory.IInventory in project LogisticsPipes by RS485.

the class PipeItemsProviderLogistics method getAdaptedInventoryUtil.

private IInventoryUtil getAdaptedInventoryUtil(AdjacentTileEntity adjacent) {
    IInventory base = (IInventory) adjacent.tileEntity;
    if (base instanceof net.minecraft.inventory.ISidedInventory) {
        base = new SidedInventoryMinecraftAdapter((net.minecraft.inventory.ISidedInventory) base, adjacent.direction.getOpposite(), true);
    }
    ExtractionMode mode = getExtractionMode();
    switch(mode) {
        case LeaveFirst:
            return SimpleServiceLocator.inventoryUtilFactory.getHidingInventoryUtil(base, adjacent.direction.getOpposite(), false, false, 1, 0);
        case LeaveLast:
            return SimpleServiceLocator.inventoryUtilFactory.getHidingInventoryUtil(base, adjacent.direction.getOpposite(), false, false, 0, 1);
        case LeaveFirstAndLast:
            return SimpleServiceLocator.inventoryUtilFactory.getHidingInventoryUtil(base, adjacent.direction.getOpposite(), false, false, 1, 1);
        case Leave1PerStack:
            return SimpleServiceLocator.inventoryUtilFactory.getHidingInventoryUtil(base, adjacent.direction.getOpposite(), true, false, 0, 0);
        case Leave1PerType:
            return SimpleServiceLocator.inventoryUtilFactory.getHidingInventoryUtil(base, adjacent.direction.getOpposite(), false, true, 0, 0);
        default:
            break;
    }
    return SimpleServiceLocator.inventoryUtilFactory.getHidingInventoryUtil(base, adjacent.direction.getOpposite(), false, false, 0, 0);
}
Also used : IInventory(net.minecraft.inventory.IInventory) SidedInventoryMinecraftAdapter(logisticspipes.utils.SidedInventoryMinecraftAdapter) ExtractionMode(logisticspipes.logisticspipes.ExtractionMode)

Aggregations

IInventory (net.minecraft.inventory.IInventory)123 ItemStack (net.minecraft.item.ItemStack)78 TileEntity (net.minecraft.tileentity.TileEntity)53 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)21 ArrayList (java.util.ArrayList)18 ISidedInventory (net.minecraft.inventory.ISidedInventory)13 EntityItem (net.minecraft.entity.item.EntityItem)12 EntityPlayer (net.minecraft.entity.player.EntityPlayer)12 IInventoryUtil (logisticspipes.interfaces.IInventoryUtil)10 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)9 WorldCoordinatesWrapper (network.rs485.logisticspipes.world.WorldCoordinatesWrapper)9 AMVector3 (am2.api.math.AMVector3)8 List (java.util.List)8 SidedInventoryMinecraftAdapter (logisticspipes.utils.SidedInventoryMinecraftAdapter)8 SinkReply (logisticspipes.utils.SinkReply)8 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)8 LogisticsModule (logisticspipes.modules.abstractmodules.LogisticsModule)7 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)7 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)7 ConnectionPipeType (logisticspipes.routing.pathfinder.IPipeInformationProvider.ConnectionPipeType)7