From 9c4a50afeb16550d067cda78d563815a8e9b6a69 Mon Sep 17 00:00:00 2001 From: MrSam7K <64192417+MrSam7K@users.noreply.github.com> Date: Sat, 28 Sep 2024 11:09:11 +0300 Subject: [PATCH] toggle between modes keybinds! --- .../dfonline/codeclient/config/KeyBinds.java | 19 +++++++++++++++++++ .../assets/codeclient/lang/en_us.json | 2 ++ 2 files changed, 21 insertions(+) diff --git a/src/main/java/dev/dfonline/codeclient/config/KeyBinds.java b/src/main/java/dev/dfonline/codeclient/config/KeyBinds.java index 03f37bda..58343a62 100644 --- a/src/main/java/dev/dfonline/codeclient/config/KeyBinds.java +++ b/src/main/java/dev/dfonline/codeclient/config/KeyBinds.java @@ -4,6 +4,7 @@ import dev.dfonline.codeclient.dev.InteractionManager; import dev.dfonline.codeclient.dev.menu.devinventory.DevInventoryScreen; import dev.dfonline.codeclient.location.Dev; +import dev.dfonline.codeclient.location.Play; import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.minecraft.block.Blocks; import net.minecraft.client.option.KeyBinding; @@ -36,6 +37,15 @@ public class KeyBinds { */ public static KeyBinding previewItemTags; + /** + * Toggles between Play and Dev modes. + */ + public static KeyBinding playDev; + /** + * Toggles between Play and Build modes. + */ + public static KeyBinding playBuild; + public static void init() { editBind = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.codeclient.codepalette", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_Y, "category.codeclient.dev")); clipBind = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.codeclient.phaser", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_V, "category.codeclient.dev")); @@ -47,6 +57,8 @@ public static void init() { teleportBackward = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.codeclient.tp.backward", InputUtil.Type.KEYSYM, InputUtil.UNKNOWN_KEY.getCode(), "category.codeclient.navigation")); previewItemTags = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.codeclient.preview_item_tags", InputUtil.Type.KEYSYM, InputUtil.UNKNOWN_KEY.getCode(), "category.codeclient.dev")); + playDev = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.codeclient.playDev", InputUtil.UNKNOWN_KEY.getCode(), "category.codeclient.dev")); + playBuild = KeyBindingHelper.registerKeyBinding(new KeyBinding("key.codeclient.playBuild", InputUtil.UNKNOWN_KEY.getCode(), "category.codeclient.dev")); } public static void tick() { @@ -82,6 +94,13 @@ public static void tick() { } } } + + if(CodeClient.MC.getNetworkHandler() == null) return; + if (playDev.wasPressed()) + CodeClient.MC.getNetworkHandler().sendCommand(CodeClient.location instanceof Play ? "dev" : "play"); + + if (playBuild.wasPressed()) + CodeClient.MC.getNetworkHandler().sendCommand(CodeClient.location instanceof Play ? "build" : "play"); } private static void checkTp(KeyBinding keyBinding, Vec3d offset) { diff --git a/src/main/resources/assets/codeclient/lang/en_us.json b/src/main/resources/assets/codeclient/lang/en_us.json index fcb52a4c..e99dbfe5 100644 --- a/src/main/resources/assets/codeclient/lang/en_us.json +++ b/src/main/resources/assets/codeclient/lang/en_us.json @@ -3,6 +3,8 @@ "key.codeclient.codepalette": "Code Palette", "key.codeclient.phaser": "Phaser", "key.codeclient.preview_item_tags": "Preview Item Tags", + "key.codeclient.playDev": "Toggle Mode Play <-> Dev", + "key.codeclient.playBuild": "Toggle Mode Play <-> Build", "category.codeclient.navigation": "Code Navigation", "key.codeclient.tp.left": "Teleport Left",