aboutsummaryrefslogtreecommitdiff
path: root/main/java/gregtech/common/tileentities/machines
diff options
context:
space:
mode:
authorpyure <pyure@hotmail.com>2015-08-12 15:15:45 -0400
committerpyure <pyure@hotmail.com>2015-08-12 15:15:45 -0400
commit0c7b825e7ebcece7d780e4a96f79c319ccfe6c5f (patch)
treec8c32747fd836cf8f9f5d5f591d7a0db41e754ed /main/java/gregtech/common/tileentities/machines
parent27da7acbb3988fb2e4d47a83e7df7b833945ce63 (diff)
downloadGT5-Unofficial-0c7b825e7ebcece7d780e4a96f79c319ccfe6c5f.tar.gz
GT5-Unofficial-0c7b825e7ebcece7d780e4a96f79c319ccfe6c5f.tar.bz2
GT5-Unofficial-0c7b825e7ebcece7d780e4a96f79c319ccfe6c5f.zip
Plasma turbine fixes
* Math fixes (no more crazy output numbers) * getAverage() references removed * multiple input hatch support (first fluid-type handled only in case user tries to fuel with different-valued plasma types simultaneously) * 125% maximum overflow inefficiency
Diffstat (limited to 'main/java/gregtech/common/tileentities/machines')
-rw-r--r--main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java60
1 files changed, 44 insertions, 16 deletions
diff --git a/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java b/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java
index b1916b432f..ceed528bf4 100644
--- a/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java
+++ b/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Plasma.java
@@ -68,22 +68,50 @@ public class GT_MetaTileEntity_LargeTurbine_Plasma extends GT_MetaTileEntity_Lar
return 0;
}
- @Override
- int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff) {
- int tEU=0;
- int tOut=0;
- int tOptFlow = aOptFlow * 40;
- boolean b = false;
- for(int i=0;i<aFluids.size();i++){
- int fuelValue = getFuelValue(aFluids.get(i));
- if(fuelValue>0&&depleteInput(new FluidStack(aFluids.get(i),Math.max(tOptFlow/(fuelValue*2),1)))){
- tEU += tOptFlow/2;}
- }
- if(tEU>0)b=true;
- tEU = getAverage(tEU);
- if(b&&tEU<=0)tEU=3;
- return tEU * aBaseEff / 10000;
- }
+ @Override
+ int fluidIntoPower(ArrayList<FluidStack> aFluids, int aOptFlow, int aBaseEff) {
+
+ aOptFlow *= 40;
+ int tEU = 0;
+
+ int actualOptimalFlow = 0;
+
+ if (aFluids.size() >= 1) {
+ FluidStack firstFuelType = new FluidStack(aFluids.get(0), 0); // Identify a SINGLE type of fluid to process. Doesn't matter which one. Ignore the rest!
+ int fuelValue = getFuelValue(firstFuelType);
+ actualOptimalFlow = (int) (aOptFlow / fuelValue);
+
+ int remainingFlow = (int) (actualOptimalFlow * 1.25f); // Allowed to use up to 125% of optimal flow. Variable required outside of loop for multi-hatch scenarios.
+ int flow = 0;
+ int totalFlow = 0;
+
+ for (int i = 0; i < aFluids.size(); i++) {
+ if (aFluids.get(i).isFluidEqual(firstFuelType)) {
+ flow = aFluids.get(i).amount; // Get all (steam) in hatch
+ flow = Math.min(flow, Math.min(remainingFlow, (int) (actualOptimalFlow * 1.25f))); // try to use up to 125% of optimal flow w/o exceeding remainingFlow
+ depleteInput(new FluidStack(aFluids.get(i), flow)); // deplete that amount
+ remainingFlow -= flow; // track amount we're allowed to continue depleting from hatches
+ totalFlow += flow; // track total input used
+ }
+ }
+
+ tEU = (int) (Math.min((float) actualOptimalFlow, totalFlow) * fuelValue);
+
+ if (totalFlow != actualOptimalFlow) {
+ float efficiency = 1.0f - Math.abs(((totalFlow - (float) actualOptimalFlow) / actualOptimalFlow));
+ if (efficiency < 0)
+ efficiency = 0; // Can happen with really ludicrously poor inefficiency.
+ tEU *= efficiency;
+ tEU = Math.max(1, tEU * aBaseEff / 10000);
+ } else {
+ tEU = tEU * aBaseEff / 10000;
+ }
+
+ return tEU;
+
+ }
+ return 0;
+ }
}