Search in sources :

Example 6 with IItemStorageChannel

use of appeng.api.storage.channels.IItemStorageChannel in project LogisticsPipes by RS485.

the class LPActionSource method getItemsAndCount.

private Map<ItemIdentifier, Integer> getItemsAndCount(boolean linked) {
    Map<ItemIdentifier, Integer> result;
    if (linked) {
        result = new LinkedHashMap<>();
    } else {
        result = new HashMap<>();
    }
    IItemStorageChannel channel = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
    IStorageMonitorable tmp = acc.getInventory(source);
    if (tmp == null || tmp.getInventory(channel) == null || tmp.getInventory(channel).getStorageList() == null) {
        return result;
    }
    IItemList<IAEItemStack> items = tmp.getInventory(channel).getStorageList();
    for (IAEItemStack item : items) {
        ItemIdentifier ident = ItemIdentifier.get(item.createItemStack());
        Integer count = result.get(ident);
        if (count != null) {
            result.put(ident, (int) (count + item.getStackSize() - (hideOne ? 1 : 0)));
        } else {
            result.put(ident, (int) (item.getStackSize() - (hideOne ? 1 : 0)));
        }
    }
    return result;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) IAEItemStack(appeng.api.storage.data.IAEItemStack) IItemStorageChannel(appeng.api.storage.channels.IItemStorageChannel) IStorageMonitorable(appeng.api.storage.IStorageMonitorable)

Example 7 with IItemStorageChannel

use of appeng.api.storage.channels.IItemStorageChannel in project LogisticsPipes by RS485.

the class LPActionSource method getItems.

@Override
@Nonnull
public Set<ItemIdentifier> getItems() {
    IItemStorageChannel channel = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
    Set<ItemIdentifier> result = new TreeSet<>();
    IStorageMonitorable tmp = acc.getInventory(source);
    if (tmp == null || tmp.getInventory(channel) == null || tmp.getInventory(channel).getStorageList() == null) {
        return result;
    }
    IItemList<IAEItemStack> items = tmp.getInventory(channel).getStorageList();
    for (IAEItemStack item : items) {
        ItemIdentifier ident = ItemIdentifier.get(item.createItemStack());
        result.add(ident);
    }
    return result;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) TreeSet(java.util.TreeSet) IAEItemStack(appeng.api.storage.data.IAEItemStack) IItemStorageChannel(appeng.api.storage.channels.IItemStorageChannel) IStorageMonitorable(appeng.api.storage.IStorageMonitorable) Nonnull(javax.annotation.Nonnull)

Aggregations

IStorageMonitorable (appeng.api.storage.IStorageMonitorable)7 IItemStorageChannel (appeng.api.storage.channels.IItemStorageChannel)7 IAEItemStack (appeng.api.storage.data.IAEItemStack)7 Nonnull (javax.annotation.Nonnull)4 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)3 TreeSet (java.util.TreeSet)1 ItemStack (net.minecraft.item.ItemStack)1