Skip to content

Commit 7a74d4b

Browse files
Merge pull request #130 from haykam821/gamma
Add cgamma command
2 parents e1c39c3 + 47c8adb commit 7a74d4b

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

src/main/java/net/earthcomputer/clientcommands/ClientCommands.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public static void registerCommands(CommandDispatcher<ServerCommandSource> dispa
4444
GetDataCommand.register(dispatcher);
4545
ScriptCommand.register(dispatcher);
4646
CalcStackCommand.register(dispatcher);
47+
GammaCommand.register(dispatcher);
4748

4849
CrackRNGCommand.register(dispatcher);
4950

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package net.earthcomputer.clientcommands.command;
2+
3+
import static com.mojang.brigadier.arguments.DoubleArgumentType.getDouble;
4+
import static com.mojang.brigadier.arguments.DoubleArgumentType.doubleArg;
5+
import static net.earthcomputer.clientcommands.command.ClientCommandManager.addClientSideCommand;
6+
import static net.earthcomputer.clientcommands.command.ClientCommandManager.*;
7+
import static net.minecraft.server.command.CommandManager.argument;
8+
import static net.minecraft.server.command.CommandManager.literal;
9+
10+
import com.mojang.brigadier.CommandDispatcher;
11+
12+
import net.minecraft.client.MinecraftClient;
13+
import net.minecraft.server.command.ServerCommandSource;
14+
import net.minecraft.text.Text;
15+
import net.minecraft.text.TranslatableText;
16+
17+
public class GammaCommand {
18+
19+
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
20+
addClientSideCommand("cgamma");
21+
22+
dispatcher.register(literal("cgamma")
23+
.then(argument("gamma", doubleArg())
24+
.executes(ctx -> setGamma(ctx.getSource(), getDouble(ctx, "gamma")))));
25+
}
26+
27+
private static int setGamma(ServerCommandSource source, double gamma) {
28+
MinecraftClient.getInstance().options.gamma = gamma;
29+
30+
Text feedback = new TranslatableText("commands.cgamma.success", gamma);
31+
sendFeedback(feedback);
32+
33+
return 1;
34+
}
35+
36+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
"commands.cfinditem.starting.keepSearching": "Infinitely searching for %s.",
3737
"commands.cfinditem.total": "Found %dx %s total",
3838

39+
"commands.cgamma.success": "Set gamma to %d",
40+
3941
"commands.crender.entities.success": "Entity rendering rules have been updated",
4042

4143
"commands.cscript.notFound": "Script \"%s\" not found",

0 commit comments

Comments
 (0)