Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pause AutoWalk when opposite movement key is pressed #271

Merged
merged 2 commits into from
Apr 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ object AutoWalk : Module(
) {
private val mode = setting("Direction", AutoWalkMode.BARITONE)
private val disableOnDisconnect by setting("Disable On Disconnect", true)
private var pauseOnBackwards by setting("Pause on opposite movement", true)

private enum class AutoWalkMode(override val displayName: String) : DisplayEnum {
FORWARD("Forward"),
Expand Down Expand Up @@ -73,21 +74,24 @@ object AutoWalk : Module(

if (it.movementInput !is MovementInputFromOptions) return@listener

when (mode.value) {
it.movementInput.moveForward = when (mode.value) {
AutoWalkMode.FORWARD -> {
it.movementInput.moveForward = 1.0f
if (pauseOnBackwards && mc.gameSettings.keyBindBack.isKeyDown) 0.0f else 1.0f
}
AutoWalkMode.BACKWARD -> {
it.movementInput.moveForward = -1.0f
if (pauseOnBackwards && mc.gameSettings.keyBindForward.isKeyDown) 0.0f else -1.0f
}
else -> {
// Baritone mode
0.0f
}
}
}

safeListener<TickEvent.ClientTickEvent> {
if (mode.value == AutoWalkMode.BARITONE && !checkBaritoneElytra() && !isActive()) {
if (mode.value == AutoWalkMode.BARITONE
&& !checkBaritoneElytra()
&& !isActive()
) {
startPathing()
}
}
Expand Down