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

99 lines
2.4 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 04:42:17 +00:00
private MovementTarget goal = new MovementTarget();
private MovementTarget target = new MovementTarget();
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 04:42:17 +00:00
public 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 04:42:17 +00:00
public Rotation rotation;
2018-08-02 08:15:51 +00:00
2018-08-06 04:42:17 +00:00
public MovementTarget() {
this(null, null);
}
public MovementTarget(Vec3d position) {
this(position, null);
}
public MovementTarget(Rotation rotation) {
this(null, rotation);
}
public MovementTarget(Vec3d position, Rotation rotation) {
this.position = position;
this.rotation = rotation;
2018-08-02 08:15:51 +00:00
}
2018-08-06 04:42:17 +00:00
public final Optional<Vec3d> getPosition() {
return Optional.of(this.position);
}
public final Optional<Rotation> getRotation() {
return Optional.of(this.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
}
}