Search in sources :

Example 1 with IStorageMonitorable

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

the class AEInterfaceInventoryHandler method getItems.

@Override
public Set<ItemIdentifier> getItems() {
    Set<ItemIdentifier> result = new TreeSet<>();
    IStorageMonitorable tmp = tile.getMonitorable(dir, source);
    if (tmp == null || tmp.getItemInventory() == null || tmp.getItemInventory().getStorageList() == null) {
        return result;
    }
    for (IAEItemStack items : tmp.getItemInventory().getStorageList()) {
        ItemIdentifier ident = ItemIdentifier.get(items.getItemStack());
        result.add(ident);
    }
    return result;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) TreeSet(java.util.TreeSet) IAEItemStack(appeng.api.storage.data.IAEItemStack) IStorageMonitorable(appeng.api.storage.IStorageMonitorable)

Example 2 with IStorageMonitorable

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

the class AEInterfaceInventoryHandler method getMultipleItems.

@Override
public ItemStack getMultipleItems(ItemIdentifier item, int count) {
    IStorageMonitorable tmp = tile.getMonitorable(dir, source);
    if (tmp == null || tmp.getItemInventory() == null) {
        return null;
    }
    IAEItemStack stack = AEApi.instance().storage().createItemStack(item.makeNormalStack(count));
    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 3 with IStorageMonitorable

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

the class AEInterfaceInventoryHandler method getItemsAndCount.

private Map<ItemIdentifier, Integer> getItemsAndCount(boolean linked) {
    Map<ItemIdentifier, Integer> result;
    if (linked) {
        result = new LinkedHashMap<>();
    } else {
        result = new HashMap<>();
    }
    IStorageMonitorable tmp = tile.getMonitorable(dir, source);
    if (tmp == null || tmp.getItemInventory() == null || tmp.getItemInventory().getStorageList() == null) {
        return result;
    }
    for (IAEItemStack items : tmp.getItemInventory().getStorageList()) {
        ItemIdentifier ident = ItemIdentifier.get(items.getItemStack());
        Integer count = result.get(ident);
        if (count != null) {
            result.put(ident, (int) (count + items.getStackSize() - (hideOnePerStack ? 1 : 0)));
        } else {
            result.put(ident, (int) (items.getStackSize() - (hideOnePerStack ? 1 : 0)));
        }
    }
    return result;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) IAEItemStack(appeng.api.storage.data.IAEItemStack) IStorageMonitorable(appeng.api.storage.IStorageMonitorable)

Example 4 with IStorageMonitorable

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

the class LPActionSource method add.

@Override
@Nonnull
public ItemStack add(@Nonnull ItemStack stack, EnumFacing from, boolean doAdd) {
    ItemStack st = stack.copy();
    IItemStorageChannel channel = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
    IAEItemStack tst = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(stack);
    IStorageMonitorable tmp = acc.getInventory(source);
    if (tmp == null || tmp.getInventory(channel) == null) {
        return st;
    }
    IAEItemStack overflow = tmp.getInventory(channel).injectItems(tst, Actionable.MODULATE, source);
    if (overflow != null) {
        st.setCount((int) (st.getCount() - overflow.getStackSize()));
    }
    return st;
}
Also used : IAEItemStack(appeng.api.storage.data.IAEItemStack) IItemStorageChannel(appeng.api.storage.channels.IItemStorageChannel) ItemStack(net.minecraft.item.ItemStack) IAEItemStack(appeng.api.storage.data.IAEItemStack) IStorageMonitorable(appeng.api.storage.IStorageMonitorable) Nonnull(javax.annotation.Nonnull)

Example 5 with IStorageMonitorable

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

the class AETankHandler method getAvailableLiquid.

@SuppressWarnings("unused")
@Override
public Map<FluidIdentifier, Long> getAvailableLiquid(TileEntity tile) {
    Map<FluidIdentifier, Long> map = new HashMap<>();
    if (tile instanceof ITileStorageMonitorable) {
        ITileStorageMonitorable mon = (ITileStorageMonitorable) tile;
        if (mon == null) {
            return map;
        }
        for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
            MachineSource source = new MachineSource(new LPActionHost(((IGridHost) tile).getGridNode(dir)));
            IStorageMonitorable monitor = mon.getMonitorable(dir, source);
            if (monitor == null || monitor.getFluidInventory() == null) {
                continue;
            }
            IMEMonitor<IAEFluidStack> fluids = monitor.getFluidInventory();
            for (IAEFluidStack stack : fluids.getStorageList()) {
                if (SimpleServiceLocator.extraCellsProxy.canSeeFluidInNetwork(stack.getFluid())) {
                    map.put(FluidIdentifier.get(stack.getFluid(), stack.getTagCompound() != null ? stack.getTagCompound().getNBTTagCompoundCopy() : null, null), stack.getStackSize());
                }
            }
            return map;
        }
    }
    return map;
}
Also used : HashMap(java.util.HashMap) ITileStorageMonitorable(appeng.api.implementations.tiles.ITileStorageMonitorable) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IGridHost(appeng.api.networking.IGridHost) FluidIdentifier(logisticspipes.utils.FluidIdentifier) IStorageMonitorable(appeng.api.storage.IStorageMonitorable) MachineSource(appeng.api.networking.security.MachineSource) IAEFluidStack(appeng.api.storage.data.IAEFluidStack)

Aggregations

IStorageMonitorable (appeng.api.storage.IStorageMonitorable)15 IAEItemStack (appeng.api.storage.data.IAEItemStack)13 IItemStorageChannel (appeng.api.storage.channels.IItemStorageChannel)7 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)5 Nonnull (javax.annotation.Nonnull)4 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 TreeSet (java.util.TreeSet)2 ItemStack (net.minecraft.item.ItemStack)2 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)2 HashMap (java.util.HashMap)1 FluidIdentifier (logisticspipes.utils.FluidIdentifier)1