aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorkoiNoCirculation <57739338+koiNoCirculation@users.noreply.github.com>2024-02-27 22:16:04 -0800
committerGitHub <noreply@github.com>2024-02-28 07:16:04 +0100
commitece12a200879adfb16fd9d8701f6e75a3d7c072e (patch)
tree5fe217680e123b1e7407539c20edac3e5ab1062b /src/main/java
parentb0ef9ce3bffebb39c1ae6f552639bef0e5ccce45 (diff)
downloadGT5-Unofficial-ece12a200879adfb16fd9d8701f6e75a3d7c072e.tar.gz
GT5-Unofficial-ece12a200879adfb16fd9d8701f6e75a3d7c072e.tar.bz2
GT5-Unofficial-ece12a200879adfb16fd9d8701f6e75a3d7c072e.zip
Let remainingFlow become 125% of realOptFlow, rather than raw optimal… (#841)
* 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. * criteria should be totalFlow != realOptFlow in HP Steam and Steam turbine * fluidIntoPower should be long type, because ichorium huge turbine can generate power greater than Integer.MAX_VALUE on SC Turbine. * Final change. * 1 -> 1L * revert the accidentally refactor in Plasma turbine --------- Co-authored-by: yiteng.liu <yiteng.liu@11bee.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Gas.java2
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Plasma.java4
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SCSteam.java17
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_SHSteam.java22
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GT_MTE_LargeTurbine_Steam.java24
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/turbines/GregtechMetaTileEntity_LargerTurbineBase.java4
6 files changed, 43 insertions, 30 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 @@ public class GT_MTE_LargeTurbine_Gas extends GregtechMetaTileEntity_LargerTurbin
}
@Override
- int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) {
+ long fluidIntoPower(ArrayList<FluidStack> 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..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
@@ -172,7 +172,7 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur
}
// 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:
@@ -218,7 +218,7 @@ public class GT_MTE_LargeTurbine_Plasma extends GregtechMetaTileEntity_LargerTur
}
@Override
- int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) {
+ long fluidIntoPower(ArrayList<FluidStack> 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 ea6753e7d7..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
@@ -55,14 +55,17 @@ public class GT_MTE_LargeTurbine_SCSteam extends GregtechMetaTileEntity_LargerTu
}
@Override
- int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) {
+ long fluidIntoPower(ArrayList<FluidStack> 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)); // Allowed to use up to 125% of optimal flow.
- // Variable required outside of loop for
+ // 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.
storedFluid = 0;
FluidStack tSCSteam = FluidRegistry.getFluidStack("supercriticalsteam", 1);
@@ -78,8 +81,8 @@ public class GT_MTE_LargeTurbine_SCSteam extends GregtechMetaTileEntity_LargerTu
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));
@@ -87,7 +90,7 @@ public class GT_MTE_LargeTurbine_SCSteam extends GregtechMetaTileEntity_LargerTu
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 0824c7560d..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
@@ -64,7 +64,7 @@ public class GT_MTE_LargeTurbine_SHSteam extends GregtechMetaTileEntity_LargerTu
}
@Override
- int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) {
+ long fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) {
if (looseFit) {
aOptFlow *= 4;
if (aBaseEff > 10000) {
@@ -77,13 +77,17 @@ public class GT_MTE_LargeTurbine_SHSteam extends GregtechMetaTileEntity_LargerTu
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;
- int remainingFlow = MathUtils.safeInt((long) (aOptFlow * 1.25f)); // Allowed to use up to 125% of optimal flow.
- // Variable required outside of loop for
+
+ // 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.
storedFluid = 0;
for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) {
@@ -111,13 +115,13 @@ public class GT_MTE_LargeTurbine_SHSteam extends GregtechMetaTileEntity_LargerTu
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));
+ tEU = Math.max(1L, 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 750b62b43e..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
@@ -73,7 +73,7 @@ public class GT_MTE_LargeTurbine_Steam extends GregtechMetaTileEntity_LargerTurb
}
@Override
- int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) {
+ long fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers) {
if (looseFit) {
aOptFlow *= 4;
if (aBaseEff > 10000) {
@@ -86,13 +86,19 @@ public class GT_MTE_LargeTurbine_Steam extends GregtechMetaTileEntity_LargerTurb
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;
- int remainingFlow = MathUtils.safeInt((long) (aOptFlow * 1.25f)); // Allowed to use up to 125% of optimal flow.
- // Variable required outside of loop for
+
+ // 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.
storedFluid = 0;
for (int i = 0; i < aFluids.size() && remainingFlow > 0; i++) { // loop through each hatch; extract inputs and
@@ -120,13 +126,13 @@ public class GT_MTE_LargeTurbine_Steam extends GregtechMetaTileEntity_LargerTurb
tEU = totalFlow;
int waterToOutput = useWater(totalFlow / 160.0f);
addOutput(GT_ModHandler.getDistilledWater(waterToOutput));
- 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 / 20000L));
+ tEU = Math.max(1L, tEU * aBaseEff / 20000L);
} else {
- tEU = MathUtils.safeInt((long) tEU * (long) aBaseEff / 20000L);
+ tEU = tEU * aBaseEff / 20000L;
}
return tEU;
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 @@ public abstract class GregtechMetaTileEntity_LargerTurbineBase extends
}
// 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 abstract class GregtechMetaTileEntity_LargerTurbineBase extends
return (getFullTurbineAssemblies().size());
}
- abstract int fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers);
+ abstract long fluidIntoPower(ArrayList<FluidStack> aFluids, long aOptFlow, int aBaseEff, float[] flowMultipliers);
@Override
public int getDamageToComponent(ItemStack aStack) {