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;
}
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;
}));
}
}
Aggregations