summaryrefslogtreecommitdiff
path: root/src/main/java/ftbsc
diff options
context:
space:
mode:
author alemi <me@alemi.dev>2023-03-18 22:08:22 +0100
committer alemi <me@alemi.dev>2023-03-18 22:08:22 +0100
commit20e953f15fad4168369316b588db3f510cf6df9e (patch)
tree68bd161a7c31332a184d73b785c4f622e07e849b /src/main/java/ftbsc
parent10cbb3bd8364d4e505519e19001265272425cd8c (diff)
feat: commands to do debug things
Diffstat (limited to 'src/main/java/ftbsc')
-rw-r--r--src/main/java/ftbsc/bscv/commands/Debug.java112
1 files changed, 112 insertions, 0 deletions
diff --git a/src/main/java/ftbsc/bscv/commands/Debug.java b/src/main/java/ftbsc/bscv/commands/Debug.java
new file mode 100644
index 0000000..75e1e9d
--- /dev/null
+++ b/src/main/java/ftbsc/bscv/commands/Debug.java
@@ -0,0 +1,112 @@
+package ftbsc.bscv.commands;
+
+import com.google.auto.service.AutoService;
+import com.mojang.brigadier.builder.LiteralArgumentBuilder;
+
+import ftbsc.bscv.api.ILoadable;
+import net.minecraft.client.AbstractOption;
+import net.minecraft.client.gui.screen.GamemodeSelectionScreen;
+import net.minecraft.command.CommandSource;
+import net.minecraft.command.Commands;
+import net.minecraft.util.math.MathHelper;
+import net.minecraftforge.server.command.EnumArgument;
+
+import static ftbsc.bscv.Boscovicino.log;
+
+@AutoService(ILoadable.class)
+public class Debug extends AbstractCommand {
+
+ private enum RenderDistanceAction {
+ INCREASE,
+ DECREASE
+ }
+
+ public LiteralArgumentBuilder<CommandSource> register(LiteralArgumentBuilder<CommandSource> builder) {
+ return builder
+ .then(
+ Commands.literal("reloadchunks")
+ .executes(ctx -> {
+ MC.levelRenderer.allChanged();
+ log("debug.reload_chunks.message");
+ return 0;
+ })
+ )
+ .then(
+ Commands.literal("hitboxes")
+ .executes(ctx -> {
+ boolean flag = !MC.getEntityRenderDispatcher().shouldRenderHitBoxes();
+ MC.getEntityRenderDispatcher().setRenderHitBoxes(flag);
+ log(flag ? "debug.show_hitboxes.on" : "debug.show_hitboxes.off");
+ return 0;
+ })
+ )
+ .then(
+ Commands.literal("clearmessages")
+ .executes(ctx -> {
+ if (MC.gui != null) {
+ MC.gui.getChat().clearMessages(false);
+ log("debug.clear_messages");
+ return 0;
+ }
+ return 1;
+ })
+ )
+ .then(
+ Commands.literal("renderdistance")
+ .then(
+ Commands.argument("action", EnumArgument.enumArgument(RenderDistanceAction.class))
+ .executes(ctx -> {
+ RenderDistanceAction action = ctx.getArgument("action", RenderDistanceAction.class);
+ double new_distance = MathHelper.clamp(
+ (double)(MC.options.renderDistance + (action == RenderDistanceAction.INCREASE ? +1 : -1)),
+ AbstractOption.RENDER_DISTANCE.getMinValue(), AbstractOption.RENDER_DISTANCE.getMaxValue()
+ );
+ AbstractOption.RENDER_DISTANCE.set(MC.options, new_distance);
+ log("debug.cycle_renderdistance.message");
+ return 0;
+ })
+ )
+ .executes(ctx -> {
+ log("[!] no action specified");
+ return 1;
+ })
+ )
+ .then(
+ Commands.literal("boundaries")
+ .executes(ctx -> {
+ boolean flag1 = MC.debugRenderer.switchRenderChunkborder();
+ log(flag1 ? "debug.chunk_boundaries.on" : "debug.chunk_boundaries.off");
+ return 0;
+ })
+ )
+ .then(
+ Commands.literal("tooltips")
+ .executes(ctx -> {
+ MC.options.advancedItemTooltips = !MC.options.advancedItemTooltips;
+ MC.options.save();
+ log(MC.options.advancedItemTooltips ? "debug.advanced_tooltips.on" : "debug.advanced_tooltips.off");
+ return 0;
+ })
+ )
+ .then(
+ Commands.literal("reloadresources")
+ .executes(ctx -> {
+ MC.reloadResourcePacks();
+ log("debug.reload_resourcepacks.message");
+ return 0;
+ })
+ )
+ .then(
+ Commands.literal("gamemode")
+ .executes(ctx -> {
+ MC.setScreen(new GamemodeSelectionScreen());
+ return 0;
+ })
+ )
+ .executes(ctx -> {
+ log("[!] no debug action requested");
+ return 1;
+ });
+ }
+
+}