Search in sources :

Example 26 with IPipeServiceProvider

use of logisticspipes.interfaces.IPipeServiceProvider in project LogisticsPipes by RS485.

the class ModuleItemSink method sinksItem.

@Override
public SinkReply sinksItem(@Nonnull ItemStack stack, ItemIdentifier item, int bestPriority, int bestCustomPriority, boolean allowDefault, boolean includeInTransit, boolean forcePassive) {
    if (defaultRoute.getValue() && !allowDefault) {
        return null;
    }
    if (bestPriority > _sinkReply.fixedPriority.ordinal() || (bestPriority == _sinkReply.fixedPriority.ordinal() && bestCustomPriority >= _sinkReply.customPriority)) {
        return null;
    }
    final IPipeServiceProvider service = _service;
    if (service == null)
        return null;
    if (filterInventory.containsUndamagedItem(item.getUndamaged())) {
        if (service.canUseEnergy(1)) {
            return _sinkReply;
        }
        return null;
    }
    final ISlotUpgradeManager upgradeManager = getUpgradeManager();
    if (upgradeManager.isFuzzyUpgrade()) {
        for (Pair<ItemIdentifierStack, Integer> filter : filterInventory.contents()) {
            if (filter == null) {
                continue;
            }
            if (filter.getValue1() == null) {
                continue;
            }
            ItemIdentifier ident1 = item;
            ItemIdentifier ident2 = filter.getValue1().getItem();
            if (ignoreData.get(filter.getValue2())) {
                ident1 = ident1.getIgnoringData();
                ident2 = ident2.getIgnoringData();
            }
            if (ignoreNBT.get(filter.getValue2())) {
                ident1 = ident1.getIgnoringNBT();
                ident2 = ident2.getIgnoringNBT();
            }
            if (ident1.equals(ident2)) {
                if (service.canUseEnergy(5)) {
                    return _sinkReply;
                }
                return null;
            }
        }
    }
    if (defaultRoute.getValue()) {
        if (bestPriority > _sinkReplyDefault.fixedPriority.ordinal() || (bestPriority == _sinkReplyDefault.fixedPriority.ordinal() && bestCustomPriority >= _sinkReplyDefault.customPriority)) {
            return null;
        }
        if (service.canUseEnergy(1)) {
            return _sinkReplyDefault;
        }
        return null;
    }
    return null;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) IPipeServiceProvider(logisticspipes.interfaces.IPipeServiceProvider) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ISlotUpgradeManager(logisticspipes.interfaces.ISlotUpgradeManager)

Example 27 with IPipeServiceProvider

use of logisticspipes.interfaces.IPipeServiceProvider in project LogisticsPipes by RS485.

the class LogisticsModule method registerHandler.

/**
 * Registers the Inventory and ItemSender to the module
 *
 * @param world   that the module is in.
 * @param service Inventory access, power and utility functions provided by the pipe.
 */
public void registerHandler(IWorldProvider world, IPipeServiceProvider service) {
    _world = world;
    _service = service;
    if (service != null) {
        final IBlockAccess blockAccess = world == null ? null : world.getWorld();
        MainProxy.runOnServer(blockAccess, () -> () -> UtilKt.addObserver(getProperties(), (prop) -> {
            _service.markTileDirty();
            return Unit.INSTANCE;
        }));
    }
}
Also used : Getter(lombok.Getter) LogisticsPipes(logisticspipes.LogisticsPipes) CCType(logisticspipes.proxy.computers.interfaces.CCType) IPipeServiceProvider(logisticspipes.interfaces.IPipeServiceProvider) MainProxy(logisticspipes.proxy.MainProxy) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) SinkReply(logisticspipes.utils.SinkReply) IWorldProvider(logisticspipes.interfaces.IWorldProvider) CCSinkResponder(logisticspipes.proxy.computers.objects.CCSinkResponder) ISlotUpgradeManager(logisticspipes.interfaces.ISlotUpgradeManager) ILPCCTypeHolder(logisticspipes.proxy.computers.interfaces.ILPCCTypeHolder) CCCommand(logisticspipes.proxy.computers.interfaces.CCCommand) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) IBlockAccess(net.minecraft.world.IBlockAccess) IQueueCCEvent(logisticspipes.interfaces.IQueueCCEvent) PropertyHolder(network.rs485.logisticspipes.property.PropertyHolder) World(net.minecraft.world.World) Collection(java.util.Collection) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) BlockPos(net.minecraft.util.math.BlockPos) Objects(java.util.Objects) List(java.util.List) Unit(kotlin.Unit) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ISaveState(logisticspipes.interfaces.routing.ISaveState) Gui(network.rs485.logisticspipes.module.Gui) Property(network.rs485.logisticspipes.property.Property) Collections(java.util.Collections) UtilKt(network.rs485.logisticspipes.property.UtilKt) IBlockAccess(net.minecraft.world.IBlockAccess)

Aggregations

IPipeServiceProvider (logisticspipes.interfaces.IPipeServiceProvider)27 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)14 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)14 ItemStack (net.minecraft.item.ItemStack)13 Nonnull (javax.annotation.Nonnull)11 SinkReply (logisticspipes.utils.SinkReply)10 IAdditionalTargetInformation (logisticspipes.interfaces.routing.IAdditionalTargetInformation)9 DictResource (logisticspipes.request.resources.DictResource)9 List (java.util.List)8 Objects (java.util.Objects)8 IInventoryUtil (logisticspipes.interfaces.IInventoryUtil)8 ISlotUpgradeManager (logisticspipes.interfaces.ISlotUpgradeManager)8 LogisticsItemOrder (logisticspipes.routing.order.LogisticsItemOrder)8 Pair (logisticspipes.utils.tuples.Pair)8 ArrayList (java.util.ArrayList)7 Collection (java.util.Collection)7 ItemResource (logisticspipes.request.resources.ItemResource)7 Property (network.rs485.logisticspipes.property.Property)7 ImmutableList (com.google.common.collect.ImmutableList)6 Map (java.util.Map)6