diff options
author | kekzdealer <kekzdealer@gmail.com> | 2020-05-07 21:33:42 +0200 |
---|---|---|
committer | kekzdealer <kekzdealer@gmail.com> | 2020-05-07 22:34:17 +0200 |
commit | 1c02ee5485a9ec522b118c84288b906196fb75af (patch) | |
tree | ce301ba791037a7242dd71f7b95a8a6799de0b53 /src | |
parent | a90d13e848293cf664774168f14772c4a63ced00 (diff) | |
download | GT5-Unofficial-1c02ee5485a9ec522b118c84288b906196fb75af.tar.gz GT5-Unofficial-1c02ee5485a9ec522b118c84288b906196fb75af.tar.bz2 GT5-Unofficial-1c02ee5485a9ec522b118c84288b906196fb75af.zip |
Moved TFFT auto void logic to MultiFluidHandler
Diffstat (limited to 'src')
3 files changed, 33 insertions, 33 deletions
diff --git a/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java b/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java index c4407c3c05..5025fc53c1 100644 --- a/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java +++ b/src/main/java/common/tileentities/GTMTE_FluidMultiStorage.java @@ -47,7 +47,6 @@ public class GTMTE_FluidMultiStorage extends GT_MetaTileEntity_MultiBlockBase { private int runningCost = 0;
private boolean doVoidExcess = false;
-
private byte fluidSelector = 0;
public GTMTE_FluidMultiStorage(int aID, String aName, String aNameRegional) {
@@ -68,7 +67,7 @@ public class GTMTE_FluidMultiStorage extends GT_MetaTileEntity_MultiBlockBase { final MultiBlockTooltipBuilder b = new MultiBlockTooltipBuilder();
b.addInfo("High-Tech fluid tank that can hold up to 25 different fluids!")
.addInfo("Has 1/25th of the total capacity as capacity for each fluid.")
- .addInfo("Rightclicking the controller with a screwdriver will turn on excess voiding.")
+ .addInfo("Right clicking the controller with a screwdriver will turn on excess voiding.")
.addInfo("Fluid storage amount and running cost depends on the storage field blocks used.")
.addSeparator()
.addInfo("Note on hatch locking:")
@@ -139,13 +138,6 @@ public class GTMTE_FluidMultiStorage extends GT_MetaTileEntity_MultiBlockBase { toDeplete.amount = pushed;
super.depleteInput(toDeplete);
}
-
- // Void excess if that is turned on
- if (doVoidExcess) {
- for (GT_MetaTileEntity_Hatch_Input inputHatch : super.mInputHatches) {
- inputHatch.setDrainableStack(null);
- }
- }
}
// Push out fluids
@@ -200,6 +192,7 @@ public class GTMTE_FluidMultiStorage extends GT_MetaTileEntity_MultiBlockBase { if (mfh != null) {
mfh.setLock(!super.getBaseMetaTileEntity().isActive());
mfh.setFluidSelector(fluidSelector);
+ mfh.setDoVoidExcess(doVoidExcess);
}
}
diff --git a/src/main/java/common/tileentities/TE_TFFTMultiHatch.java b/src/main/java/common/tileentities/TE_TFFTMultiHatch.java index 04a8048904..d334a92070 100644 --- a/src/main/java/common/tileentities/TE_TFFTMultiHatch.java +++ b/src/main/java/common/tileentities/TE_TFFTMultiHatch.java @@ -27,7 +27,7 @@ public class TE_TFFTMultiHatch extends TileEntity implements IFluidHandler { } public void toggleAutoOutput() { - autoOutput = autoOutput ? false : true; + autoOutput = !autoOutput; } public boolean isOutputting() { @@ -52,7 +52,7 @@ public class TE_TFFTMultiHatch extends TileEntity implements IFluidHandler { this.yCoord + d.offsetY, this.zCoord + d.offsetZ); - if(t != null && t instanceof IFluidHandler) { + if(t instanceof IFluidHandler) { final IFluidHandler fh = (IFluidHandler) t; @@ -71,8 +71,8 @@ public class TE_TFFTMultiHatch extends TileEntity implements IFluidHandler { final FluidStack copy = volume.copy(); copy.amount = Math.min(copy.amount, OUTPUT_PER_SECOND); - final int drawn = mfh.pullFluid(copy, false); - copy.amount = drawn; + // How much is drawn + copy.amount = mfh.pullFluid(copy, false); // Test how much can be filled (and fill if possible) copy.amount = fh.fill(d.getOpposite(), copy, true); @@ -141,7 +141,7 @@ public class TE_TFFTMultiHatch extends TileEntity implements IFluidHandler { if(mfh != null) { final FluidStack drain = mfh.getFluid(0); if(drain != null) { - // If there's no integrated circuit in the TFFT controller, output slot 0 + // If there's no integrated circuit in the T.F.F.T. controller, output slot 0 final byte selectedSlot = (mfh.getSelectedFluid() == -1) ? 0 : mfh.getSelectedFluid(); return new FluidStack( @@ -155,12 +155,12 @@ public class TE_TFFTMultiHatch extends TileEntity implements IFluidHandler { @Override public boolean canFill(ForgeDirection from, Fluid fluid) { - return (mfh != null) ? mfh.couldPush(new FluidStack(fluid, 1)) : false; + return (mfh != null) && mfh.couldPush(new FluidStack(fluid, 1)); } @Override public boolean canDrain(ForgeDirection from, Fluid fluid) { - return (mfh != null) ? mfh.contains(new FluidStack(fluid, 1)) : false; + return (mfh != null) && mfh.contains(new FluidStack(fluid, 1)); } @Override diff --git a/src/main/java/kekztech/MultiFluidHandler.java b/src/main/java/kekztech/MultiFluidHandler.java index 880576ca7e..407fb32e54 100644 --- a/src/main/java/kekztech/MultiFluidHandler.java +++ b/src/main/java/kekztech/MultiFluidHandler.java @@ -15,6 +15,7 @@ public class MultiFluidHandler { private int capacityPerFluid; private boolean locked = true; + private boolean doVoidExcess = false; private byte fluidSelector = -1; public MultiFluidHandler() { @@ -39,7 +40,9 @@ public class MultiFluidHandler { public void setLock(boolean state) { locked = state; } - + + public void setDoVoidExcess(boolean doVoidExcess) { this.doVoidExcess = doVoidExcess; } + /** * Used to tell the MFH if a fluid is selected by * an Integrated Circuit in the controller. @@ -69,7 +72,7 @@ public class MultiFluidHandler { } public List<FluidStack> getFluids(){ - return (!locked) ? fluids : new ArrayList<FluidStack>(); + return (!locked) ? fluids : new ArrayList<>(); } public FluidStack getFluid(int slot) { @@ -131,24 +134,25 @@ public class MultiFluidHandler { return 0; } if(fluids.size() == MAX_DISTINCT_FLUIDS && !contains(push)) { + // Already contains 25 fluids and this isn't one of them return 0; } else if (fluids.size() < MAX_DISTINCT_FLUIDS && !contains(push)) { // Add new fluid - final int remcap = getCapacity(); - final int fit = Math.min(remcap, push.amount); + final int fit = Math.min(getCapacity(), push.amount); if(doPush) { fluids.add(new FluidStack(push.getFluid(), fit)); } - return fit; + // If doVoidExcess, pretend all of it fit + return doVoidExcess ? push.amount : fit; } else { // Add to existing fluid - final FluidStack fs = fluids.get(fluids.indexOf(push)); - final int remcap = getCapacity() - fs.amount; - final int fit = Math.min(remcap, push.amount); + final FluidStack existing = fluids.get(fluids.indexOf(push)); + final int fit = Math.min(getCapacity() - existing.amount, push.amount); if(doPush) { - fs.amount += fit; + existing.amount += fit; } - return fit; + // If doVoidExcess, pretend all of it fit + return doVoidExcess ? push.amount : fit; } } @@ -168,18 +172,21 @@ public class MultiFluidHandler { return 0; } if(slot < 0 || slot >= MAX_DISTINCT_FLUIDS) { + // Invalid slot return 0; } - if(!fluids.get(slot).equals(push)) { + if((fluids.get(slot) != null) && !fluids.get(slot).equals(push)) { + // Selected slot is taken by a non-matching fluid return 0; } else { - final FluidStack fs = fluids.get(slot); - final int remcap = getCapacity() - fs.amount; - final int fit = Math.min(remcap, push.amount); + // Add to existing fluid + final FluidStack existing = fluids.get(slot); + final int fit = Math.min(getCapacity() - existing.amount, push.amount); if(doPush) { - fs.amount += fit; + existing.amount += fit; } - return fit; + // If doVoidExcess, pretend all of it fit + return doVoidExcess ? push.amount : fit; } } @@ -260,7 +267,7 @@ public class MultiFluidHandler { return Math.min(getCapacity(), push.amount) > 0; } else { final int remcap = getCapacity() - fluids.get(fluids.indexOf(push)).amount; - return Math.min(remcap, push.amount) > 0; + return doVoidExcess ? true : (Math.min(remcap, push.amount) > 0); } } } |