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

use baritone process for pausing #4150

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 @@ -9,6 +9,9 @@
import baritone.api.pathing.goals.Goal;
import baritone.api.pathing.goals.GoalGetToBlock;
import baritone.api.pathing.goals.GoalXZ;
import baritone.api.process.IBaritoneProcess;
import baritone.api.process.PathingCommand;
import baritone.api.process.PathingCommandType;
import baritone.api.utils.Rotation;
import baritone.api.utils.SettingsUtil;
import meteordevelopment.meteorclient.MeteorClient;
Expand All @@ -31,6 +34,7 @@ public class BaritonePathManager implements IPathManager {
private final Settings settings;

private GoalDirection directionGoal;
private boolean pathingPaused;

public BaritonePathManager() {
// Subscribe to event bus
Expand All @@ -53,6 +57,9 @@ public BaritonePathManager() {

// Create settings
settings = new Settings();

// Baritone pathing control
BaritoneAPI.getProvider().getPrimaryBaritone().getPathingControlManager().registerProcess(new BaritoneProcess());
}

@Override
Expand All @@ -62,12 +69,12 @@ public boolean isPathing() {

@Override
public void pause() {
BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("pause");
pathingPaused = true;
}

@Override
public void resume() {
BaritoneAPI.getProvider().getPrimaryBaritone().getCommandManager().execute("resume");
pathingPaused = false;
}

@Override
Expand Down Expand Up @@ -249,4 +256,36 @@ public int getZ() {
return this.z;
}
}

private class BaritoneProcess implements IBaritoneProcess {
@Override
public boolean isActive() {
return pathingPaused;
}

@Override
public PathingCommand onTick(boolean b, boolean b1) {
BaritoneAPI.getProvider().getPrimaryBaritone().getInputOverrideHandler().clearAllKeys();
return new PathingCommand(null, PathingCommandType.REQUEST_PAUSE);
}

@Override
public boolean isTemporary() {
return true;
}

@Override
public void onLostControl() {
}

@Override
public double priority() {
return 0d;
}

@Override
public String displayName0() {
return "Meteor Client";
}
}
}