Search in sources :

Example 6 with DictResource

use of logisticspipes.request.resources.DictResource in project LogisticsPipes by RS485.

the class ServerRouter method getRoutersInterestedIn.

public static BitSet getRoutersInterestedIn(IResource item) {
    if (item instanceof ItemResource) {
        return ServerRouter.getRoutersInterestedIn(((ItemResource) item).getItem());
    } else if (item instanceof FluidResource) {
        return ServerRouter.getRoutersInterestedIn(((FluidResource) item).getFluid().getItemIdentifier());
    } else if (item instanceof DictResource) {
        DictResource dict = (DictResource) item;
        BitSet s = new BitSet(ServerRouter.getBiggestSimpleID() + 1);
        if (ServerRouter._genericInterests != null) {
            for (IRouter r : ServerRouter._genericInterests) {
                s.set(r.getSimpleID());
            }
        }
        ServerRouter._globalSpecificInterests.entrySet().stream().filter(entry -> dict.matches(entry.getKey(), IResource.MatchSettings.NORMAL)).forEach(entry -> {
            for (IRouter r : entry.getValue()) {
                s.set(r.getSimpleID());
            }
        });
        return s;
    }
    return new BitSet(ServerRouter.getBiggestSimpleID() + 1);
}
Also used : LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule) PriorityQueue(java.util.PriorityQueue) Quartet(logisticspipes.utils.tuples.Quartet) Particles(logisticspipes.pipefxhandlers.Particles) MainProxy(logisticspipes.proxy.MainProxy) ILogisticsPowerProvider(logisticspipes.api.ILogisticsPowerProvider) Configs(logisticspipes.config.Configs) StackTraceUtil(logisticspipes.utils.StackTraceUtil) Map(java.util.Map) ILPTEInformation(logisticspipes.asm.te.ILPTEInformation) EnumSet(java.util.EnumSet) ITileEntityChangeListener(logisticspipes.asm.te.ITileEntityChangeListener) EnumMap(java.util.EnumMap) FluidResource(logisticspipes.request.resources.FluidResource) CacheHolder(logisticspipes.utils.CacheHolder) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) Set(java.util.Set) LPTickHandler(logisticspipes.ticks.LPTickHandler) UUID(java.util.UUID) DictResource(logisticspipes.request.resources.DictResource) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Collectors(java.util.stream.Collectors) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) Info(logisticspipes.utils.StackTraceUtil.Info) List(java.util.List) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) IFilter(logisticspipes.interfaces.routing.IFilter) Pair(logisticspipes.utils.tuples.Pair) Entry(java.util.Map.Entry) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) ItemResource(logisticspipes.request.resources.ItemResource) Setter(lombok.Setter) Getter(lombok.Getter) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) HashMap(java.util.HashMap) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ISubSystemPowerProvider(logisticspipes.interfaces.ISubSystemPowerProvider) AccessLevel(lombok.AccessLevel) IRoutingDebugAdapter(logisticspipes.interfaces.IRoutingDebugAdapter) LPTileEntityObject(logisticspipes.asm.te.LPTileEntityObject) PathFinder(logisticspipes.routing.pathfinder.PathFinder) OneList(logisticspipes.utils.OneList) WeakReference(java.lang.ref.WeakReference) LinkedList(java.util.LinkedList) LPConstants(logisticspipes.LPConstants) DimensionManager(net.minecraftforge.common.DimensionManager) RoutingTableUpdateThread(logisticspipes.ticks.RoutingTableUpdateThread) Iterator(java.util.Iterator) World(net.minecraft.world.World) IResource(logisticspipes.request.resources.IResource) Lock(java.util.concurrent.locks.Lock) PipeItemsFirewall(logisticspipes.pipes.PipeItemsFirewall) TileEntity(net.minecraft.tileentity.TileEntity) BitSet(java.util.BitSet) Collections(java.util.Collections) FluidResource(logisticspipes.request.resources.FluidResource) DictResource(logisticspipes.request.resources.DictResource) BitSet(java.util.BitSet) ItemResource(logisticspipes.request.resources.ItemResource)

