diff options
author | BlueWeabo <76872108+BlueWeabo@users.noreply.github.com> | 2023-01-01 23:58:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-01 22:58:14 +0100 |
commit | 744834083d4504108be1715d36acd94d71c31a84 (patch) | |
tree | b20bf8c21ec8149aa0988fb7d0125d1944cf6373 /src/main/java/gregtech/common/tileentities | |
parent | 988fd7962d5dbb39980ca248d41317594c2d53c4 (diff) | |
download | GT5-Unofficial-744834083d4504108be1715d36acd94d71c31a84.tar.gz GT5-Unofficial-744834083d4504108be1715d36acd94d71c31a84.tar.bz2 GT5-Unofficial-744834083d4504108be1715d36acd94d71c31a84.zip |
Add a Overclock Calculator for multis and the like to use (#1617)
* add calculator and unit tests
* use math.ceil
* math.ceil everywhere
* add some more unit tests and add onetick discount possibility
* add an exception when trying to get the consumption before calculating
* spotless oops
* convert PCB Factory to use the OC calculator
* fix tests trying for wrong values
* fix copy paste error
* address reviews
* this should be there too.
Diffstat (limited to 'src/main/java/gregtech/common/tileentities')
-rw-r--r-- | src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PCBFactory.java | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PCBFactory.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PCBFactory.java index 6d7862909d..94f03f7fe5 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PCBFactory.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_PCBFactory.java @@ -48,6 +48,7 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_Multiblock_Tooltip_Builder; import gregtech.api.util.GT_OreDictUnificator; +import gregtech.api.util.GT_OverclockCalculator; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; import gregtech.common.blocks.GT_Block_Casings8; @@ -527,6 +528,7 @@ public class GT_MetaTileEntity_PCBFactory } long voltage = getMaxInputVoltage(); + long amps = getMaxInputAmps(); int tier = GT_Utility.getTier(voltage); GT_Recipe tRecipe = @@ -582,12 +584,23 @@ public class GT_MetaTileEntity_PCBFactory this.mMaxProgresstime = (int) Math.ceil(tRecipe.mDuration * Math.pow(mRoughnessMultiplier, 2)); if (mOCTier1 || mOCTier2) { - calculateOverclockedNessMultiInternal( - (long) Math.ceil(tRecipe.mEUt * aExtraPower), - (int) Math.ceil(tRecipe.mDuration * Math.pow(mRoughnessMultiplier, 2)), - aCurrentParallel, - V[tier], - mOCTier2); + GT_OverclockCalculator calc = new GT_OverclockCalculator() + .setRecipeEUt(tRecipe.mEUt) + .setDuration(tRecipe.mDuration) + .setEUt(voltage) + .setAmperage(amps) + .setEUtDiscount(aExtraPower) + .setSpeedBoost((float) Math.pow(mRoughnessMultiplier, 2)); + if (mOCTier2) { + calc.enablePerfectOC(); + } + calc.calculate(); + try { + this.lEUt = calc.getConsumption(); + this.mMaxProgresstime = calc.getDuration(); + } catch (Exception e) { + e.printStackTrace(); + } } if (this.lEUt == Long.MAX_VALUE - 1 || this.mProgresstime == Integer.MAX_VALUE - 1) return false; |