aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/covers/GT_Cover_Pump.java
diff options
context:
space:
mode:
authorMartin Robertz <dream-master@gmx.net>2024-01-14 18:20:41 +0100
committerGitHub <noreply@github.com>2024-01-14 18:20:41 +0100
commit82026627c6fafbc0def10244f8c02ebd8c514f9a (patch)
tree5a25d3e90f3060095e30bdb2406ef16703b5e1f1 /src/main/java/gregtech/common/covers/GT_Cover_Pump.java
parentfee9926380647755f5882b8869462281123e0a46 (diff)
downloadGT5-Unofficial-82026627c6fafbc0def10244f8c02ebd8c514f9a.tar.gz
GT5-Unofficial-82026627c6fafbc0def10244f8c02ebd8c514f9a.tar.bz2
GT5-Unofficial-82026627c6fafbc0def10244f8c02ebd8c514f9a.zip
Feature/movefluid (#2459)
* merge similar code into new utility function moveFluid * Spotless apply for branch feature/movefluid for #2455 (#2456) spotlessApply Co-authored-by: GitHub GTNH Actions <> * fix boolean logic * Spotless apply for branch feature/movefluid for #2459 (#2460) spotlessApply Co-authored-by: GitHub GTNH Actions <> * fix (cherry picked from commit dce33cb4bbc0b1405bcbee25b5f1f1e6384f0147) --------- Co-authored-by: Glease <4586901+Glease@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gregtech/common/covers/GT_Cover_Pump.java')
-rw-r--r--src/main/java/gregtech/common/covers/GT_Cover_Pump.java28
1 files changed, 6 insertions, 22 deletions
diff --git a/src/main/java/gregtech/common/covers/GT_Cover_Pump.java b/src/main/java/gregtech/common/covers/GT_Cover_Pump.java
index f36f6ce215..e1bbf950ce 100644
--- a/src/main/java/gregtech/common/covers/GT_Cover_Pump.java
+++ b/src/main/java/gregtech/common/covers/GT_Cover_Pump.java
@@ -50,32 +50,16 @@ public class GT_Cover_Pump extends GT_CoverBehavior {
final IFluidHandler toAccess = aTileEntity.getITankContainerAtSide(side);
if (toAccess == null) return aCoverVariable;
- transferFluid(current, toAccess, side, aCoverVariable % 2);
+ transferFluid(current, toAccess, side, aCoverVariable % 2 == 0);
}
return aCoverVariable;
}
- protected void transferFluid(IFluidHandler current, IFluidHandler toAccess, ForgeDirection side,
- int exportOrImport) {
- if (exportOrImport == 0) {
- FluidStack liquid = current.drain(side, this.mTransferRate, false);
- if (liquid != null) {
- liquid = liquid.copy();
- liquid.amount = toAccess.fill(side.getOpposite(), liquid, false);
- if (liquid.amount > 0 && canTransferFluid(liquid)) {
- toAccess.fill(side.getOpposite(), current.drain(side, liquid.amount, true), true);
- }
- }
- return;
- }
- FluidStack liquid = toAccess.drain(side.getOpposite(), this.mTransferRate, false);
- if (liquid != null) {
- liquid = liquid.copy();
- liquid.amount = current.fill(side, liquid, false);
- if (liquid.amount > 0 && canTransferFluid(liquid)) {
- current.fill(side, toAccess.drain(side.getOpposite(), liquid.amount, true), true);
- }
- }
+ protected void transferFluid(IFluidHandler current, IFluidHandler toAccess, ForgeDirection side, boolean export) {
+ IFluidHandler source = export ? current : toAccess;
+ IFluidHandler dest = export ? toAccess : current;
+ ForgeDirection drainSide = export ? side : side.getOpposite();
+ GT_Utility.moveFluid(source, dest, drainSide, mTransferRate, this::canTransferFluid);
}
protected boolean canTransferFluid(FluidStack fluid) {