From 3012e97610fcfa76747449b961689ea26031f6ed Mon Sep 17 00:00:00 2001 From: Dominika Date: Mon, 25 May 2020 16:54:40 -0400 Subject: [PATCH] Added AutoMine --- .../kami/module/modules/misc/AutoMine.kt | 68 +++++++++++++++++++ .../kami/module/modules/misc/AutoTunnel.kt | 3 + 2 files changed, 71 insertions(+) create mode 100644 src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoMine.kt diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoMine.kt b/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoMine.kt new file mode 100644 index 000000000..9a7a6cac8 --- /dev/null +++ b/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoMine.kt @@ -0,0 +1,68 @@ +package me.zeroeightsix.kami.module.modules.misc + +import baritone.api.BaritoneAPI +import me.zeroeightsix.kami.command.Command +import me.zeroeightsix.kami.module.Module +import me.zeroeightsix.kami.setting.Setting +import me.zeroeightsix.kami.setting.Settings +import me.zeroeightsix.kami.util.MessageSendHelper + +/** + * @author dominikaaaa + */ +@Module.Info( + name = "AutoMine", + description = "Automatically mines chosen ores", + category = Module.Category.MISC +) +class AutoMine : Module() { + private var iron = register(Settings.b("Iron", true)) + private var diamond = register(Settings.b("Diamond", true)) + private var gold = register(Settings.b("Gold", false)) + private var coal = register(Settings.b("Coal", false)) + private var log = register(Settings.b("Logs", false)) + + init { + iron.settingListener = Setting.SettingListeners { if (mc.player != null && isEnabled) run() } + diamond.settingListener = Setting.SettingListeners { if (mc.player != null && isEnabled) run() } + gold.settingListener = Setting.SettingListeners { if (mc.player != null && isEnabled) run() } + coal.settingListener = Setting.SettingListeners { if (mc.player != null && isEnabled) run() } + log.settingListener = Setting.SettingListeners { if (mc.player != null && isEnabled) run() } + } + + override fun onEnable() { + if (mc.player == null) { + disable() + return + } + run() + } + + private fun run() { + var current = "" + if (iron.value) current += " iron_ore" + if (diamond.value) current += " diamond_ore" + if (gold.value) current += " gold_ore" + if (coal.value) current += " coal_ore" + if (log.value) current += " log" + + if (current.startsWith(" ")) { + current = current.substring(1) + } + val total = current.split(" ") + + if (current.length < 2) { + MessageSendHelper.sendBaritoneMessage("Error: you have to choose at least one thing to mine. To mine custom blocks run the &7" + Command.getCommandPrefix() + "b mine block&f command") + BaritoneAPI.getProvider().primaryBaritone.pathingBehavior.cancelEverything() + return + } + + MessageSendHelper.sendBaritoneCommand("mine", *total.toTypedArray()) + } + + override fun onDisable() { + mc.player?.let { + BaritoneAPI.getProvider().primaryBaritone.pathingBehavior.cancelEverything() + } + } +} \ No newline at end of file diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoTunnel.kt b/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoTunnel.kt index 1da47ec6f..27adfaf32 100644 --- a/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoTunnel.kt +++ b/src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoTunnel.kt @@ -10,6 +10,9 @@ import me.zeroeightsix.kami.util.MathsUtils.CardinalMain import me.zeroeightsix.kami.util.MathsUtils.getPlayerMainCardinal import me.zeroeightsix.kami.util.MessageSendHelper +/** + * @author dominikaaaa + */ @Module.Info( name = "AutoTunnel", description = "Automatically tunnels forward, at a given size",