@@ -19,14 +19,25 @@ public class FramerateCommand {
1919
2020 public static void register (CommandDispatcher <FabricClientCommandSource > dispatcher ) {
2121 dispatcher .register (literal ("cfps" )
22+ .executes (ctx -> getMaxFps (ctx .getSource ()))
2223 .then (argument ("maxfps" , integer (1 ))
2324 .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" ))))
2526 .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 ))));
2728 }
2829
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 ) {
3041 int maxRefreshRate = MAX_REFRESH_RATE .getAsInt ();
3142 boolean unlimited ;
3243 if (maxFps > maxRefreshRate ) {
@@ -37,9 +48,9 @@ private static int maxFps(FabricClientCommandSource source, int maxFps) {
3748 }
3849 source .getClient ().getFramerateLimitTracker ().setFramerateLimit (maxFps );
3950 if (unlimited ) {
40- source .sendFeedback (Component .translatable ("commands.cfps.unlimited" ));
51+ source .sendFeedback (Component .translatable ("commands.cfps.setMaxFps. unlimited" ));
4152 } else {
42- source .sendFeedback (Component .translatable ("commands.cfps.success" , maxFps ));
53+ source .sendFeedback (Component .translatable ("commands.cfps.setMaxFps. success" , maxFps ));
4354 }
4455 return maxFps ;
4556 }
0 commit comments