Search in sources :

Example 11 with IStorageMonitorable

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

the class LPActionSource method getMultipleItems.

@Override
@Nonnull
public ItemStack getMultipleItems(@Nonnull ItemIdentifier itemIdent, int count) {
    if (itemCount(itemIdent) < count) {
        return ItemStack.EMPTY;
    }
    IItemStorageChannel channel = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
    IStorageMonitorable tmp = acc.getInventory(source);
    if (tmp == null || tmp.getInventory(channel) == null) {
        return ItemStack.EMPTY;
    }
    IAEItemStack stack = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(itemIdent.makeNormalStack(count));
    IAEItemStack extract = tmp.getInventory(channel).extractItems(stack, Actionable.MODULATE, source);
    if (extract == null) {
        return ItemStack.EMPTY;
    }
    return extract.createItemStack();
}
Also used : IAEItemStack(appeng.api.storage.data.IAEItemStack) IItemStorageChannel(appeng.api.storage.channels.IItemStorageChannel) IStorageMonitorable(appeng.api.storage.IStorageMonitorable) Nonnull(javax.annotation.Nonnull)

Example 12 with IStorageMonitorable

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

the class LPActionSource method getSingleItem.

@Override
@Nonnull
public ItemStack getSingleItem(ItemIdentifier item) {
    IItemStorageChannel channel = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class);
    IStorageMonitorable tmp = acc.getInventory(source);
    if (tmp == null || tmp.getInventory(channel) == null) {
        return ItemStack.EMPTY;
    }
    IAEItemStack stack = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createStack(item.makeNormalStack(1));
    IAEItemStack extract = tmp.getInventory(channel).extractItems(stack, Actionable.MODULATE, source);
    if (extract == null) {
        return ItemStack.EMPTY;
    }
    return extract.createItemStack();
}
Also used : IAEItemStack(appeng.api.storage.data.IAEItemStack) IItemStorageChannel(appeng.api.storage.channels.IItemStorageChannel) IStorageMonitorable(appeng.api.storage.IStorageMonitorable) Nonnull(javax.annotation.Nonnull)

Example 13 with IStorageMonitorable

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

the class LPActionSource method containsUndamagedItem.

@Override
public boolean containsUndamagedItem(@Nonnull ItemIdentifier itemIdent) {
    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 false;
    }
    IItemList<IAEItemStack> items = tmp.getInventory(channel).getStorageList();
    for (IAEItemStack item : items) {
        ItemIdentifier ident = ItemIdentifier.get(item.createItemStack());
        if (ident.equals(itemIdent)) {
            return true;
        }
    }
    return false;
}
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 14 with IStorageMonitorable

use of appeng.api.storage.IStorageMonitorable 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 15 with IStorageMonitorable

use of appeng.api.storage.IStorageMonitorable 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)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