Search in sources :

Example 1 with ICraftItems

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

the class LogisticsManager method getCraftableItems.

/**
 * @param validDestinations
 *            a List of ExitRoute of valid destinations.
 * @return LinkedList with ItemIdentifier
 */
@Override
public LinkedList<ItemIdentifier> getCraftableItems(List<ExitRoute> validDestinations) {
    LinkedList<ItemIdentifier> craftableItems = new LinkedList<>();
    BitSet used = new BitSet(ServerRouter.getBiggestSimpleID());
    outer: for (ExitRoute r : validDestinations) {
        if (r == null) {
            continue;
        }
        if (!r.containsFlag(PipeRoutingConnectionType.canRequestFrom)) {
            continue;
        }
        if (used.get(r.destination.getSimpleID())) {
            continue;
        }
        if (!(r.destination.getPipe() instanceof ICraftItems)) {
            continue;
        }
        for (IFilter filter : r.filters) {
            if (filter.blockCrafting()) {
                continue outer;
            }
        }
        ICraftItems crafter = (ICraftItems) r.destination.getPipe();
        List<ItemIdentifierStack> craftedItems = crafter.getCraftedItems();
        if (craftedItems != null) {
            outer2: for (ItemIdentifierStack craftedItem : craftedItems) {
                if (craftedItem != null && !craftableItems.contains(craftedItem.getItem())) {
                    for (IFilter filter : r.filters) {
                        if (filter.isBlocked() == filter.isFilteredItem(craftedItem.getItem())) {
                            continue outer2;
                        }
                    }
                    craftableItems.add(craftedItem.getItem());
                }
            }
        }
        used.set(r.destination.getSimpleID(), true);
    }
    return craftableItems;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) IFilter(logisticspipes.interfaces.routing.IFilter) BitSet(java.util.BitSet) ICraftItems(logisticspipes.interfaces.routing.ICraftItems) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) ExitRoute(logisticspipes.routing.ExitRoute) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) LinkedList(java.util.LinkedList)

Aggregations

ArrayList (java.util.ArrayList)1 BitSet (java.util.BitSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 ICraftItems (logisticspipes.interfaces.routing.ICraftItems)1 IFilter (logisticspipes.interfaces.routing.IFilter)1 ExitRoute (logisticspipes.routing.ExitRoute)1 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)1 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)1