diff options
author | Reflex18 <127531099+Reflex18@users.noreply.github.com> | 2024-04-06 01:46:20 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-05 17:46:20 +0200 |
commit | a5eb98a09c2a4f76b0d167e90edd1ba95caf0068 (patch) | |
tree | 15f41990c8697b0d577933210b856698ad48d39e /src/main/java/common | |
parent | 6c875cb21139d1f22cf482c0c52caeddb1f243ee (diff) | |
download | GT5-Unofficial-a5eb98a09c2a4f76b0d167e90edd1ba95caf0068.tar.gz GT5-Unofficial-a5eb98a09c2a4f76b0d167e90edd1ba95caf0068.tar.bz2 GT5-Unofficial-a5eb98a09c2a4f76b0d167e90edd1ba95caf0068.zip |
Added a time to empty/time to full readout on the LSC (#85)
* gradle
* Adding empty/filling readout to lsc
Update GTMTE_LapotronicSuperCapacitor.java
Update GTMTE_LapotronicSuperCapacitor.java
Update GTMTE_LapotronicSuperCapacitor.java
Update GTMTE_LapotronicSuperCapacitor.java
Update GTMTE_LapotronicSuperCapacitor.java
Update GTMTE_LapotronicSuperCapacitor.java
Update GTMTE_LapotronicSuperCapacitor.java
* Adding caching to avgin and avgout
* Moving cache up to include a few more variables
* Moved it to be inside the method call
* Spotless applied
Diffstat (limited to 'src/main/java/common')
-rw-r--r-- | src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java b/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java index 37b1489319..5222de0837 100644 --- a/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java +++ b/src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java @@ -907,6 +907,10 @@ public class GTMTE_LapotronicSuperCapacitor extends NumberFormat nf = NumberFormat.getNumberInstance(); int secInterval = DURATION_AVERAGE_TICKS / 20; + // Caching avgin and avgout + double avgIn = getAvgIn(); + double avgOut = getAvgOut(); + final ArrayList<String> ll = new ArrayList<>(); ll.add(EnumChatFormatting.YELLOW + "Operational Data:" + EnumChatFormatting.RESET); ll.add("EU Stored (exact): " + nf.format(stored) + "EU"); @@ -917,8 +921,27 @@ public class GTMTE_LapotronicSuperCapacitor extends ll.add("Passive Loss: " + nf.format(passiveDischargeAmount) + "EU/t"); ll.add("EU IN: " + GT_Utility.formatNumbers(inputLastTick) + "EU/t"); ll.add("EU OUT: " + GT_Utility.formatNumbers(outputLastTick) + "EU/t"); - ll.add("Avg EU IN: " + nf.format(getAvgIn()) + " (last " + secInterval + " seconds)"); - ll.add("Avg EU OUT: " + nf.format(getAvgOut()) + " (last " + secInterval + " seconds)"); + ll.add("Avg EU IN: " + nf.format(avgIn) + " (last " + secInterval + " seconds)"); + ll.add("Avg EU OUT: " + nf.format(avgOut) + " (last " + secInterval + " seconds)"); + + // Check if the system is charging or discharging + if (avgIn > avgOut) { + // Calculate time to full if charging + if (avgIn != 0) { + double timeToFull = (capacity.longValue() - stored.longValue()) / avgIn / 60; + ll.add("Time to Full: " + nf.format(timeToFull) + " minutes"); + } else { + ll.add("Completely full"); + } + } else { + // Calculate time to empty if discharging + if (avgOut != 0) { + double timeToEmpty = stored.longValue() / avgOut / 60; + ll.add("Time to Empty: " + nf.format(timeToEmpty) + " minutes"); + } else { + ll.add("Completely empty"); + } + } ll.add( "Maintenance Status: " + ((super.getRepairStatus() == super.getIdealStatus()) ? EnumChatFormatting.GREEN + "Working perfectly" + EnumChatFormatting.RESET |