use of logisticspipes.routing.LogisticsExtraDictPromise in project LogisticsPipes by RS485.
the class ModuleCrafter method canProvide.
@Override
public void canProvide(RequestTreeNode tree, RequestTree root, List<IFilter> filters) {
if (!_service.getItemOrderManager().hasExtras() || tree.hasBeenQueried(_service.getItemOrderManager())) {
return;
}
IResource requestedItem = tree.getRequestType();
if (!canCraft(requestedItem)) {
return;
}
for (IFilter filter : filters) {
if (filter.isBlocked() == filter.isFilteredItem(requestedItem) || filter.blockProvider()) {
return;
}
}
int remaining = 0;
for (LogisticsItemOrder extra : _service.getItemOrderManager()) {
if (extra.getType() == ResourceType.EXTRA) {
if (extra.getResource().getItem().equals(requestedItem)) {
remaining += extra.getResource().stack.getStackSize();
}
}
}
remaining -= root.getAllPromissesFor(this, getCraftedItem().getItem());
if (remaining < 1) {
return;
}
if (this.getUpgradeManager().isFuzzyUpgrade() && outputFuzzyFlags.getBitSet().nextSetBit(0) != -1) {
DictResource dict = new DictResource(getCraftedItem(), null).loadFromBitSet(outputFuzzyFlags.getBitSet());
LogisticsExtraDictPromise promise = new LogisticsExtraDictPromise(dict, Math.min(remaining, tree.getMissingAmount()), this, true);
tree.addPromise(promise);
} else {
LogisticsExtraPromise promise = new LogisticsExtraPromise(getCraftedItem().getItem(), Math.min(remaining, tree.getMissingAmount()), this, true);
tree.addPromise(promise);
}
tree.setQueried(_service.getItemOrderManager());
}
Aggregations