Search in sources :

Example 1 with LogisticsExtraDictPromise

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());
}
Also used : IFilter(logisticspipes.interfaces.routing.IFilter) DictResource(logisticspipes.request.resources.DictResource) LogisticsItemOrder(logisticspipes.routing.order.LogisticsItemOrder) LogisticsExtraDictPromise(logisticspipes.routing.LogisticsExtraDictPromise) IResource(logisticspipes.request.resources.IResource) LogisticsExtraPromise(logisticspipes.routing.LogisticsExtraPromise)

Aggregations

IFilter (logisticspipes.interfaces.routing.IFilter)1 DictResource (logisticspipes.request.resources.DictResource)1 IResource (logisticspipes.request.resources.IResource)1 LogisticsExtraDictPromise (logisticspipes.routing.LogisticsExtraDictPromise)1 LogisticsExtraPromise (logisticspipes.routing.LogisticsExtraPromise)1 LogisticsItemOrder (logisticspipes.routing.order.LogisticsItemOrder)1