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;
}
Aggregations