use of logisticspipes.request.resources.IResource in project LogisticsPipes by RS485.
the class ModuleCrafter method canProvide.
@Override
public void canProvide(RequestTreeNode tree, RequestTree root, List<IFilter> filters) {
final IPipeServiceProvider service = _service;
if (service == null)
return;
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.getAsItem())) {
remaining += extra.getResource().stack.getStackSize();
}
}
}
final ItemIdentifierStack craftedItem = getCraftedItem();
if (craftedItem == null)
return;
remaining -= root.getAllPromissesFor(this, craftedItem.getItem());
if (remaining < 1) {
return;
}
if (getUpgradeManager().isFuzzyUpgrade() && outputFuzzy().nextSetBit(0) != -1) {
DictResource dict = new DictResource(craftedItem, null).loadFromBitSet(outputFuzzy().copyValue());
LogisticsExtraDictPromise promise = new LogisticsExtraDictPromise(dict, Math.min(remaining, tree.getMissingAmount()), this, true);
tree.addPromise(promise);
} else {
LogisticsExtraPromise promise = new LogisticsExtraPromise(craftedItem.getItem(), Math.min(remaining, tree.getMissingAmount()), this, true);
tree.addPromise(promise);
}
tree.setQueried(service.getItemOrderManager());
}
Aggregations