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;
}
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;
}
}
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;
}
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;
}
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);
}
Aggregations