Example 7 with DictResource

use of logisticspipes.request.resources.DictResource in project LogisticsPipes by RS485.

the class ModuleCrafter method registerExtras.

@Override
public void registerExtras(IPromise promise) {
    if (promise instanceof LogisticsDictPromise) {
        _service.getItemOrderManager().addExtra(((LogisticsDictPromise) promise).getResource());
        return;
    } else {
        ItemIdentifierStack stack = new ItemIdentifierStack(promise.getItemType(), promise.getAmount());
        _service.getItemOrderManager().addExtra(new DictResource(stack, null));
    }
}
Also used : LogisticsDictPromise(logisticspipes.routing.LogisticsDictPromise) DictResource(logisticspipes.request.resources.DictResource) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Example 8 with DictResource

use of logisticspipes.request.resources.DictResource in project LogisticsPipes by RS485.

the class ModuleCrafter method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
    //		super.readFromNBT(nbttagcompound);
    _dummyInventory.readFromNBT(nbttagcompound, "");
    _liquidInventory.readFromNBT(nbttagcompound, "FluidInv");
    _cleanupInventory.readFromNBT(nbttagcompound, "CleanupInv");
    satelliteId = nbttagcompound.getInteger("satelliteid");
    priority = nbttagcompound.getInteger("priority");
    for (int i = 0; i < 9; i++) {
        advancedSatelliteIdArray[i] = nbttagcompound.getInteger("advancedSatelliteId" + i);
    }
    if (nbttagcompound.hasKey("fuzzyCraftingFlag0")) {
        for (int i = 0; i < 9; i++) {
            int flags = nbttagcompound.getByte("fuzzyCraftingFlag" + i);
            DictResource dict = fuzzyCraftingFlagArray[i];
            if ((flags & 0x1) != 0) {
                dict.use_od = true;
            }
            if ((flags & 0x2) != 0) {
                dict.ignore_dmg = true;
            }
            if ((flags & 0x4) != 0) {
                dict.ignore_nbt = true;
            }
            if ((flags & 0x8) != 0) {
                dict.use_category = true;
            }
        }
    }
    if (nbttagcompound.hasKey("fuzzyFlags")) {
        NBTTagList lst = nbttagcompound.getTagList("fuzzyFlags", Constants.NBT.TAG_COMPOUND);
        for (int i = 0; i < 9; i++) {
            NBTTagCompound comp = lst.getCompoundTagAt(i);
            fuzzyCraftingFlagArray[i].ignore_dmg = comp.getBoolean("ignore_dmg");
            fuzzyCraftingFlagArray[i].ignore_nbt = comp.getBoolean("ignore_nbt");
            fuzzyCraftingFlagArray[i].use_od = comp.getBoolean("use_od");
            fuzzyCraftingFlagArray[i].use_category = comp.getBoolean("use_category");
        }
    }
    if (nbttagcompound.hasKey("outputFuzzyFlags")) {
        NBTTagCompound comp = nbttagcompound.getCompoundTag("outputFuzzyFlags");
        outputFuzzyFlags.ignore_dmg = comp.getBoolean("ignore_dmg");
        outputFuzzyFlags.ignore_nbt = comp.getBoolean("ignore_nbt");
        outputFuzzyFlags.use_od = comp.getBoolean("use_od");
        outputFuzzyFlags.use_category = comp.getBoolean("use_category");
    }
    for (int i = 0; i < 6; i++) {
        craftingSigns[i] = nbttagcompound.getBoolean("craftingSigns" + i);
    }
    if (nbttagcompound.hasKey("FluidAmount")) {
        amount = nbttagcompound.getIntArray("FluidAmount");
    }
    if (amount.length < ItemUpgrade.MAX_LIQUID_CRAFTER) {
        amount = new int[ItemUpgrade.MAX_LIQUID_CRAFTER];
    }
    for (int i = 0; i < ItemUpgrade.MAX_LIQUID_CRAFTER; i++) {
        liquidSatelliteIdArray[i] = nbttagcompound.getInteger("liquidSatelliteIdArray" + i);
    }
    for (int i = 0; i < ItemUpgrade.MAX_LIQUID_CRAFTER; i++) {
        liquidSatelliteIdArray[i] = nbttagcompound.getInteger("liquidSatelliteIdArray" + i);
    }
    liquidSatelliteId = nbttagcompound.getInteger("liquidSatelliteId");
    cleanupModeIsExclude = nbttagcompound.getBoolean("cleanupModeIsExclude");
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) DictResource(logisticspipes.request.resources.DictResource) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Example 9 with DictResource

