Skip to content

Commit 4e6c6c3

Browse files
committed
add getter, fix common refresh rate list
1 parent c511859 commit 4e6c6c3

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/main/java/net/earthcomputer/clientcommands/command/FramerateCommand.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ public class FramerateCommand {
3232

3333
public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
3434
dispatcher.register(literal("cfps")
35+
.executes(ctx -> getMaxFps(ctx.getSource()))
3536
.then(literal("unlimited")
3637
.executes(ctx -> maxFps(ctx.getSource(), Integer.MAX_VALUE))
3738
).then(argument("maxfps", integer())
3839
.suggests((context, builder) -> {
3940
int maxFps = getDisplayMaxFramerate();
4041
for (int refreshRate : COMMON_REFRESH_RATES) {
4142
if (refreshRate > maxFps) {
42-
break;
43+
continue;
4344
}
4445
builder.suggest(refreshRate);
4546
}
@@ -51,12 +52,22 @@ public static void register(CommandDispatcher<FabricClientCommandSource> dispatc
5152

5253
}
5354

55+
private static int getMaxFps(FabricClientCommandSource source) {
56+
int framerateLimit = source.getClient().getFramerateLimitTracker().getFramerateLimit();
57+
if (framerateLimit < Integer.MAX_VALUE) {
58+
source.sendFeedback(Component.translatable("commands.cfps.success.get", framerateLimit));
59+
} else {
60+
source.sendFeedback(Component.translatable("commands.cfps.success.get.unlimited"));
61+
}
62+
return framerateLimit;
63+
}
64+
5465
private static int maxFps(FabricClientCommandSource source, int maxFps) {
5566
source.getClient().getFramerateLimitTracker().setFramerateLimit(maxFps);
5667
if (maxFps == Integer.MAX_VALUE) {
57-
source.sendFeedback(Component.translatable("commands.cfps.success.unlimited"));
68+
source.sendFeedback(Component.translatable("commands.cfps.success.set.unlimited"));
5869
} else {
59-
source.sendFeedback(Component.translatable("commands.cfps.success", maxFps));
70+
source.sendFeedback(Component.translatable("commands.cfps.success.set", maxFps));
6071
}
6172
return maxFps;
6273
}

src/main/resources/assets/clientcommands/lang/en_us.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@
129129

130130
"commands.cfov.success": "Set FOV to %s",
131131

132-
"commands.cfps.success": "Set max FPS to %s",
133-
"commands.cfps.success.unlimited": "Set max FPS to unlimited",
132+
"commands.cfps.success.get": "max FPS is %s",
133+
"commands.cfps.success.get.unlimited": "max FPS is unlimited",
134+
"commands.cfps.success.set": "Set max FPS to %s",
135+
"commands.cfps.success.set.unlimited": "Set max FPS to unlimited",
134136

135137
"commands.cfunction.limitReached": "Command limit (%s) reached",
136138
"commands.cfunction.success": "Ran %s commands from function %s",

0 commit comments

Comments
 (0)