aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
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