diff options
Diffstat (limited to 'src/main/kotlin/dulkirmod/command')
-rw-r--r-- | src/main/kotlin/dulkirmod/command/FarmingControlSchemeCommand.kt | 52 | ||||
-rw-r--r-- | src/main/kotlin/dulkirmod/command/HelpCommand.kt | 1 |
2 files changed, 53 insertions, 0 deletions
diff --git a/src/main/kotlin/dulkirmod/command/FarmingControlSchemeCommand.kt b/src/main/kotlin/dulkirmod/command/FarmingControlSchemeCommand.kt new file mode 100644 index 0000000..8bbad18 --- /dev/null +++ b/src/main/kotlin/dulkirmod/command/FarmingControlSchemeCommand.kt @@ -0,0 +1,52 @@ +package dulkirmod.command + +import dulkirmod.config.Config +import dulkirmod.utils.TextUtils +import net.minecraft.client.Minecraft +import net.minecraft.client.settings.KeyBinding +import net.minecraft.command.CommandException +import net.minecraft.command.ICommandSender + +class FarmingControlSchemeCommand : ClientCommandBase("farmcontrols") { + private var enabled = false + @Throws(CommandException::class) + override fun processCommand(sender: ICommandSender, args: Array<String>) { + toggleControls() + } + + companion object { + private var enabled = false + + /** + * Method to do the brunt work of the command. This is separate, so I can also let the user set a + * keybind to do the same thing. + */ + fun toggleControls() { + val minecraft = Minecraft.getMinecraft() + val breakingKey: KeyBinding = minecraft.gameSettings.keyBindAttack + val jumpKey: KeyBinding = minecraft.gameSettings.keyBindJump + if (!enabled) { + KeyBinding.setKeyBindState(breakingKey.keyCode, false) + breakingKey.keyCode = 57 // 57 = space key code + + KeyBinding.setKeyBindState(jumpKey.keyCode, false) + jumpKey.keyCode = -100 // -100 = Left click key code + minecraft.gameSettings.mouseSensitivity = 0.0f + } else { + KeyBinding.setKeyBindState(breakingKey.keyCode, false) + breakingKey.keyCode = -100 // -100 = Left click key code + + KeyBinding.setKeyBindState(jumpKey.keyCode, false) + jumpKey.keyCode = 57 // 57 = space key code + minecraft.gameSettings.mouseSensitivity = Config.defaultSens / 2 + } + + // Save the changes to the control settings + minecraft.gameSettings.saveOptions() + minecraft.gameSettings.loadOptions() + + enabled = !enabled + TextUtils.toggledMessage("Farming Controls", enabled) + } + } +}
\ No newline at end of file diff --git a/src/main/kotlin/dulkirmod/command/HelpCommand.kt b/src/main/kotlin/dulkirmod/command/HelpCommand.kt index 2b7a9b0..7269d7a 100644 --- a/src/main/kotlin/dulkirmod/command/HelpCommand.kt +++ b/src/main/kotlin/dulkirmod/command/HelpCommand.kt @@ -11,5 +11,6 @@ class HelpCommand : ClientCommandBase("dulkirhelp") { TextUtils.info(" §7/enchantrune - toggles enchant rune visibility.", false) TextUtils.info(" §7/fairy - toggles healer fairy visibility.", false) TextUtils.info(" §7/hl - helps change highlighted leap player on the fly.", false) + TextUtils.info(" §7/farmcontrols - swaps some keybinds and adjusts sens to be better suited for farming", false) } }
\ No newline at end of file |