@@ -19,14 +19,25 @@ public class FramerateCommand {
19
19
20
20
public static void register (CommandDispatcher <FabricClientCommandSource > dispatcher ) {
21
21
dispatcher .register (literal ("cfps" )
22
+ .executes (ctx -> getMaxFps (ctx .getSource ()))
22
23
.then (argument ("maxfps" , integer (1 ))
23
24
.suggests ((context , builder ) -> builder .suggest (MAX_REFRESH_RATE .getAsInt ()).buildFuture ())
24
- .executes (ctx -> maxFps (ctx .getSource (), getInteger (ctx , "maxfps" ))))
25
+ .executes (ctx -> setMaxFps (ctx .getSource (), getInteger (ctx , "maxfps" ))))
25
26
.then (literal ("unlimited" )
26
- .executes (ctx -> maxFps (ctx .getSource (), MAX_REFRESH_RATE .getAsInt () + 1 ))));
27
+ .executes (ctx -> setMaxFps (ctx .getSource (), MAX_REFRESH_RATE .getAsInt () + 1 ))));
27
28
}
28
29
29
- private static int maxFps (FabricClientCommandSource source , int maxFps ) {
30
+ private static int getMaxFps (FabricClientCommandSource source ) {
31
+ int framerateLimit = source .getClient ().getFramerateLimitTracker ().getFramerateLimit ();
32
+ if (framerateLimit > MAX_REFRESH_RATE .getAsInt ()) {
33
+ source .sendFeedback (Component .translatable ("commands.cfps.getMaxFps.unlimited" ));
34
+ } else {
35
+ source .sendFeedback (Component .translatable ("commands.cfps.getMaxFps" , framerateLimit ));
36
+ }
37
+ return framerateLimit ;
38
+ }
39
+
40
+ private static int setMaxFps (FabricClientCommandSource source , int maxFps ) {
30
41
int maxRefreshRate = MAX_REFRESH_RATE .getAsInt ();
31
42
boolean unlimited ;
32
43
if (maxFps > maxRefreshRate ) {
@@ -37,9 +48,9 @@ private static int maxFps(FabricClientCommandSource source, int maxFps) {
37
48
}
38
49
source .getClient ().getFramerateLimitTracker ().setFramerateLimit (maxFps );
39
50
if (unlimited ) {
40
- source .sendFeedback (Component .translatable ("commands.cfps.unlimited" ));
51
+ source .sendFeedback (Component .translatable ("commands.cfps.setMaxFps. unlimited" ));
41
52
} else {
42
- source .sendFeedback (Component .translatable ("commands.cfps.success" , maxFps ));
53
+ source .sendFeedback (Component .translatable ("commands.cfps.setMaxFps. success" , maxFps ));
43
54
}
44
55
return maxFps ;
45
56
}
0 commit comments