Search in sources :

Example 21 with IFilter

use of logisticspipes.interfaces.routing.IFilter in project LogisticsPipes by RS485.

the class ModuleProvider method getAllItems.

@Override
public void getAllItems(Map<ItemIdentifier, Integer> items, List<IFilter> filters) {
    IInventoryUtil inv = _service.getPointedInventory(_extractionMode, true);
    if (inv == null) {
        return;
    }
    Map<ItemIdentifier, Integer> currentInv = inv.getItemsAndCount();
    //Skip already added items from this provider, skip filtered items, Reduce what has been reserved, add.
    outer: for (Entry<ItemIdentifier, Integer> currItem : currentInv.entrySet()) {
        if (items.containsKey(currItem.getKey())) {
            // Already provided by the previous module
            continue;
        }
        if (!filterAllowsItem(currItem.getKey())) {
            continue;
        }
        for (IFilter filter : filters) {
            if (filter.isBlocked() == filter.isFilteredItem(currItem.getKey().getUndamaged()) || filter.blockProvider()) {
                continue outer;
            }
        }
        int remaining = currItem.getValue() - _service.getItemOrderManager().totalItemsCountInOrders(currItem.getKey());
        if (remaining < 1) {
            continue;
        }
        items.put(currItem.getKey(), remaining);
    }
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) Entry(java.util.Map.Entry) IFilter(logisticspipes.interfaces.routing.IFilter) IInventoryUtil(logisticspipes.interfaces.IInventoryUtil)

Aggregations

IFilter (logisticspipes.interfaces.routing.IFilter)21 ArrayList (java.util.ArrayList)13 ExitRoute (logisticspipes.routing.ExitRoute)12 LinkedList (java.util.LinkedList)9 IRouter (logisticspipes.routing.IRouter)9 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)9 List (java.util.List)8 BitSet (java.util.BitSet)7 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Entry (java.util.Map.Entry)6 Pair (logisticspipes.utils.tuples.Pair)6 DictResource (logisticspipes.request.resources.DictResource)5 IResource (logisticspipes.request.resources.IResource)5 Iterator (java.util.Iterator)4 Collectors (java.util.stream.Collectors)4 IProvideItems (logisticspipes.interfaces.routing.IProvideItems)4 LogisticsModule (logisticspipes.modules.abstractmodules.LogisticsModule)4 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)4