9
9
import net .lostluma .battery .api .State ;
10
10
import net .lostluma .battery .api .exception .LibraryLoadError ;
11
11
import net .lostluma .battery .api .util .LibraryUtil ;
12
+ import net .minecraft .client .Minecraft ;
12
13
import org .jetbrains .annotations .Nullable ;
13
14
14
15
import java .io .IOException ;
@@ -26,6 +27,7 @@ public class BatteryTracker {
26
27
private static @ Nullable Manager manager = null ;
27
28
private static Collection <Battery > batteries = Collections .emptyList ();
28
29
30
+ private static final Minecraft minecraft = Minecraft .getInstance ();
29
31
private static final Duration updateInterval = Duration .of (15 , ChronoUnit .SECONDS );
30
32
31
33
public static int charge () {
@@ -87,11 +89,17 @@ private static void updateState() {
87
89
88
90
if (readInitialData && charge != newCharge ) {
89
91
changed = true ;
90
- DynamicFPSMod .onBatteryChargeChanged (charge , newCharge );
92
+
93
+ int current = charge ;
94
+ minecraft .tell (() -> DynamicFPSMod .onBatteryChargeChanged (current , newCharge ));
91
95
}
92
96
93
97
if (readInitialData && status != newStatus ) {
94
- DynamicFPSMod .onBatteryStatusChanged (status ,newStatus );
98
+ changed = true ;
99
+
100
+ State current = status ;
101
+ State updated = newStatus ;
102
+ minecraft .tell (() -> DynamicFPSMod .onBatteryStatusChanged (current , updated ));
95
103
}
96
104
97
105
charge = newCharge ;
0 commit comments