diff options
author | Linnea Gräf <nea@nea.moe> | 2024-08-07 21:34:16 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-08-07 21:34:16 +0200 |
commit | b4f9ca21ef801bb3e39c53ae21bb6bf4398c94e9 (patch) | |
tree | 1f7928e5587b6d4d7ca071949f0a70bf81282c14 /src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt | |
parent | 9b277bd897490d13ee4549a086e8d1b5f4cd0e10 (diff) | |
download | firmament-b4f9ca21ef801bb3e39c53ae21bb6bf4398c94e9.tar.gz firmament-b4f9ca21ef801bb3e39c53ae21bb6bf4398c94e9.tar.bz2 firmament-b4f9ca21ef801bb3e39c53ae21bb6bf4398c94e9.zip |
Add /firm npcs command
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt')
-rw-r--r-- | src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt b/src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt index f07cd29..4056e66 100644 --- a/src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt +++ b/src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt @@ -47,8 +47,7 @@ data class SavedKeyBinding( || InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_RIGHT_SUPER) } else InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_LEFT_CONTROL) || InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_RIGHT_CONTROL) - val shift = InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_LEFT_SHIFT) - || InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_RIGHT_SHIFT) + val shift = isShiftDown() val alt = InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_LEFT_ALT) || InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_RIGHT_ALT) var mods = 0 @@ -57,6 +56,11 @@ data class SavedKeyBinding( if (alt) mods = mods or GLFW.GLFW_MOD_ALT return mods } + + private val h get() = MC.window.handle + fun isShiftDown() = InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_LEFT_SHIFT) + || InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_RIGHT_SHIFT) + } fun isPressed(atLeast: Boolean = false): Boolean { @@ -69,8 +73,7 @@ data class SavedKeyBinding( || InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_RIGHT_SUPER) } else InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_LEFT_CONTROL) || InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_RIGHT_CONTROL) - val shift = InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_LEFT_SHIFT) - || InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_RIGHT_SHIFT) + val shift = isShiftDown() val alt = InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_LEFT_ALT) || InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_RIGHT_ALT) if (atLeast) |