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
This commit is contained in:
Johannes Gäßler 2017-04-26 23:57:10 +02:00
parent 8f4225f0b8
commit baa9caf06b
2 changed files with 14 additions and 11 deletions

View file

@ -1406,17 +1406,11 @@ public class GT_Recipe implements Comparable<GT_Recipe> {
private GT_Recipe addRecipe(GT_Recipe recipe, double baseBurnTime){ private GT_Recipe addRecipe(GT_Recipe recipe, double baseBurnTime){
recipe = new GT_Recipe(recipe); 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; double bronzeBurnTime = baseBurnTime * 2;
bronzeBurnTime -= bronzeBurnTime % 0.05; double steelBurnTime = baseBurnTime * 1.5;
double steelBurnTime = baseBurnTime * 1.5 + floatErrorCorrection; double titaniumBurnTime = baseBurnTime * 1.3;
steelBurnTime -= steelBurnTime % 0.05; double tungstensteelBurnTime = baseBurnTime * 1.2;
double titaniumBurnTime = baseBurnTime * 1.3 + floatErrorCorrection;
titaniumBurnTime -= titaniumBurnTime % 0.05;
double tungstensteelBurnTime = baseBurnTime * 1.2 + floatErrorCorrection;
tungstensteelBurnTime -= tungstensteelBurnTime % 0.05;
recipe.setNeiDesc("Burn time in seconds:", recipe.setNeiDesc("Burn time in seconds:",
String.format("Bronze Boiler: %.2f", bronzeBurnTime), String.format("Bronze Boiler: %.2f", bronzeBurnTime),

View file

@ -24,6 +24,8 @@ public abstract class GT_MetaTileEntity_LargeBoiler
private boolean firstRun = true; private boolean firstRun = true;
private int mSuperEfficencyIncrease = 0; private int mSuperEfficencyIncrease = 0;
private int integratedCircuitConfig = 0; //Steam output is reduced by 1000L per config 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) { public GT_MetaTileEntity_LargeBoiler(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional); super(aID, aName, aNameRegional);
@ -133,6 +135,9 @@ public abstract class GT_MetaTileEntity_LargeBoiler
if (!tInputList.isEmpty()) { if (!tInputList.isEmpty()) {
for (ItemStack tInput : tInputList) { for (ItemStack tInput : tInputList) {
if ((GT_Utility.getFluidForFilledItem(tInput, true) == null) && ((this.mMaxProgresstime = runtimeBoost(GT_ModHandler.getFuelValue(tInput) / 80)) > 0)) { 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.mMaxProgresstime = adjustBurnTimeForConfig(this.mMaxProgresstime);
this.mEUt = adjustEUtForConfig(getEUt()); this.mEUt = adjustEUtForConfig(getEUt());
this.mEfficiencyIncrease = (this.mMaxProgresstime * getEfficiencyIncrease()); this.mEfficiencyIncrease = (this.mMaxProgresstime * getEfficiencyIncrease());
@ -264,6 +269,10 @@ public abstract class GT_MetaTileEntity_LargeBoiler
return rawBurnTime; return rawBurnTime;
} }
int adjustedEUt = Math.max(25, getEUt() - 25 * integratedCircuitConfig); 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;
} }
} }