From 16d7f22c0aeda92301a517fe622e10598b3c0282 Mon Sep 17 00:00:00 2001 From: raoulvdberge Date: Sun, 5 Nov 2023 17:17:18 +0100 Subject: [PATCH] fix: importer using simulated extractions to insert The behavior is now consistent with items. This caused issues with Gregtech, they returned fluids that weren't extractable in simulation mode so RS ended up duping them. Now we only insert fluids that return from execution mode. Fixes #3570 (cherry picked from commit 1522971a939f6bbe6f7ab4d143c1263405e44928) --- .../network/node/ImporterNetworkNode.java | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/refinedmods/refinedstorage/apiimpl/network/node/ImporterNetworkNode.java b/src/main/java/com/refinedmods/refinedstorage/apiimpl/network/node/ImporterNetworkNode.java index 85158a2187..694022036c 100644 --- a/src/main/java/com/refinedmods/refinedstorage/apiimpl/network/node/ImporterNetworkNode.java +++ b/src/main/java/com/refinedmods/refinedstorage/apiimpl/network/node/ImporterNetworkNode.java @@ -103,20 +103,15 @@ public void update() { IFluidHandler handler = LevelUtils.getFluidHandler(getFacingBlockEntity(), getDirection().getOpposite()); if (handler != null) { - FluidStack stack = handler.drain(FluidType.BUCKET_VOLUME, IFluidHandler.FluidAction.SIMULATE); + FluidStack extractedSimulated = handler.drain(FluidType.BUCKET_VOLUME * upgrades.getStackInteractCount(), IFluidHandler.FluidAction.SIMULATE); - if (!stack.isEmpty() && - IWhitelistBlacklist.acceptsFluid(fluidFilters, mode, compare, stack) && - network.insertFluid(stack, stack.getAmount(), Action.SIMULATE).isEmpty()) { - FluidStack toDrain = handler.drain(FluidType.BUCKET_VOLUME * upgrades.getStackInteractCount(), IFluidHandler.FluidAction.SIMULATE); + if (!extractedSimulated.isEmpty() + && IWhitelistBlacklist.acceptsFluid(fluidFilters, mode, compare, extractedSimulated) + && network.insertFluid(extractedSimulated, extractedSimulated.getAmount(), Action.SIMULATE).isEmpty()) { + FluidStack extracted = handler.drain(extractedSimulated, IFluidHandler.FluidAction.EXECUTE); - if (!toDrain.isEmpty()) { - FluidStack remainder = network.insertFluidTracked(toDrain, toDrain.getAmount()); - if (!remainder.isEmpty()) { - toDrain.shrink(remainder.getAmount()); - } - - handler.drain(toDrain, IFluidHandler.FluidAction.EXECUTE); + if (!extracted.isEmpty()) { + network.insertFluidTracked(extracted, extracted.getAmount()); } } }