diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/ftbsc/bscv/commands/Debug.java | 112 |
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; + }); + } + +} |