Skip to content
This repository has been archived by the owner on Apr 22, 2021. It is now read-only.

Commit

Permalink
Added AutoMine
Browse files Browse the repository at this point in the history
  • Loading branch information
5HT2 committed May 25, 2020
1 parent a759b25 commit 3012e97
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
68 changes: 68 additions & 0 deletions src/main/java/me/zeroeightsix/kami/module/modules/misc/AutoMine.kt
Original file line number Diff line number Diff line change
@@ -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()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 3012e97

Please sign in to comment.