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-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-02 22:35:36 +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-02 21:28:35 +00:00
|
|
|
protected MovementStatus status;
|
2018-08-02 22:35:36 +00:00
|
|
|
public MovementGoal goal = new MovementGoal();
|
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-02 21:28:35 +00:00
|
|
|
public static class MovementGoal {
|
2018-08-02 08:15:51 +00:00
|
|
|
/**
|
|
|
|
* Necessary movement to achieve
|
|
|
|
* <p>
|
|
|
|
* TODO: Decide desiredMovement type
|
|
|
|
*/
|
2018-08-02 22:35:36 +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-02 22:35:36 +00:00
|
|
|
public Optional<Vec3d> rotation;
|
2018-08-02 08:15:51 +00:00
|
|
|
|
2018-08-02 22:35:36 +00:00
|
|
|
public MovementGoal() {
|
|
|
|
this.position = Optional.empty();
|
|
|
|
this.rotation = Optional.empty();
|
2018-08-02 08:15:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-02 21:28:35 +00:00
|
|
|
public MovementGoal getGoal() {
|
2018-08-02 08:15:51 +00:00
|
|
|
return goal;
|
|
|
|
}
|
|
|
|
|
2018-08-02 22:35:36 +00:00
|
|
|
public MovementState setPosition(Vec3d posGoal) {
|
|
|
|
this.goal.position = Optional.of(posGoal);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public MovementState clearPosition() {
|
|
|
|
this.goal.position = Optional.empty();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public MovementState setLookDirection(Vec3d rotGoal) {
|
|
|
|
this.goal.rotation = Optional.of(rotGoal);
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public MovementState clearLookDirection() {
|
|
|
|
this.goal.rotation = Optional.empty();
|
2018-08-02 08:15:51 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
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-02 08:15:51 +00:00
|
|
|
WAITING, RUNNING, SUCCESS, UNREACHABLE, FAILED;
|
|
|
|
}
|
|
|
|
}
|