diff --git a/src/main/java/baritone/bot/Baritone.java b/src/main/java/baritone/bot/Baritone.java index 8dbfc1884..48f874df7 100755 --- a/src/main/java/baritone/bot/Baritone.java +++ b/src/main/java/baritone/bot/Baritone.java @@ -1,6 +1,7 @@ package baritone.bot; import baritone.bot.behavior.Behavior; +import baritone.bot.behavior.impl.LookBehavior; import baritone.bot.behavior.impl.PathingBehavior; import java.util.ArrayList; @@ -42,6 +43,7 @@ public enum Baritone { this.inputOverrideHandler = new InputOverrideHandler(); this.behaviors = new ArrayList<>(); behaviors.add(PathingBehavior.INSTANCE); + behaviors.add(LookBehavior.INSTANCE); this.active = true; this.initialized = true; diff --git a/src/main/java/baritone/bot/InputOverrideHandler.java b/src/main/java/baritone/bot/InputOverrideHandler.java index 5c95c8eaa..090bd5c8e 100755 --- a/src/main/java/baritone/bot/InputOverrideHandler.java +++ b/src/main/java/baritone/bot/InputOverrideHandler.java @@ -46,6 +46,8 @@ public final class InputOverrideHandler implements Helper { * @param forced Whether or not the state is being forced */ public final void setInputForceState(Input input, boolean forced) { + if(!forced) + System.out.println(input); inputForceStateMap.put(input.getKeyBinding(), forced); } diff --git a/src/main/java/baritone/bot/behavior/impl/LookBehavior.java b/src/main/java/baritone/bot/behavior/impl/LookBehavior.java index b0e9a7b6b..191cc1f11 100644 --- a/src/main/java/baritone/bot/behavior/impl/LookBehavior.java +++ b/src/main/java/baritone/bot/behavior/impl/LookBehavior.java @@ -1,6 +1,7 @@ package baritone.bot.behavior.impl; import baritone.bot.behavior.Behavior; +import baritone.bot.event.events.TickEvent; import baritone.bot.utils.Rotation; import java.util.Optional; @@ -25,6 +26,11 @@ public class LookBehavior extends Behavior { this.target = Optional.of(target); } + @Override + public void onTick(TickEvent event) { + this.onPlayerUpdate(); + } + @Override public void onPlayerUpdate() { if(target.isPresent()) { diff --git a/src/main/java/baritone/bot/pathing/movement/Movement.java b/src/main/java/baritone/bot/pathing/movement/Movement.java index b8e347399..9bc5aff55 100644 --- a/src/main/java/baritone/bot/pathing/movement/Movement.java +++ b/src/main/java/baritone/bot/pathing/movement/Movement.java @@ -112,8 +112,11 @@ public abstract class Movement implements Helper, MovementHelper { MovementState latestState = updateState(currentState); latestState.getTarget().rotation.ifPresent(LookBehavior.INSTANCE::updateTarget); //TODO calculate movement inputs from latestState.getGoal().position - latestState.getTarget().position.ifPresent(null); // NULL CONSUMER REALLY SHOULDN'T BE THE FINAL THING YOU SHOULD REALLY REPLACE THIS WITH ALMOST ACTUALLY ANYTHING ELSE JUST PLEASE DON'T LEAVE IT AS IT IS THANK YOU KANYE - latestState.inputState.forEach((input, forced) -> Baritone.INSTANCE.getInputOverrideHandler().setInputForceState(input, forced)); + //latestState.getTarget().position.ifPresent(null); NULL CONSUMER REALLY SHOULDN'T BE THE FINAL THING YOU SHOULD REALLY REPLACE THIS WITH ALMOST ACTUALLY ANYTHING ELSE JUST PLEASE DON'T LEAVE IT AS IT IS THANK YOU KANYE + latestState.inputState.forEach((input, forced) -> { + Baritone.INSTANCE.getInputOverrideHandler().setInputForceState(input, forced); + System.out.println(input + " AND " + forced); + }); latestState.inputState.replaceAll((input, forced) -> false); currentState = latestState; @@ -160,6 +163,8 @@ public abstract class Movement implements Helper, MovementHelper { * Run cleanup on state finish and declare success. */ public void onFinish(MovementState state) { + state.inputState.replaceAll((input, forced) -> false); + state.inputState.forEach((input, forced) -> Baritone.INSTANCE.getInputOverrideHandler().setInputForceState(input, forced)); state.setStatus(MovementStatus.SUCCESS); } diff --git a/src/main/java/baritone/bot/pathing/movement/MovementState.java b/src/main/java/baritone/bot/pathing/movement/MovementState.java index bfc7fb23e..ee67ac8dd 100644 --- a/src/main/java/baritone/bot/pathing/movement/MovementState.java +++ b/src/main/java/baritone/bot/pathing/movement/MovementState.java @@ -11,8 +11,8 @@ import java.util.Optional; public class MovementState { private MovementStatus status; - private MovementTarget goal; - private MovementTarget target; + private MovementTarget goal = new MovementTarget(Optional.empty(), Optional.empty()); + private MovementTarget target = new MovementTarget(Optional.empty(), Optional.empty()); protected final Map inputState = new HashMap<>(); public MovementState setStatus(MovementStatus status) { diff --git a/src/main/java/baritone/bot/pathing/movement/movements/MovementAscend.java b/src/main/java/baritone/bot/pathing/movement/movements/MovementAscend.java index a5da2b97c..6c5ed32c9 100644 --- a/src/main/java/baritone/bot/pathing/movement/movements/MovementAscend.java +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementAscend.java @@ -73,11 +73,14 @@ public class MovementAscend extends Movement { return state; case WAITING: case RUNNING: - state.setTarget(new MovementState.MovementTarget(Optional.empty(), Optional.of(Utils.calcRotationFromCoords(playerFeet(), positionsToBreak[0])))); + if (playerFeet().equals(dest)) { + state.setStatus(MovementStatus.SUCCESS); + return state; + } - MovementState latestState = state.setInput(InputOverrideHandler.Input.JUMP, true).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); - if (playerFeet().equals(dest)) - latestState.setStatus(MovementStatus.SUCCESS); + state.setTarget(new MovementState.MovementTarget(Optional.empty(), Optional.of(Utils.calcRotationFromCoords(playerFeet(), positionsToBreak[0])))); + state.setInput(InputOverrideHandler.Input.JUMP, true).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); + return state; default: return state; } diff --git a/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java b/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java index 9e7865a54..78c61f4e6 100644 --- a/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java +++ b/src/main/java/baritone/bot/pathing/movement/movements/MovementTraverse.java @@ -93,10 +93,13 @@ public class MovementTraverse extends Movement { return state; case WAITING: case RUNNING: - state.setTarget(new MovementState.MovementTarget(Optional.empty(), Optional.of(Utils.calcRotationFromCoords(playerFeet(), positionsToBreak[0])))); - MovementState latestState = state.setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); - if (playerFeet().equals(dest)) - latestState.setStatus(MovementState.MovementStatus.SUCCESS); + if (playerFeet().equals(dest)) { + state.setStatus(MovementState.MovementStatus.SUCCESS); + return state; + } + state.setTarget(new MovementState.MovementTarget(Optional.empty(), Optional.of(Utils.calcRotationFromCoords(playerFeet(), positionsToBreak[1])))).setInput(InputOverrideHandler.Input.MOVE_FORWARD, true); + return state; + default: return state; }