use of logisticspipes.request.resources.DictResource 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)

Example 10 with DictResource

use of logisticspipes.request.resources.DictResource in project LogisticsPipes by RS485.

the class PipeItemsProviderLogistics method canProvide.

@Override
public void canProvide(RequestTreeNode tree, RequestTree root, List<IFilter> filters) {
    if (!isEnabled()) {
        return;
    }
    if (tree.getRequestType() instanceof ItemResource) {
        ItemIdentifier item = ((ItemResource) tree.getRequestType()).getItem();
        for (IFilter filter : filters) {
            if (filter.isBlocked() == filter.isFilteredItem(item.getUndamaged()) || filter.blockProvider()) {
                return;
            }
        }
        // Check the transaction and see if we have helped already
        int canProvide = getAvailableItemCount(item);
        canProvide -= root.getAllPromissesFor(this, item);
        if (canProvide < 1) {
            return;
        }
        LogisticsPromise promise = new LogisticsPromise(item, Math.min(canProvide, tree.getMissingAmount()), this, ResourceType.PROVIDER);
        tree.addPromise(promise);
    } else if (tree.getRequestType() instanceof DictResource) {
        DictResource dict = (DictResource) tree.getRequestType();
        HashMap<ItemIdentifier, Integer> available = new HashMap<>();
        getAllItems(available, filters);
        for (Entry<ItemIdentifier, Integer> item : available.entrySet()) {
            if (!dict.matches(item.getKey(), IResource.MatchSettings.NORMAL)) {
                continue;
            }
            int canProvide = getAvailableItemCount(item.getKey());
            canProvide -= root.getAllPromissesFor(this, item.getKey());
            if (canProvide < 1) {
                continue;
            }
            LogisticsPromise promise = new LogisticsPromise(item.getKey(), Math.min(canProvide, tree.getMissingAmount()), this, ResourceType.PROVIDER);
            tree.addPromise(promise);
            if (tree.getMissingAmount() <= 0) {
                break;
            }
        }
    }
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) Entry(java.util.Map.Entry) IFilter(logisticspipes.interfaces.routing.IFilter) HashMap(java.util.HashMap) LogisticsPromise(logisticspipes.routing.LogisticsPromise) DictResource(logisticspipes.request.resources.DictResource) ItemResource(logisticspipes.request.resources.ItemResource)

Aggregations

DictResource (logisticspipes.request.resources.DictResource)14 ItemResource (logisticspipes.request.resources.ItemResource)7 IResource (logisticspipes.request.resources.IResource)6 ArrayList (java.util.ArrayList)4 IFilter (logisticspipes.interfaces.routing.IFilter)4 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)4 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)4 Entry (java.util.Map.Entry)3 LogisticsPromise (logisticspipes.routing.LogisticsPromise)3 LogisticsItemOrder (logisticspipes.routing.order.LogisticsItemOrder)3 ItemStack (net.minecraft.item.ItemStack)3 BitSet (java.util.BitSet)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 IInventoryUtil (logisticspipes.interfaces.IInventoryUtil)2 IRequestItems (logisticspipes.interfaces.routing.IRequestItems)2 LogisticsModule (logisticspipes.modules.abstractmodules.LogisticsModule)2 Particles (logisticspipes.pipefxhandlers.Particles)2