Clean up Movement input behavior
This commit is contained in:
@@ -113,13 +113,12 @@ public abstract class Movement implements Helper, MovementHelper {
|
|||||||
latestState.getTarget().rotation.ifPresent(LookBehavior.INSTANCE::updateTarget);
|
latestState.getTarget().rotation.ifPresent(LookBehavior.INSTANCE::updateTarget);
|
||||||
//TODO calculate movement inputs from latestState.getGoal().position
|
//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.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) -> {
|
latestState.inputState.forEach((input, forced) -> Baritone.INSTANCE.getInputOverrideHandler().setInputForceState(input, forced));
|
||||||
Baritone.INSTANCE.getInputOverrideHandler().setInputForceState(input, forced);
|
latestState.inputState.replaceAll((input, forced) -> false);
|
||||||
});
|
|
||||||
currentState = latestState;
|
currentState = latestState;
|
||||||
|
|
||||||
if (isFinished())
|
if (isFinished())
|
||||||
onFinish();
|
onFinish(latestState);
|
||||||
|
|
||||||
return currentState.getStatus();
|
return currentState.getStatus();
|
||||||
}
|
}
|
||||||
@@ -133,8 +132,8 @@ public abstract class Movement implements Helper, MovementHelper {
|
|||||||
if(MovementHelper.canWalkThrough(blockPos, BlockStateInterface.get(blockPos))) {
|
if(MovementHelper.canWalkThrough(blockPos, BlockStateInterface.get(blockPos))) {
|
||||||
Optional<Rotation> reachable = LookBehaviorUtils.reachable(blockPos);
|
Optional<Rotation> reachable = LookBehaviorUtils.reachable(blockPos);
|
||||||
reachable.ifPresent(rotation -> {
|
reachable.ifPresent(rotation -> {
|
||||||
state.setTarget(new MovementState.MovementTarget(Optional.empty(), reachable));
|
state.setTarget(new MovementState.MovementTarget(Optional.empty(), reachable))
|
||||||
state.setInput(Input.CLICK_LEFT, true);
|
.setInput(Input.CLICK_LEFT, true);
|
||||||
});
|
});
|
||||||
if (reachable.isPresent())
|
if (reachable.isPresent())
|
||||||
return false;
|
return false;
|
||||||
@@ -158,9 +157,11 @@ public abstract class Movement implements Helper, MovementHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Run cleanup on state finish
|
* Run cleanup on state finish and declare success.
|
||||||
*/
|
*/
|
||||||
public abstract void onFinish();
|
public void onFinish(MovementState state) {
|
||||||
|
state.setStatus(MovementStatus.SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate latest movement state.
|
* Calculate latest movement state.
|
||||||
@@ -172,7 +173,6 @@ public abstract class Movement implements Helper, MovementHelper {
|
|||||||
if (!prepared(state))
|
if (!prepared(state))
|
||||||
return state.setStatus(MovementStatus.PREPPING);
|
return state.setStatus(MovementStatus.PREPPING);
|
||||||
else if (state.getStatus() == MovementStatus.PREPPING) {
|
else if (state.getStatus() == MovementStatus.PREPPING) {
|
||||||
state.setInput(Input.CLICK_LEFT, false);
|
|
||||||
state.setStatus(MovementStatus.WAITING);
|
state.setStatus(MovementStatus.WAITING);
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
|
|||||||
@@ -58,8 +58,9 @@ public class MovementState {
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTarget(MovementTarget target) {
|
public MovementState setTarget(MovementTarget target) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MovementState setInput(Input input, boolean forced) {
|
public MovementState setInput(Input input, boolean forced) {
|
||||||
@@ -72,6 +73,6 @@ public class MovementState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum MovementStatus {
|
public enum MovementStatus {
|
||||||
PREPPING, WAITING, RUNNING, SUCCESS, UNREACHABLE, FAILED;
|
PREPPING, WAITING, RUNNING, SUCCESS, UNREACHABLE, FAILED, FINISHING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user