diff options
Diffstat (limited to 'src/main/kotlin/events/WorldKeyboardEvent.kt')
| -rw-r--r-- | src/main/kotlin/events/WorldKeyboardEvent.kt | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/main/kotlin/events/WorldKeyboardEvent.kt b/src/main/kotlin/events/WorldKeyboardEvent.kt index 1d6a758..eed892d 100644 --- a/src/main/kotlin/events/WorldKeyboardEvent.kt +++ b/src/main/kotlin/events/WorldKeyboardEvent.kt @@ -1,17 +1,16 @@ package moe.nea.firmament.events -import net.minecraft.client.option.KeyBinding -import moe.nea.firmament.keybindings.IKeyBinding +import moe.nea.firmament.keybindings.GenericInputAction +import moe.nea.firmament.keybindings.InputModifiers +import moe.nea.firmament.keybindings.SavedKeyBinding data class WorldKeyboardEvent(val keyCode: Int, val scanCode: Int, val modifiers: Int) : FirmamentEvent.Cancellable() { - companion object : FirmamentEventBus<WorldKeyboardEvent>() - - fun matches(keyBinding: KeyBinding): Boolean { - return matches(IKeyBinding.minecraft(keyBinding)) + fun matches(keyBinding: SavedKeyBinding, atLeast: Boolean = false): Boolean { + return keyBinding.matches(intoAction(), InputModifiers(modifiers), atLeast) } - fun matches(keyBinding: IKeyBinding, atLeast: Boolean = false): Boolean { - return if (atLeast) keyBinding.matchesAtLeast(keyCode, scanCode, modifiers) else - keyBinding.matches(keyCode, scanCode, modifiers) - } + fun intoAction() = GenericInputAction.key(keyCode, scanCode) + + + companion object : FirmamentEventBus<WorldKeyboardEvent>() } |
