From 14f232e3fcb380e9f8bfc4bccb681ac3b015a650 Mon Sep 17 00:00:00 2001 From: Oth3r Date: Tue, 6 Aug 2024 11:10:45 -0500 Subject: [PATCH] new sitting keybind, executes the sit command on sit servers --- src/main/java/one/oth3r/sit/utl/Events.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main/java/one/oth3r/sit/utl/Events.java b/src/main/java/one/oth3r/sit/utl/Events.java index ddd137d..c3996bc 100644 --- a/src/main/java/one/oth3r/sit/utl/Events.java +++ b/src/main/java/one/oth3r/sit/utl/Events.java @@ -27,6 +27,7 @@ public class Events { private static class Keybindings { private static KeyBinding toggle_key; + private static KeyBinding sit_key; private static void register() { toggle_key = KeyBindingHelper.registerKeyBinding(new KeyBinding( @@ -34,6 +35,11 @@ public class Events { GLFW.GLFW_KEY_UNKNOWN, "category.sit" )); + sit_key = KeyBindingHelper.registerKeyBinding(new KeyBinding( + "key.sit", + GLFW.GLFW_KEY_UNKNOWN, + "category.sit" + )); } private static void loopLogic(ClientPlayerEntity player) { @@ -68,6 +74,19 @@ public class Events { } } } + + while (sit_key.wasPressed()) { + // just send the sit command + if (Data.isInGame()) { + if (Data.isSupportedServer()) { + player.networkHandler.sendCommand("sit"); + } else { + // unsupported server message if not in a Sit! server + player.sendMessage(Utl.lang("msg.unsupported") + .formatted(Formatting.RED), true); + } + } + } } }