baritone/src/main/java/baritone/bot/pathing/movement/MovementState.java

79 lines
2.0 KiB
Java
Raw Normal View History

2018-08-02 21:28:35 +00:00
package baritone.bot.pathing.movement;
2018-08-02 08:15:51 +00:00
import baritone.bot.InputOverrideHandler.Input;
2018-08-06 00:37:42 +00:00
import baritone.bot.utils.Rotation;
2018-08-02 14:59:51 +00:00
import net.minecraft.util.math.Vec3d;
2018-08-02 08:15:51 +00:00
2018-08-02 13:20:35 +00:00
import java.util.HashMap;
2018-08-02 08:15:51 +00:00
import java.util.Map;
2018-08-06 00:37:42 +00:00
import java.util.Optional;
2018-08-02 08:15:51 +00:00
2018-08-02 21:28:35 +00:00
public class MovementState {
2018-08-02 08:15:51 +00:00
2018-08-04 18:49:52 +00:00
private MovementStatus status;
2018-08-06 01:52:55 +00:00
private MovementTarget goal = new MovementTarget(Optional.empty(), Optional.empty());
private MovementTarget target = new MovementTarget(Optional.empty(), Optional.empty());
2018-08-02 13:20:35 +00:00
protected final Map<Input, Boolean> inputState = new HashMap<>();
2018-08-02 08:15:51 +00:00
2018-08-02 21:28:35 +00:00
public MovementState setStatus(MovementStatus status) {
2018-08-02 08:15:51 +00:00
this.status = status;
return this;
}
2018-08-02 21:28:35 +00:00
public MovementStatus getStatus() {
2018-08-02 08:15:51 +00:00
return status;
}
2018-08-06 00:37:42 +00:00
public static class MovementTarget {
2018-08-02 08:15:51 +00:00
/**
* Necessary movement to achieve
* <p>
* TODO: Decide desiredMovement type
*/
2018-08-06 00:37:42 +00:00
public Optional<Vec3d> position;
2018-08-02 08:15:51 +00:00
/**
* Yaw and pitch angles that must be matched
* <p>
* getFirst() -> YAW
* getSecond() -> PITCH
*/
2018-08-06 00:37:42 +00:00
public Optional<Rotation> rotation;
2018-08-02 08:15:51 +00:00
public MovementTarget(Optional<Vec3d> position, Optional<Rotation> rotation) {
this.position = position;
this.rotation = rotation;
2018-08-02 08:15:51 +00:00
}
}
2018-08-06 00:37:42 +00:00
public MovementTarget getGoal() {
2018-08-02 08:15:51 +00:00
return goal;
}
2018-08-06 00:37:42 +00:00
public MovementState setGoal(MovementTarget goal) {
2018-08-04 18:49:52 +00:00
this.goal = goal;
2018-08-02 08:15:51 +00:00
return this;
}
2018-08-06 00:37:42 +00:00
public MovementTarget getTarget() {
return target;
}
2018-08-06 01:17:54 +00:00
public MovementState setTarget(MovementTarget target) {
2018-08-06 00:37:42 +00:00
this.target = target;
2018-08-06 01:17:54 +00:00
return this;
2018-08-06 00:37:42 +00:00
}
2018-08-02 21:28:35 +00:00
public MovementState setInput(Input input, boolean forced) {
2018-08-02 13:20:35 +00:00
inputState.put(input, forced);
2018-08-02 08:15:51 +00:00
return this;
}
2018-08-02 13:20:35 +00:00
public boolean getInput(Input input) {
return inputState.getOrDefault(input, false);
}
2018-08-02 21:28:35 +00:00
public enum MovementStatus {
2018-08-06 02:08:23 +00:00
PREPPING, WAITING, RUNNING, SUCCESS, UNREACHABLE, FAILED, CANCELED;
2018-08-02 08:15:51 +00:00
}
}