Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

toggle between modes keybinds! #104

Merged
merged 1 commit into from
Sep 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/main/java/dev/dfonline/codeclient/config/KeyBinds.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
Expand All @@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/codeclient/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down