aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorkekzdealer <kekzdealer@gmail.com>2020-05-14 19:00:10 +0200
committerkekzdealer <kekzdealer@gmail.com>2020-05-14 19:00:10 +0200
commitad5d0e42efe0d3d546a9dee91340288bf3e509c6 (patch)
tree9a726237f3e01289d17dadf0ee653b00df1f7867 /src/main/java
parent22da29fac28e4d19b024fa5764904c352de61d28 (diff)
downloadGT5-Unofficial-ad5d0e42efe0d3d546a9dee91340288bf3e509c6.tar.gz
GT5-Unofficial-ad5d0e42efe0d3d546a9dee91340288bf3e509c6.tar.bz2
GT5-Unofficial-ad5d0e42efe0d3d546a9dee91340288bf3e509c6.zip
Guarded against some edge case where you could get stuck with a wrong passive loss
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java b/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java
index 4ea0f06bb4..a23026b6ea 100644
--- a/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java
+++ b/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java
@@ -320,7 +320,7 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
}
// Calculate how much energy to void each tick
passiveDischargeAmount = new BigDecimal(tempCapacity).multiply(PASSIVE_DISCHARGE_FACTOR_PER_TICK).toBigInteger();
-
+ passiveDischargeAmount = recalculateLossWithMaintenance(super.getRepairStatus());
return formationChecklist;
}
@@ -442,11 +442,8 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
}
// Loose some energy
// Recalculate if the repair status changed
- final int repairStatus = super.getRepairStatus();
- if(repairStatus != repairStatusCache) {
- repairStatusCache = repairStatus;
- passiveDischargeAmount = new BigDecimal(passiveDischargeAmount)
- .multiply(BigDecimal.valueOf(1.0D + 0.2D * repairStatus)).toBigInteger();
+ if(super.getRepairStatus() != repairStatusCache) {
+ passiveDischargeAmount = recalculateLossWithMaintenance(super.getRepairStatus());
}
stored = stored.subtract(passiveDischargeAmount);
stored = (stored.compareTo(BigInteger.ZERO) <= 0) ? BigInteger.ZERO : stored;
@@ -455,6 +452,18 @@ public class GTMTE_LapotronicSuperCapacitor extends GT_MetaTileEntity_MultiBlock
}
/**
+ * To be called whenever the maintenance status changes or the capacity was recalculated
+ * @param repairStatus
+ * This machine's repair status
+ * @return new BigInteger instance for passiveDischargeAmount
+ */
+ private BigInteger recalculateLossWithMaintenance(int repairStatus) {
+ repairStatusCache = repairStatus;
+ return new BigDecimal(passiveDischargeAmount)
+ .multiply(BigDecimal.valueOf(1.0D + 0.2D * repairStatus)).toBigInteger();
+ }
+
+ /**
* Calculate how much EU to draw from an Energy Hatch
* @param hatchWatts
* Hatch amperage * voltage