From a5eb98a09c2a4f76b0d167e90edd1ba95caf0068 Mon Sep 17 00:00:00 2001 From: Reflex18 <127531099+Reflex18@users.noreply.github.com> Date: Sat, 6 Apr 2024 01:46:20 +1000 Subject: 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 --- .../GTMTE_LapotronicSuperCapacitor.java | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/main/java/common/tileentities/GTMTE_LapotronicSuperCapacitor.java') 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 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 -- cgit