From 4a6c00027959474ed6f687bfc834828c9cb22913 Mon Sep 17 00:00:00 2001 From: koiNoCirculation Date: Tue, 27 Feb 2024 12:49:22 -0800 Subject: [PATCH] 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 759d7fc2c..f2fd9a9a0 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 985c4e3e4..f8f40625a 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 f8545b212..83270e61d 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 763854ec9..6931326d8 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 f257e1508..db2452c90 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 dc793a928..f84cc77d4 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) {