[fix] AutoWalk starts pathing when toggles mode and disabled, readable mode name on ModuleList

This commit is contained in:
Xiaro 2021-01-19 13:29:39 -05:00
parent a8b807dd25
commit 7cede5af7f
No known key found for this signature in database
GPG Key ID: 996D265D6E155377
1 changed files with 8 additions and 5 deletions

View File

@ -18,6 +18,7 @@ import net.minecraft.util.MovementInputFromOptions
import net.minecraftforge.client.event.InputUpdateEvent import net.minecraftforge.client.event.InputUpdateEvent
import net.minecraftforge.fml.common.gameevent.TickEvent import net.minecraftforge.fml.common.gameevent.TickEvent
import org.kamiblue.commons.extension.floorToInt import org.kamiblue.commons.extension.floorToInt
import org.kamiblue.commons.interfaces.DisplayEnum
import org.kamiblue.event.listener.listener import org.kamiblue.event.listener.listener
internal object AutoWalk : Module( internal object AutoWalk : Module(
@ -28,8 +29,10 @@ internal object AutoWalk : Module(
private val mode = setting("Direction", AutoWalkMode.BARITONE) private val mode = setting("Direction", AutoWalkMode.BARITONE)
private val disableOnDisconnect by setting("DisableOnDisconnect", true) private val disableOnDisconnect by setting("DisableOnDisconnect", true)
private enum class AutoWalkMode { private enum class AutoWalkMode(override val displayName: String): DisplayEnum {
FORWARD, BACKWARDS, BARITONE FORWARD("Forward"),
BACKWARD("Backward"),
BARITONE("Baritone")
} }
val baritoneWalk get() = isEnabled && mode.value == AutoWalkMode.BARITONE val baritoneWalk get() = isEnabled && mode.value == AutoWalkMode.BARITONE
@ -46,7 +49,7 @@ internal object AutoWalk : Module(
return if (mode.value == AutoWalkMode.BARITONE && (BaritoneUtils.isActive || BaritoneUtils.isPathing)) { return if (mode.value == AutoWalkMode.BARITONE && (BaritoneUtils.isActive || BaritoneUtils.isPathing)) {
direction.displayName direction.displayName
} else { } else {
mode.value.name mode.value.displayName
} }
} }
@ -74,7 +77,7 @@ internal object AutoWalk : Module(
AutoWalkMode.FORWARD -> { AutoWalkMode.FORWARD -> {
it.movementInput.moveForward = 1.0f it.movementInput.moveForward = 1.0f
} }
AutoWalkMode.BACKWARDS -> { AutoWalkMode.BACKWARD -> {
it.movementInput.moveForward = -1.0f it.movementInput.moveForward = -1.0f
} }
else -> { else -> {
@ -111,7 +114,7 @@ internal object AutoWalk : Module(
init { init {
mode.listeners.add { mode.listeners.add {
if (mc.player == null) return@add if (isDisabled || mc.player == null) return@add
if (mode.value == AutoWalkMode.BARITONE) { if (mode.value == AutoWalkMode.BARITONE) {
if (!checkBaritoneElytra()) { if (!checkBaritoneElytra()) {
runSafe { startPathing() } runSafe { startPathing() }