Refactoring

This commit is contained in:
Howard Stark
2018-08-02 23:40:27 -04:00
parent 1f9dadce39
commit f6f057c8cb
10 changed files with 34 additions and 24 deletions

View File

@@ -7,13 +7,13 @@ package baritone.bot.event.events.type;
public enum EventState {
/**
* Indicates that whatever action the event is being
* Indicates that whatever movement the event is being
* dispatched as a result of is about to occur.
*/
PRE,
/**
* Indicates that whatever action the event is being
* Indicates that whatever movement the event is being
* dispatched as a result of has already occured.
*/
POST

View File

@@ -1,5 +1,9 @@
package baritone.bot.pathing.calc;
<<<<<<< Updated upstream
=======
import baritone.bot.pathing.movement.Movement;
>>>>>>> Stashed changes
import baritone.bot.pathing.goals.Goal;
import baritone.bot.pathing.movement.Movement;
import net.minecraft.util.math.BlockPos;

View File

@@ -45,7 +45,7 @@ public abstract class Movement implements AbstractGameEventListener, Helper, Mov
@Override
public void onTick() {
MovementState latestState = calcState();
MovementState latestState = updateState();
Optional<Vec3d> orientation = latestState.getGoal().rotation;
if (orientation.isPresent()) {
Tuple<Float, Float> rotation = Utils.calcRotationFromVec3d(mc.player.getPositionEyes(1.0F),
@@ -60,6 +60,7 @@ public abstract class Movement implements AbstractGameEventListener, Helper, Mov
currentState = latestState;
if (isFinished())
onFinish();
return;
}
@@ -76,11 +77,16 @@ public abstract class Movement implements AbstractGameEventListener, Helper, Mov
return dest;
}
/**
* Run cleanup on state finish
*/
public abstract void onFinish();
/**
* Calculate latest movement state.
* Gets called once a tick.
*
* @return
*/
public abstract MovementState calcState();
public abstract MovementState updateState();
}

View File

@@ -18,7 +18,7 @@ public class MovementAscend extends Movement {
}
@Override
public MovementState calcState() {
public MovementState updateState() {
MovementState latestState = currentState.setInput(InputOverrideHandler.Input.JUMP, true).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true);
if (playerFeet().equals(dest))
latestState.setStatus(MovementState.MovementStatus.SUCCESS);