mostRecentGoal, fixes immediate goal clear

This commit is contained in:
Brady
2023-07-07 18:35:02 -07:00
parent fe67489419
commit 487b3a759a
3 changed files with 17 additions and 1 deletions

View File

@@ -42,7 +42,7 @@ public class ElytraCommand extends Command {
public void execute(String label, IArgConsumer args) throws CommandException {
ICustomGoalProcess customGoalProcess = baritone.getCustomGoalProcess();
args.requireMax(0);
Goal iGoal = customGoalProcess.getGoal();
Goal iGoal = customGoalProcess.mostRecentGoal();
if (iGoal == null) {
throw new CommandInvalidStateException("No goal has been set");
}

View File

@@ -36,6 +36,11 @@ public final class CustomGoalProcess extends BaritoneProcessHelper implements IC
*/
private Goal goal;
/**
* The most recent goal. Not invalidated upon {@link #onLostControl()}
*/
private Goal mostRecentGoal;
/**
* The current process state.
*
@@ -50,6 +55,7 @@ public final class CustomGoalProcess extends BaritoneProcessHelper implements IC
@Override
public void setGoal(Goal goal) {
this.goal = goal;
this.mostRecentGoal = goal;
if (this.state == State.NONE) {
this.state = State.GOAL_SET;
}
@@ -68,6 +74,11 @@ public final class CustomGoalProcess extends BaritoneProcessHelper implements IC
return this.goal;
}
@Override
public Goal mostRecentGoal() {
return this.mostRecentGoal;
}
@Override
public boolean isActive() {
return this.state != State.NONE;