diff --git a/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java b/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java index 010f05a0..2f750ab9 100644 --- a/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java +++ b/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Gas.java @@ -69,22 +69,48 @@ public class GT_MetaTileEntity_LargeTurbine_Gas extends GT_MetaTileEntity_LargeT return 10; } - @Override - int fluidIntoPower(ArrayList aFluids, int aOptFlow, int aBaseEff) { - int tEU=0; - int tOut=0; - int tOptFlow = aOptFlow; - boolean b = false; - for(int i=0;i0&&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 aFluids, int aOptFlow, int aBaseEff) { + 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; + } }