diff options
author | Maxim <maxim235@gmx.de> | 2023-02-16 13:21:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-16 13:21:35 +0100 |
commit | a9d3b225545a31a2b86ce6c66ca5c706a367f92d (patch) | |
tree | 9e62897174e63fd2beb87f25fd368f65c276ced7 /src/main/java/gregtech/api/util/AdvFusionPower.java | |
parent | 6d1ce9ee20fc0bdb7dda2d7066a8c3474e4d1050 (diff) | |
download | GT5-Unofficial-a9d3b225545a31a2b86ce6c66ca5c706a367f92d.tar.gz GT5-Unofficial-a9d3b225545a31a2b86ce6c66ca5c706a367f92d.tar.bz2 GT5-Unofficial-a9d3b225545a31a2b86ce6c66ca5c706a367f92d.zip |
Added tier-NEI-support for fusion mk4 (#545)
Diffstat (limited to 'src/main/java/gregtech/api/util/AdvFusionPower.java')
-rw-r--r-- | src/main/java/gregtech/api/util/AdvFusionPower.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/util/AdvFusionPower.java b/src/main/java/gregtech/api/util/AdvFusionPower.java new file mode 100644 index 0000000000..2ea04d9e0d --- /dev/null +++ b/src/main/java/gregtech/api/util/AdvFusionPower.java @@ -0,0 +1,43 @@ +package gregtech.api.util; + +import static gregtech.api.enums.GT_Values.V; + +import gregtech.common.power.FusionPower; +import gregtech.nei.FusionSpecialValueFormatter; + +public class AdvFusionPower extends FusionPower { + + public AdvFusionPower(byte tier, int startupPower) { + super(tier, startupPower); + } + + @Override + public void computePowerUsageAndDuration(int euPerTick, int duration, int specialValue) { + originalVoltage = computeVoltageForEuRate(euPerTick); + recipeEuPerTick = euPerTick; + recipeDuration = duration; + // It's safe to assume fusion is above ULV. We put this as safety check here anyway + if (tier > 0) { + int maxPossibleOverclocks = FusionSpecialValueFormatter.getFusionTier(this.specialValue, V[tier - 1]) + - FusionSpecialValueFormatter.getFusionTier(specialValue, euPerTick); + // Isn't too low EUt check? + long tempEUt = Math.max(euPerTick, V[1]); + + recipeDuration = duration; + + while (tempEUt <= V[tier - 1] * (long) amperage && maxPossibleOverclocks-- > 0 && recipeDuration > 1) { + tempEUt <<= 2; // this actually controls overclocking + recipeDuration >>= 2; // this is effect of overclocking + } + if (tempEUt > Integer.MAX_VALUE - 1) { + recipeEuPerTick = Integer.MAX_VALUE - 1; + recipeDuration = Integer.MAX_VALUE - 1; + } else { + recipeEuPerTick = (int) tempEUt; + if (recipeEuPerTick == 0) recipeEuPerTick = 1; + if (recipeDuration == 0) recipeDuration = 1; // set time to 1 tick + } + } + wasOverclocked = checkIfOverclocked(); + } +} |