Pathing is functioning
This commit is contained in:
parent
5b96e6cd57
commit
2f06857858
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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()) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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<Input, Boolean> inputState = new HashMap<>();
|
||||
|
||||
public MovementState setStatus(MovementStatus status) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user