From baa9caf06bd5793ccbddd8e8335668e3edd54900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20G=C3=A4=C3=9Fler?= Date: Wed, 26 Apr 2017 23:57:10 +0200 Subject: [PATCH] Eliminated rounding errors that caused fuel to burn too shortly The Large Boiler now saves excess fuel between items, greatly improves performance of items like sticks and planks. The Large boiler now stores excess projected EU that is lost when throttling with an integrated circuit --- src/main/java/gregtech/api/util/GT_Recipe.java | 14 ++++---------- .../multi/GT_MetaTileEntity_LargeBoiler.java | 11 ++++++++++- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/main/java/gregtech/api/util/GT_Recipe.java b/src/main/java/gregtech/api/util/GT_Recipe.java index 2bc8985c..3f102216 100644 --- a/src/main/java/gregtech/api/util/GT_Recipe.java +++ b/src/main/java/gregtech/api/util/GT_Recipe.java @@ -1406,17 +1406,11 @@ public class GT_Recipe implements Comparable { private GT_Recipe addRecipe(GT_Recipe recipe, double baseBurnTime){ recipe = new GT_Recipe(recipe); - //Some recipes will have a burn time like 15.9999999 and % always rounds down - double floatErrorCorrection = 0.0001; - double bronzeBurnTime = baseBurnTime * 2 + floatErrorCorrection; - bronzeBurnTime -= bronzeBurnTime % 0.05; - double steelBurnTime = baseBurnTime * 1.5 + floatErrorCorrection; - steelBurnTime -= steelBurnTime % 0.05; - double titaniumBurnTime = baseBurnTime * 1.3 + floatErrorCorrection; - titaniumBurnTime -= titaniumBurnTime % 0.05; - double tungstensteelBurnTime = baseBurnTime * 1.2 + floatErrorCorrection; - tungstensteelBurnTime -= tungstensteelBurnTime % 0.05; + double bronzeBurnTime = baseBurnTime * 2; + double steelBurnTime = baseBurnTime * 1.5; + double titaniumBurnTime = baseBurnTime * 1.3; + double tungstensteelBurnTime = baseBurnTime * 1.2; recipe.setNeiDesc("Burn time in seconds:", String.format("Bronze Boiler: %.2f", bronzeBurnTime), diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java index 4a9130c7..b3c0e8ce 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeBoiler.java @@ -24,6 +24,8 @@ public abstract class GT_MetaTileEntity_LargeBoiler private boolean firstRun = true; private int mSuperEfficencyIncrease = 0; private int integratedCircuitConfig = 0; //Steam output is reduced by 1000L per config + private int excessFuel = 0; //Eliminate rounding errors for fuels that burn half items + private int excessProjectedEU = 0; //Eliminate rounding errors from throttling the boiler public GT_MetaTileEntity_LargeBoiler(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -133,6 +135,9 @@ public abstract class GT_MetaTileEntity_LargeBoiler if (!tInputList.isEmpty()) { for (ItemStack tInput : tInputList) { if ((GT_Utility.getFluidForFilledItem(tInput, true) == null) && ((this.mMaxProgresstime = runtimeBoost(GT_ModHandler.getFuelValue(tInput) / 80)) > 0)) { + this.excessFuel += GT_ModHandler.getFuelValue(tInput) % 80; + this.mMaxProgresstime += this.excessFuel / 80; + this.excessFuel %= 80; this.mMaxProgresstime = adjustBurnTimeForConfig(this.mMaxProgresstime); this.mEUt = adjustEUtForConfig(getEUt()); this.mEfficiencyIncrease = (this.mMaxProgresstime * getEfficiencyIncrease()); @@ -264,6 +269,10 @@ public abstract class GT_MetaTileEntity_LargeBoiler return rawBurnTime; } int adjustedEUt = Math.max(25, getEUt() - 25 * integratedCircuitConfig); - return rawBurnTime * getEUt() / adjustedEUt; + int adjustedBurnTime = rawBurnTime * getEUt() / adjustedEUt; + this.excessProjectedEU += (getEUt() * rawBurnTime) - (adjustedEUt * adjustedBurnTime); + adjustedBurnTime += this.excessProjectedEU / adjustedEUt; + this.excessProjectedEU %= adjustedEUt; + return adjustedBurnTime; } } \ No newline at end of file