Skip to content

Commit

Permalink
fix: importer using simulated extractions to insert
Browse files Browse the repository at this point in the history
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 1522971)
  • Loading branch information
raoulvdberge committed Nov 12, 2023
1 parent 543b28e commit 16d7f22
Showing 1 changed file with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
Expand Down

0 comments on commit 16d7f22

Please sign in to comment.