From b0583a32cbd5207f953ee596649c4eac6574798f Mon Sep 17 00:00:00 2001 From: Guillaume Mercier <10gui-gui10@live.ca> Date: Sat, 22 Mar 2025 23:12:20 -0400 Subject: [PATCH] Make the fluid monitor more resilient. - Add checks via the can drain and can fill methods of fluid tanks to prevent dupe bugs like the one encountered with the blockhead sink the blockhead sink doesn't check the fluid passed to it during the drain or fill calls so it ended up draining itself instead of the required fluid when ever it was working Adding some some sort of logging if the fluid extracted and the fluid requested aren't the same would be a good idea, and since there is no caching from the simulate phase, it's going to have to be done in both phases. It shouldn't just void the output though since the changes will have already been applied to the tank by the time we void out the values and we can't assume the fill function would work properly if the drain doesn't. --- .../glodblock/github/inventory/MEMonitorIFluidHandler.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/com/glodblock/github/inventory/MEMonitorIFluidHandler.java b/src/main/java/com/glodblock/github/inventory/MEMonitorIFluidHandler.java index 54a8305f..f5d8fea6 100644 --- a/src/main/java/com/glodblock/github/inventory/MEMonitorIFluidHandler.java +++ b/src/main/java/com/glodblock/github/inventory/MEMonitorIFluidHandler.java @@ -57,6 +57,10 @@ public class MEMonitorIFluidHandler implements IMEMonitor { } public IAEFluidStack injectItems(IAEFluidStack input, Actionable type, BaseActionSource src) { + if (!this.handler.canFill(this.side, input.getFluid())) { + return null; + } + int filled = this.handler.fill(this.side, input.getFluidStack(), type == Actionable.MODULATE); if (type == Actionable.MODULATE) { @@ -73,6 +77,9 @@ public class MEMonitorIFluidHandler implements IMEMonitor { } public IAEFluidStack extractItems(IAEFluidStack request, Actionable type, BaseActionSource src) { + if (!this.handler.canDrain(this.side, request.getFluid())) { + return null; + } FluidStack removed = this.handler.drain(this.side, request.getFluidStack(), type == Actionable.MODULATE); if (removed != null && removed.amount != 0) { IAEFluidStack o = request.copy();