From 0fb5f3233f4f1c2996550d40a0aa326294a0dbde Mon Sep 17 00:00:00 2001 From: Brady Date: Mon, 8 Oct 2018 23:52:36 -0500 Subject: [PATCH] MovementStatus javadocs --- .../api/pathing/movement/MovementStatus.java | 49 ++++++++++++++++++- .../baritone/pathing/movement/Movement.java | 9 +--- 2 files changed, 50 insertions(+), 8 deletions(-) diff --git a/src/api/java/baritone/api/pathing/movement/MovementStatus.java b/src/api/java/baritone/api/pathing/movement/MovementStatus.java index 6b5215ad..0190f8e1 100644 --- a/src/api/java/baritone/api/pathing/movement/MovementStatus.java +++ b/src/api/java/baritone/api/pathing/movement/MovementStatus.java @@ -23,5 +23,52 @@ package baritone.api.pathing.movement; */ public enum MovementStatus { - PREPPING, WAITING, RUNNING, SUCCESS, UNREACHABLE, FAILED, CANCELED + /** + * We are preparing the movement to be executed. This is when any blocks obstructing the destination are broken. + */ + PREPPING(false), + + /** + * We are waiting for the movement to begin, after {@link MovementStatus#PREPPING}. + */ + WAITING(false), + + /** + * The movement is currently in progress, after {@link MovementStatus#WAITING} + */ + RUNNING(false), + + /** + * The movement has been completed and we are at our destination + */ + SUCCESS(true), + + /** + * There was a change in state between calculation and actual + * movement execution, and the movement has now become impossible. + */ + UNREACHABLE(true), + + /** + * Unused + */ + FAILED(true), + + /** + * "Unused" + */ + CANCELED(true); + + /** + * Whether or not this status indicates a complete movement. + */ + private final boolean complete; + + MovementStatus(boolean complete) { + this.complete = complete; + } + + public final boolean isComplete() { + return this.complete; + } } diff --git a/src/main/java/baritone/pathing/movement/Movement.java b/src/main/java/baritone/pathing/movement/Movement.java index cffa28ee..92a1f4db 100644 --- a/src/main/java/baritone/pathing/movement/Movement.java +++ b/src/main/java/baritone/pathing/movement/Movement.java @@ -152,7 +152,8 @@ public abstract class Movement implements IMovement, Helper, MovementHelper { currentState = latestState; - if (isFinished()) { + // If the current status indicates a completed movement + if (currentState.getStatus().isComplete()) { onFinish(latestState); } @@ -201,12 +202,6 @@ public abstract class Movement implements IMovement, Helper, MovementHelper { return true; } - public boolean isFinished() { - return (currentState.getStatus() != MovementStatus.RUNNING - && currentState.getStatus() != MovementStatus.PREPPING - && currentState.getStatus() != MovementStatus.WAITING); - } - @Override public BetterBlockPos getSrc() { return src;