Search in sources :

Example 6 with LogisticsItemOrder

use of logisticspipes.routing.order.LogisticsItemOrder 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

LogisticsItemOrder (logisticspipes.routing.order.LogisticsItemOrder)6 DictResource (logisticspipes.request.resources.DictResource)2 SinkReply (logisticspipes.utils.SinkReply)2 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)2 LogisticsCraftingTableTileEntity (logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity)1 IFilter (logisticspipes.interfaces.routing.IFilter)1 IItemSpaceControl (logisticspipes.interfaces.routing.IItemSpaceControl)1 IRoutedItem (logisticspipes.logisticspipes.IRoutedItem)1 IResource (logisticspipes.request.resources.IResource)1 LogisticsExtraDictPromise (logisticspipes.routing.LogisticsExtraDictPromise)1 LogisticsExtraPromise (logisticspipes.routing.LogisticsExtraPromise)1 LogisticsPromise (logisticspipes.routing.LogisticsPromise)1 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 AdjacentTileEntity (network.rs485.logisticspipes.world.WorldCoordinatesWrapper.AdjacentTileEntity)1