From a170c6529a81b8c94813f152b272dde48c1585df Mon Sep 17 00:00:00 2001 From: pyure Date: Sat, 8 Aug 2015 20:14:06 -0400 Subject: [PATCH 1/2] Update Large Steam Turbine * Multiple input hatches now handled properly. * Now use 125% maximum input consumption and penalty * We now track averageFlow and totalFlow separately: we don't want turbine byproducts generated from the average, but the actual consumption. Notes from last pull: * We track 125% allowance via remainingFlow. We do still attempt to pull 125% from each hatch, but only up to our 125% overall allowance. (So even with two hatches, we can still only pull 500 steam total from a 400 steam rotor) * With remainingFlow, we gain optimization: we don't even check unnecessary hatches if the first one provided enough steam. * Reinstated averageFlow. * added a ton of comments for your convenience. --- .../GT_MetaTileEntity_LargeTurbine_Steam.java | 37 ++++++++++++------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java b/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java index 19a7f6ba..46f15130 100644 --- a/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java +++ b/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeTurbine_Steam.java @@ -67,21 +67,32 @@ public class GT_MetaTileEntity_LargeTurbine_Steam extends GT_MetaTileEntity_Larg @Override int fluidIntoPower(ArrayList aFluids, int aOptFlow, int aBaseEff) { int tEU=0; - int tOut=0; - for(int i=0;i 0;i++){ // loop through each hatch; extract inputs and track totals. if(aFluids.get(i).getFluid().getUnlocalizedName(aFluids.get(i)).equals("fluid.steam")||aFluids.get(i).getFluid().getUnlocalizedName(aFluids.get(i)).equals("ic2.fluidSteam")){ - tOut = Math.min((int)(aOptFlow*1.5f),aFluids.get(i).amount); - depleteInput(new FluidStack(aFluids.get(i), tOut)); + flow = aFluids.get(i).amount; // Get all (steam) in hatch + flow = Math.min(flow, Math.min(remainingFlow, (int)( aOptFlow * 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 } } - tOut = getAverage(tOut); - tEU = Math.min(aOptFlow,tOut); - addOutput(GT_ModHandler.getDistilledWater(useWater(tOut/160.0f))); - if(tOut>0&&tOut 0 && averageFlow != aOptFlow){ + float efficiency = 1.0f - Math.abs(((averageFlow - (float)aOptFlow) / aOptFlow)); + tEU *= efficiency; + tEU = Math.max(1, tEU * aBaseEff / 20000); + } + else { + tEU = tEU * aBaseEff / 20000; + } + return tEU; } - - } From 8e15794c0aaedd0ddd4be3b4842a74ddff9300f5 Mon Sep 17 00:00:00 2001 From: pyure Date: Tue, 11 Aug 2015 18:49:51 -0400 Subject: [PATCH 2/2] Large Heat Exchanger water/steam ratio * Ratio now 1:160 (perfect) * Now use useWater properly as intended * NOT using math.Round() or math.Floor() --- .../GT_MetaTileEntity_HeatExchanger.java | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java b/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java index 4443db4b..30ee99fe 100644 --- a/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java +++ b/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_HeatExchanger.java @@ -121,18 +121,28 @@ public class GT_MetaTileEntity_HeatExchanger extends GT_MetaTileEntity_MultiBloc return usage; } - public boolean onRunningTick(ItemStack aStack) - { - if (this.mEUt > 0) - { - int tGeneratedEU = (int)(this.mEUt * 2L * this.mEfficiency / 10000L); + public boolean onRunningTick(ItemStack aStack) { + + if (this.mEUt > 0) { + int tGeneratedEU = (int) (this.mEUt * 2L * this.mEfficiency / 10000L); // APPROXIMATELY how much steam to generate. + if (tGeneratedEU > 0) { - if (depleteInput(GT_ModHandler.getDistilledWater(useWater(((float)(superheated ? tGeneratedEU/2 :tGeneratedEU) + 160f) / 160f)))) { - if(superheated){addOutput(FluidRegistry.getFluidStack("ic2superheatedsteam", tGeneratedEU/2)); - }else{ - addOutput(GT_ModHandler.getSteam(tGeneratedEU));} + if (superheated) + tGeneratedEU /= 2; // We produce half as much superheated steam if necessary + + int distilledConsumed = useWater(tGeneratedEU / 160f); // how much distilled water to consume + tGeneratedEU = distilledConsumed * 160; // EXACTLY how much steam to generate, producing a perfect 1:160 ratio with distilled water consumption + + FluidStack distilledStack = GT_ModHandler.getDistilledWater(distilledConsumed); + if (depleteInput(distilledStack)) // Consume the distilled water + { + if (superheated) { + addOutput(FluidRegistry.getFluidStack("ic2superheatedsteam", tGeneratedEU)); // Generate superheated steam + } else { + addOutput(GT_ModHandler.getSteam(tGeneratedEU)); // Generate regular steam + } } else { - explodeMultiblock(); + explodeMultiblock(); // Generate crater } } return true;