aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java
diff options
context:
space:
mode:
authorkekzdealer <kekzdealer@gmail.com>2020-05-12 21:54:54 +0200
committerkekzdealer <kekzdealer@gmail.com>2020-05-12 21:54:54 +0200
commit90c07aea83b45e097b72243e08cd8d84a6dac8a8 (patch)
tree97ae5b93f98188d8ff98d603437a1be38b843803 /src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java
parentd4f0145505522e2244472e57eac6ec07319ad5c5 (diff)
downloadGT5-Unofficial-90c07aea83b45e097b72243e08cd8d84a6dac8a8.tar.gz
GT5-Unofficial-90c07aea83b45e097b72243e08cd8d84a6dac8a8.tar.bz2
GT5-Unofficial-90c07aea83b45e097b72243e08cd8d84a6dac8a8.zip
Revert "added overflow protection when dealing with TT laser hatches, as their throughput might exceed MAX_LONG"
This reverts commit dc21eafe10f52ce9cf55b651de72ba48667187c3.
Diffstat (limited to 'src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java')
-rw-r--r--src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java b/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java
index 031ea69dd4..2d8d2dc475 100644
--- a/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java
+++ b/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java
@@ -424,11 +424,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
}
final BigInteger remcapActual = capacity.subtract(stored);
final BigInteger recampLimited = (MAX_LONG.compareTo(remcapActual) > 0) ? remcapActual : MAX_LONG;
- final long watts = eHatch.maxEUInput() * eHatch.maxAmperesIn();
- long power = Math.min(
- // Overflow protection (taken from Math.addExact())
- ((eHatch.maxEUInput() ^ watts) & (eHatch.maxAmperesIn() ^ watts)) < 0 ? Long.MAX_VALUE : watts,
- recampLimited.longValue());
+ final long power = Math.min(eHatch.maxEUInput() * eHatch.maxAmperesIn(), recampLimited.longValue());
if(power <= eHatch.getEUVar()) {
eHatch.setEUVar(eHatch.getEUVar() - power);
stored = stored.add(BigInteger.valueOf(power));
@@ -440,11 +436,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
continue;
}
final BigInteger remStoredLimited = (MAX_LONG.compareTo(stored) > 0) ? stored : MAX_LONG;
- final long watts = eDynamo.maxEUOutput() * eDynamo.maxAmperesOut();
- long power = Math.min(
- // Overflow protection (taken from Math.addExact())
- ((eDynamo.maxEUOutput() ^ watts) & (eDynamo.maxAmperesOut() ^ watts)) < 0 ? Long.MAX_VALUE : watts,
- remStoredLimited.longValue());
+ final long power = Math.min(eDynamo.maxEUOutput() * eDynamo.maxAmperesOut(), remStoredLimited.longValue());
if(eDynamo.getEUVar() <= eDynamo.maxEUStore() - power) {
eDynamo.setEUVar(eDynamo.getEUVar() + power);
stored = stored.subtract(BigInteger.valueOf(power));