Search in sources :

Example 1 with IAEItemStack

use of appeng.api.storage.data.IAEItemStack 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 IAEItemStack

use of appeng.api.storage.data.IAEItemStack 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 IAEItemStack

use of appeng.api.storage.data.IAEItemStack 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 IAEItemStack

use of appeng.api.storage.data.IAEItemStack in project PneumaticCraft by MineMaarten.

the class AE2DiskInventoryItemHandler method getStacksInItem.

@Override
public void getStacksInItem(ItemStack stack, List<ItemStack> curStacks) {
    IMEInventoryHandler<IAEItemStack> cellInventoryHandler = cellRegistry.getCellInventory(stack, null, StorageChannel.ITEMS);
    if (cellInventoryHandler != null) {
        IItemList<IAEItemStack> cellItemList = storageHelper.createItemList();
        cellInventoryHandler.getAvailableItems(cellItemList);
        for (IAEItemStack aeStack : cellItemList) {
            ItemStack st = aeStack.getItemStack();
            //Do another getStacksize, as above retrieval caps to 64.
            st.stackSize = (int) aeStack.getStackSize();
            curStacks.add(st);
        }
    }
}
Also used : IAEItemStack(appeng.api.storage.data.IAEItemStack) ItemStack(net.minecraft.item.ItemStack) IAEItemStack(appeng.api.storage.data.IAEItemStack)

Example 5 with IAEItemStack

use of appeng.api.storage.data.IAEItemStack in project PneumaticCraft by MineMaarten.

the class SemiBlockRequester method onRequestChange.

//ICraftingWatcherHost
@Override
@Optional.Method(modid = ModIds.AE2)
public void onRequestChange(ICraftingGrid grid, IAEItemStack aeStack) {
    craftingGrid = grid;
    ItemStack stack = aeStack.getItemStack().copy();
    int freeSlot = -1;
    for (int i = 0; i < getFilters().getSizeInventory(); i++) {
        ItemStack s = getFilters().getStackInSlot(i);
        if (s != null) {
            if (stack.isItemEqual(s)) {
                s.stackSize = stack.stackSize;
                if (s.stackSize == 0)
                    getFilters().setInventorySlotContents(i, null);
                return;
            }
        } else if (freeSlot == -1) {
            freeSlot = i;
        }
    }
    if (freeSlot >= 0) {
        getFilters().setInventorySlotContents(freeSlot, stack.copy());
    }
}
Also used : IAEItemStack(appeng.api.storage.data.IAEItemStack) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IAEItemStack (appeng.api.storage.data.IAEItemStack)10 IStorageMonitorable (appeng.api.storage.IStorageMonitorable)6 ItemStack (net.minecraft.item.ItemStack)3 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)2 ICraftingWatcher (appeng.api.networking.crafting.ICraftingWatcher)1 IStackWatcher (appeng.api.networking.storage.IStackWatcher)1 TreeSet (java.util.TreeSet)1