Search in sources :

Example 6 with IStorageMonitorable

use of appeng.api.storage.IStorageMonitorable in project LogisticsPipes by RS485.

the class AEInterfaceInventoryHandler method add.

@Override
public ItemStack add(ItemStack stack, ForgeDirection from, boolean doAdd) {
    ItemStack st = stack.copy();
    IAEItemStack tst = AEApi.instance().storage().createItemStack(stack);
    IStorageMonitorable tmp = tile.getMonitorable(dir, source);
    if (tmp == null || tmp.getItemInventory() == null) {
        return st;
    }
    IAEItemStack overflow = tmp.getItemInventory().injectItems(tst, Actionable.MODULATE, source);
    if (overflow != null) {
        st.stackSize -= overflow.getStackSize();
    }
    return st;
}
Also used : IAEItemStack(appeng.api.storage.data.IAEItemStack) ItemStack(net.minecraft.item.ItemStack) IAEItemStack(appeng.api.storage.data.IAEItemStack) IStorageMonitorable(appeng.api.storage.IStorageMonitorable)

Example 7 with IStorageMonitorable

use of appeng.api.storage.IStorageMonitorable in project LogisticsPipes by RS485.

the class AEInterfaceInventoryHandler method getSingleItem.

@Override
public ItemStack getSingleItem(ItemIdentifier item) {
    IStorageMonitorable tmp = tile.getMonitorable(dir, source);
    if (tmp == null || tmp.getItemInventory() == null) {
        return null;
    }
    IAEItemStack stack = AEApi.instance().storage().createItemStack(item.makeNormalStack(1));
    IAEItemStack extract = tmp.getItemInventory().extractItems(stack, Actionable.MODULATE, source);
    if (extract == null) {
        return null;
    }
    return extract.getItemStack();
}
Also used : IAEItemStack(appeng.api.storage.data.IAEItemStack) IStorageMonitorable(appeng.api.storage.IStorageMonitorable)

Example 8 with IStorageMonitorable

use of appeng.api.storage.IStorageMonitorable in project LogisticsPipes by RS485.

the class AEInterfaceInventoryHandler method roomForItem.

@Override
public int roomForItem(ItemIdentifier item, int count) {
    IStorageMonitorable tmp = tile.getMonitorable(dir, source);
    if (tmp == null || tmp.getItemInventory() == null) {
        return 0;
    }
    while (count > 0) {
        IAEItemStack stack = AEApi.instance().storage().createItemStack(item.makeNormalStack(count));
        if (tmp.getItemInventory().canAccept(stack)) {
            return count;
        }
        count--;
    }
    return 0;
}
Also used : IAEItemStack(appeng.api.storage.data.IAEItemStack) IStorageMonitorable(appeng.api.storage.IStorageMonitorable)

Aggregations

IStorageMonitorable (appeng.api.storage.IStorageMonitorable)8 IAEItemStack (appeng.api.storage.data.IAEItemStack)6 ITileStorageMonitorable (appeng.api.implementations.tiles.ITileStorageMonitorable)2 IGridHost (appeng.api.networking.IGridHost)2 MachineSource (appeng.api.networking.security.MachineSource)2 IAEFluidStack (appeng.api.storage.data.IAEFluidStack)2 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)2 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)2 HashMap (java.util.HashMap)1 TreeSet (java.util.TreeSet)1 FluidIdentifier (logisticspipes.utils.FluidIdentifier)1 ItemStack (net.minecraft.item.ItemStack)1