aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorSpacebuilder2020 <spacebuilder2020@users.noreply.github.com>2024-09-04 05:17:10 -0600
committerGitHub <noreply@github.com>2024-09-04 11:17:10 +0000
commita00730b12c60394a8855e8b7a07bd9dfa4d5a252 (patch)
treeb7e466de8212cf124c7528919789682ce7af5775 /src/main/java
parent1904f6d4e3a571696ad815200a4de8b2e5df2f29 (diff)
downloadGT5-Unofficial-a00730b12c60394a8855e8b7a07bd9dfa4d5a252.tar.gz
GT5-Unofficial-a00730b12c60394a8855e8b7a07bd9dfa4d5a252.tar.bz2
GT5-Unofficial-a00730b12c60394a8855e8b7a07bd9dfa4d5a252.zip
Fix Overflows with Burn Times and adjust burn-time when the super efficiency increase logic reaches max efficiency (#3044)
* Fix Burn Times and adjust burntime when superEffIncrease reaches max eff. * Apply Spotless * implement suggestion Co-authored-by: Alexander Anishin <oneeyemaker@gmail.com> --------- Co-authored-by: boubou19 <miisterunknown@gmail.com> Co-authored-by: Alexander Anishin <oneeyemaker@gmail.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/MTELargeBoiler.java26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeBoiler.java b/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeBoiler.java
index 4d4025d7d4..64998d619b 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeBoiler.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/MTELargeBoiler.java
@@ -331,8 +331,7 @@ public abstract class MTELargeBoiler extends MTEEnhancedMultiBlockBase<MTELargeB
// those with very high fuel values that would cause an overflow error.
if (GTUtility.getFluidForFilledItem(tInput, true) == null
&& (this.mMaxProgresstime = GTModHandler.getFuelValue(tInput) / 80) > 0
- && (GTModHandler.getFuelValue(tInput) * 2 / this.getEUt()) > 1
- && GTModHandler.getFuelValue(tInput) < 100000000) {
+ && (GTModHandler.getFuelValue(tInput) * 2L / this.getEUt()) > 1) {
this.excessFuel += GTModHandler.getFuelValue(tInput) % 80;
this.mMaxProgresstime += this.excessFuel / 80;
this.excessFuel %= 80;
@@ -366,11 +365,22 @@ public abstract class MTELargeBoiler extends MTEEnhancedMultiBlockBase<MTELargeB
@Override
public boolean onRunningTick(ItemStack aStack) {
if (this.mEUt > 0) {
- if (this.mSuperEfficencyIncrease > 0) mEfficiency = Math.max(
- 0,
- Math.min(
- mEfficiency + mSuperEfficencyIncrease,
- getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000)));
+ int maxEff = getMaxEfficiency(mInventory[1]) - ((getIdealStatus() - getRepairStatus()) * 1000);
+ if (this.mSuperEfficencyIncrease > 0 && mEfficiency <= maxEff) {
+ mEfficiency = Math.max(0, Math.min(mEfficiency + mSuperEfficencyIncrease, maxEff));
+ if (mEfficiency == maxEff) {
+ // Adjust the burntime dynamically to account for circuit program
+ // This is to account for the dramatic issue where the machine outputs the throttled
+ // amount but the burntime is not throttled.
+ // This is very apparent when burning blocks with super high burntimes
+ int oldProgressTime = mProgresstime;
+ int oldMaxProgressTime = mMaxProgresstime;
+ int maxProgressTime = adjustBurnTimeForConfig(oldMaxProgressTime);
+ double progressRatio = (double) oldProgressTime / oldMaxProgressTime;
+ int progressTime = (int) Math.ceil(maxProgressTime * progressRatio);
+ mMaxProgresstime = maxProgressTime - (progressTime - oldProgressTime);
+ }
+ }
int tGeneratedEU = (int) (this.mEUt * 2L * this.mEfficiency / 10000L);
if (tGeneratedEU > 0) {
long amount = (tGeneratedEU + STEAM_PER_WATER) / STEAM_PER_WATER;
@@ -483,7 +493,7 @@ public abstract class MTELargeBoiler extends MTEEnhancedMultiBlockBase<MTELargeB
return rawBurnTime;
}
int adjustedEUt = Math.max(25, getEUt() - (isSuperheated() ? 75 : 25) * integratedCircuitConfig);
- int adjustedBurnTime = rawBurnTime * getEUt() / adjustedEUt;
+ int adjustedBurnTime = (int) (rawBurnTime * (long) getEUt() / adjustedEUt);
this.excessProjectedEU += getEUt() * rawBurnTime - adjustedEUt * adjustedBurnTime;
adjustedBurnTime += this.excessProjectedEU / adjustedEUt;
this.excessProjectedEU %= adjustedEUt;