From 94b79597091ed1e4846b2533c75ce15ab1c3bd9e Mon Sep 17 00:00:00 2001 From: "yiteng.liu" Date: Tue, 27 Feb 2024 04:09:51 -0800 Subject: [PATCH 1/6] Let remainingFlow become 125% of realOptFlow, rather than raw optimal flow. This can fix the inconsistance between optimal flow in tooltip and that in turbine. --- .../production/turbines/GT_MTE_LargeTurbine_SCSteam.java | 9 +++++---- .../production/turbines/GT_MTE_LargeTurbine_SHSteam.java | 7 ++++--- .../production/turbines/GT_MTE_LargeTurbine_Steam.java | 9 ++++++--- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SCSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SCSteam.java index ea6753e7d7..f8545b2121 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SCSteam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SCSteam.java @@ -59,8 +59,9 @@ int fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, f int tEU = 0; int totalFlow = 0; // Byproducts are based on actual flow int flow = 0; - int remainingFlow = MathUtils.safeInt((long) (aOptFlow * 1.25f)); // Allowed to use up to 125% of optimal flow. - // Variable required outside of loop for + int remainingFlow = MathUtils.safeInt((long) (aOptFlow * 1.25f * flowMultipliers[0])); // Allowed to use up to + // 125% of optimal flow. + // Variable required outside of loop for // multi-hatch scenarios. this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0]; @@ -78,8 +79,8 @@ int fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, f if (totalFlow <= 0) return 0; tEU = totalFlow; addOutput(GT_ModHandler.getSteam(totalFlow)); - if (totalFlow != aOptFlow) { - float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float) aOptFlow); + if (totalFlow != realOptFlow) { + float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow); // if(totalFlow>aOptFlow){efficiency = 1.0f;} tEU *= efficiency; tEU = Math.max(1, MathUtils.safeInt((long) tEU * (long) aBaseEff / 10000L)); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java index 0824c7560d..18c6e303b2 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java @@ -80,8 +80,9 @@ int fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, f int tEU = 0; int totalFlow = 0; // Byproducts are based on actual flow int flow = 0; - int remainingFlow = MathUtils.safeInt((long) (aOptFlow * 1.25f)); // Allowed to use up to 125% of optimal flow. - // Variable required outside of loop for + int remainingFlow = MathUtils.safeInt((long) (aOptFlow * flowMultipliers[0] * 1.25f)); // Allowed to use up to + // 125% of optimal flow. + // Variable required outside of loop for // multi-hatch scenarios. this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0]; @@ -112,7 +113,7 @@ int fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, f tEU = totalFlow; addOutput(GT_ModHandler.getSteam(totalFlow)); if (totalFlow != aOptFlow) { - float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float) aOptFlow); + float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow); // if(totalFlow>aOptFlow){efficiency = 1.0f;} tEU *= efficiency; tEU = Math.max(1, MathUtils.safeInt((long) tEU * (long) aBaseEff / 10000L)); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java index 750b62b43e..e4fb92b1e9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java @@ -89,8 +89,11 @@ int fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, f int tEU = 0; int totalFlow = 0; // Byproducts are based on actual flow int flow = 0; - int remainingFlow = MathUtils.safeInt((long) (aOptFlow * 1.25f)); // Allowed to use up to 125% of optimal flow. - // Variable required outside of loop for + int remainingFlow = MathUtils.safeInt((long) (aOptFlow * (double) flowMultipliers[0] * 1.25f)); // Allowed to + // use up to + // 125% of + // optimal flow. + // Variable required outside of loop for // multi-hatch scenarios. this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0]; @@ -121,7 +124,7 @@ int fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, f int waterToOutput = useWater(totalFlow / 160.0f); addOutput(GT_ModHandler.getDistilledWater(waterToOutput)); if (totalFlow != aOptFlow) { - float efficiency = 1.0f - Math.abs((totalFlow - aOptFlow) / (float) aOptFlow); + float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow); // if(totalFlow>aOptFlow){efficiency = 1.0f;} tEU *= efficiency; tEU = Math.max(1, MathUtils.safeInt((long) tEU * (long) aBaseEff / 20000L)); From 7a86a7641b510390ea255473aa84f4388bb23a36 Mon Sep 17 00:00:00 2001 From: koiNoCirculation Date: Tue, 27 Feb 2024 12:18:08 -0800 Subject: [PATCH 2/6] criteria should be totalFlow != realOptFlow in HP Steam and Steam turbine --- .../multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java | 2 +- .../multi/production/turbines/GT_MTE_LargeTurbine_Steam.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java index 18c6e303b2..763854ec9f 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java @@ -112,7 +112,7 @@ int fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, f if (totalFlow <= 0) return 0; tEU = totalFlow; addOutput(GT_ModHandler.getSteam(totalFlow)); - if (totalFlow != aOptFlow) { + if (totalFlow != realOptFlow) { float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow); // if(totalFlow>aOptFlow){efficiency = 1.0f;} tEU *= efficiency; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java index e4fb92b1e9..f257e1508a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java @@ -123,7 +123,7 @@ int fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, f tEU = totalFlow; int waterToOutput = useWater(totalFlow / 160.0f); addOutput(GT_ModHandler.getDistilledWater(waterToOutput)); - if (totalFlow != aOptFlow) { + if (totalFlow != realOptFlow) { float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow); // if(totalFlow>aOptFlow){efficiency = 1.0f;} tEU *= efficiency; From 4a6c00027959474ed6f687bfc834828c9cb22913 Mon Sep 17 00:00:00 2001 From: koiNoCirculation Date: Tue, 27 Feb 2024 12:49:22 -0800 Subject: [PATCH 3/6] fluidIntoPower should be long type, because ichorium huge turbine can generate power greater than Integer.MAX_VALUE on SC Turbine. --- .../production/turbines/GT_MTE_LargeTurbine_Gas.java | 2 +- .../turbines/GT_MTE_LargeTurbine_Plasma.java | 6 +++--- .../turbines/GT_MTE_LargeTurbine_SCSteam.java | 8 ++++---- .../turbines/GT_MTE_LargeTurbine_SHSteam.java | 8 +++++--- .../turbines/GT_MTE_LargeTurbine_Steam.java | 12 +++++++----- .../GregtechMetaTileEntity_LargerTurbineBase.java | 4 ++-- 6 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java index 759d7fc2ca..f2fd9a9a0a 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java @@ -107,7 +107,7 @@ protected boolean filtersFluid() { } @Override - int fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { + long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { if (aFluids.size() >= 1) { int tEU = 0; int actualOptimalFlow = 0; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java index 985c4e3e40..f8f40625a9 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java @@ -172,7 +172,7 @@ protected boolean filtersFluid() { } // How much the turbine should be producing with this flow - int newPower = fluidIntoPower(tFluids, optFlow, baseEff, flowMultipliers); + long newPower = fluidIntoPower(tFluids, optFlow, baseEff, flowMultipliers); // Reduce produced power depending on the ratio between fuel value and turbine EU/t with the following // formula: @@ -182,7 +182,7 @@ protected boolean filtersFluid() { fuelValue = getFuelValue(new FluidStack(tFluids.get(0), 0)); } float magicValue = (fuelValue * 0.005f) * (fuelValue * 0.005f); - float efficiencyLoss = Math.min(1.0f, magicValue / euPerTurbine); + long efficiencyLoss = (long) Math.min(1.0f, magicValue / euPerTurbine); newPower *= efficiencyLoss; long difference = newPower - this.lEUt; // difference between current output and new output @@ -218,7 +218,7 @@ protected boolean filtersFluid() { } @Override - int fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { + long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { if (aFluids.size() >= 1) { aOptFlow *= 800; // CHANGED THINGS HERE, check recipe runs once per 20 ticks int tEU = 0; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SCSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SCSteam.java index f8545b2121..83270e61d8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SCSteam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SCSteam.java @@ -55,15 +55,15 @@ public int getFuelValue(FluidStack aLiquid) { } @Override - int fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { + long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { int tEU = 0; int totalFlow = 0; // Byproducts are based on actual flow int flow = 0; - int remainingFlow = MathUtils.safeInt((long) (aOptFlow * 1.25f * flowMultipliers[0])); // Allowed to use up to - // 125% of optimal flow. // Variable required outside of loop for // multi-hatch scenarios. this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0]; + int remainingFlow = MathUtils.safeInt((long) (realOptFlow * 1.25f)); // Allowed to use up to + // 125% of optimal flow. storedFluid = 0; FluidStack tSCSteam = FluidRegistry.getFluidStack("supercriticalsteam", 1); @@ -88,7 +88,7 @@ int fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, f tEU = MathUtils.safeInt((long) tEU * (long) aBaseEff / 10000L); } - return (int) Math.min(tEU * 100L, Integer.MAX_VALUE); + return tEU * 100L; } @Override diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java index 763854ec9f..6931326d83 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java @@ -64,7 +64,7 @@ public int getFuelValue(FluidStack aLiquid) { } @Override - int fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { + long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { if (looseFit) { aOptFlow *= 4; if (aBaseEff > 10000) { @@ -80,12 +80,14 @@ int fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, f int tEU = 0; int totalFlow = 0; // Byproducts are based on actual flow int flow = 0; - int remainingFlow = MathUtils.safeInt((long) (aOptFlow * flowMultipliers[0] * 1.25f)); // Allowed to use up to - // 125% of optimal flow. + // Variable required outside of loop for // multi-hatch scenarios. this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0]; + int remainingFlow = MathUtils.safeInt((long) (realOptFlow * 1.25f)); // Allowed to use up to + // 125% of optimal flow. + storedFluid = 0; for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { String fluidName = aFluids.get(i).getFluid().getUnlocalizedName(aFluids.get(i)); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java index f257e1508a..db2452c900 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java @@ -73,7 +73,7 @@ public int getFuelValue(FluidStack aLiquid) { } @Override - int fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { + long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) { if (looseFit) { aOptFlow *= 4; if (aBaseEff > 10000) { @@ -89,14 +89,16 @@ int fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, f int tEU = 0; int totalFlow = 0; // Byproducts are based on actual flow int flow = 0; - int remainingFlow = MathUtils.safeInt((long) (aOptFlow * (double) flowMultipliers[0] * 1.25f)); // Allowed to - // use up to - // 125% of - // optimal flow. + // Variable required outside of loop for // multi-hatch scenarios. this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0]; + int remainingFlow = MathUtils.safeInt((long) (realOptFlow * 1.25f)); // Allowed to + // use up to + // 125% of + // optimal flow. + storedFluid = 0; for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { // loop through each hatch; extract inputs and // track totals. diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java index dc793a9282..f84cc77d46 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java @@ -483,7 +483,7 @@ protected void depleteTurbineFromStock(ItemStack aTurbine) { } // How much the turbine should be producing with this flow - int newPower = fluidIntoPower(tFluids, optFlow, baseEff, flowMultipliers); + long newPower = fluidIntoPower(tFluids, optFlow, baseEff, flowMultipliers); long difference = newPower - this.lEUt; // difference between current output and new output // Magic numbers: can always change by at least 10 eu/t, but otherwise by at most 1 percent of the @@ -553,7 +553,7 @@ public int getMaxParallelRecipes() { return (getFullTurbineAssemblies().size()); } - abstract int fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers); + abstract long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers); @Override public int getDamageToComponent(ItemStack aStack) { From bafdea239c6fca7f9934d4aea54752c074b3ff7f Mon Sep 17 00:00:00 2001 From: koiNoCirculation Date: Tue, 27 Feb 2024 13:27:59 -0800 Subject: [PATCH 4/6] Final change. --- .../production/turbines/GT_MTE_LargeTurbine_SCSteam.java | 4 +++- .../production/turbines/GT_MTE_LargeTurbine_SHSteam.java | 9 +++++---- .../production/turbines/GT_MTE_LargeTurbine_Steam.java | 9 +++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SCSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SCSteam.java index 83270e61d8..627717695b 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SCSteam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SCSteam.java @@ -61,7 +61,9 @@ long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, int flow = 0; // Variable required outside of loop for // multi-hatch scenarios. - this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0]; + this.realOptFlow = aOptFlow; + // this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0]; + // Will there be an multiplier for SC? int remainingFlow = MathUtils.safeInt((long) (realOptFlow * 1.25f)); // Allowed to use up to // 125% of optimal flow. diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java index 6931326d83..27408276d4 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java @@ -77,13 +77,14 @@ long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, aBaseEff *= 0.75f; } } - int tEU = 0; + // prevent overflow like that in SC Steam + long tEU = 0; int totalFlow = 0; // Byproducts are based on actual flow int flow = 0; // Variable required outside of loop for // multi-hatch scenarios. - this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0]; + this.realOptFlow = aOptFlow * flowMultipliers[0]; int remainingFlow = MathUtils.safeInt((long) (realOptFlow * 1.25f)); // Allowed to use up to // 125% of optimal flow. @@ -118,9 +119,9 @@ long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow); // if(totalFlow>aOptFlow){efficiency = 1.0f;} tEU *= efficiency; - tEU = Math.max(1, MathUtils.safeInt((long) tEU * (long) aBaseEff / 10000L)); + tEU = Math.max(1, tEU * aBaseEff / 10000L); } else { - tEU = MathUtils.safeInt((long) tEU * (long) aBaseEff / 10000L); + tEU = tEU * aBaseEff / 10000L; } return tEU; diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java index db2452c900..1e6a89e6ad 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java @@ -86,13 +86,14 @@ long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, aBaseEff *= 0.75f; } } - int tEU = 0; + // prevent overflow like that in SC Steam + long tEU = 0; int totalFlow = 0; // Byproducts are based on actual flow int flow = 0; // Variable required outside of loop for // multi-hatch scenarios. - this.realOptFlow = (double) aOptFlow * (double) flowMultipliers[0]; + this.realOptFlow = aOptFlow * flowMultipliers[0]; int remainingFlow = MathUtils.safeInt((long) (realOptFlow * 1.25f)); // Allowed to // use up to @@ -129,9 +130,9 @@ long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow); // if(totalFlow>aOptFlow){efficiency = 1.0f;} tEU *= efficiency; - tEU = Math.max(1, MathUtils.safeInt((long) tEU * (long) aBaseEff / 20000L)); + tEU = Math.max(1, tEU * aBaseEff / 20000L); } else { - tEU = MathUtils.safeInt((long) tEU * (long) aBaseEff / 20000L); + tEU = tEU * aBaseEff / 20000L; } return tEU; From 31308c22c1f9246895b3781de6726cf27794e7e1 Mon Sep 17 00:00:00 2001 From: koiNoCirculation Date: Tue, 27 Feb 2024 13:33:42 -0800 Subject: [PATCH 5/6] 1 -> 1L --- .../multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java | 2 +- .../multi/production/turbines/GT_MTE_LargeTurbine_Steam.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java index 27408276d4..7d36d35c77 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java @@ -119,7 +119,7 @@ long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow); // if(totalFlow>aOptFlow){efficiency = 1.0f;} tEU *= efficiency; - tEU = Math.max(1, tEU * aBaseEff / 10000L); + tEU = Math.max(1L, tEU * aBaseEff / 10000L); } else { tEU = tEU * aBaseEff / 10000L; } diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java index 1e6a89e6ad..3173ef8f37 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java @@ -130,7 +130,7 @@ long fluidIntoPower(ArrayList aFluids, long aOptFlow, int aBaseEff, float efficiency = 1.0f - Math.abs((totalFlow - (float) realOptFlow) / (float) realOptFlow); // if(totalFlow>aOptFlow){efficiency = 1.0f;} tEU *= efficiency; - tEU = Math.max(1, tEU * aBaseEff / 20000L); + tEU = Math.max(1L, tEU * aBaseEff / 20000L); } else { tEU = tEU * aBaseEff / 20000L; } From 627f140b2e35698f9a48256d5bf8adbc07786ab1 Mon Sep 17 00:00:00 2001 From: koiNoCirculation Date: Tue, 27 Feb 2024 13:43:20 -0800 Subject: [PATCH 6/6] revert the accidentally refactor in Plasma turbine --- .../multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java index f8f40625a9..d65224f4df 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java @@ -182,7 +182,7 @@ protected boolean filtersFluid() { fuelValue = getFuelValue(new FluidStack(tFluids.get(0), 0)); } float magicValue = (fuelValue * 0.005f) * (fuelValue * 0.005f); - long efficiencyLoss = (long) Math.min(1.0f, magicValue / euPerTurbine); + float efficiencyLoss = Math.min(1.0f, magicValue / euPerTurbine); newPower *= efficiencyLoss; long difference = newPower - this.lEUt; // difference between current output and new output