1
0
mirror of https://github.com/cabaletta/baritone synced 2024-12-26 17:02:24 +00:00

Merge pull request #96 from cabaletta/movement-duplicate-switch

Cleaned up 7 duplicate switch statements
This commit is contained in:
Brady 2018-09-07 19:43:26 -05:00 committed by GitHub
commit 392395446d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 19 additions and 56 deletions

View File

@ -270,6 +270,11 @@ public abstract class Movement implements Helper, MovementHelper {
} else if (state.getStatus() == MovementStatus.PREPPING) {
state.setStatus(MovementStatus.WAITING);
}
if (state.getStatus() == MovementStatus.WAITING) {
state.setStatus(MovementStatus.RUNNING);
}
return state;
}

View File

@ -123,14 +123,8 @@ public class MovementAscend extends Movement {
super.updateState(state);
// TODO incorporate some behavior from ActionClimb (specifically how it waited until it was at most 1.2 blocks away before starting to jump
// for efficiency in ascending minimal height staircases, which is just repeated MovementAscend, so that it doesn't bonk its head on the ceiling repeatedly)
switch (state.getStatus()) {
case WAITING:
state.setStatus(MovementStatus.RUNNING);
case RUNNING:
break;
default:
return state;
}
if (state.getStatus() != MovementStatus.RUNNING)
return state;
if (playerFeet().equals(dest)) {
return state.setStatus(MovementStatus.SUCCESS);

View File

@ -67,14 +67,8 @@ public class MovementDescend extends Movement {
@Override
public MovementState updateState(MovementState state) {
super.updateState(state);
switch (state.getStatus()) {
case WAITING:
state.setStatus(MovementStatus.RUNNING);
case RUNNING:
break;
default:
return state;
}
if (state.getStatus() != MovementStatus.RUNNING)
return state;
BlockPos playerFeet = playerFeet();
if (playerFeet.equals(dest)) {

View File

@ -119,14 +119,8 @@ public class MovementDiagonal extends Movement {
@Override
public MovementState updateState(MovementState state) {
super.updateState(state);
switch (state.getStatus()) {
case WAITING:
state.setStatus(MovementState.MovementStatus.RUNNING);
case RUNNING:
break;
default:
return state;
}
if (state.getStatus() != MovementState.MovementStatus.RUNNING)
return state;
if (playerFeet().equals(dest)) {
state.setStatus(MovementState.MovementStatus.SUCCESS);

View File

@ -60,14 +60,8 @@ public class MovementDownward extends Movement {
@Override
public MovementState updateState(MovementState state) {
super.updateState(state);
switch (state.getStatus()) {
case WAITING:
state.setStatus(MovementState.MovementStatus.RUNNING);
case RUNNING:
break;
default:
return state;
}
if (state.getStatus() != MovementState.MovementStatus.RUNNING)
return state;
if (playerFeet().equals(dest)) {
state.setStatus(MovementState.MovementStatus.SUCCESS);

View File

@ -96,14 +96,8 @@ public class MovementFall extends Movement {
@Override
public MovementState updateState(MovementState state) {
super.updateState(state);
switch (state.getStatus()) {
case WAITING:
state.setStatus(MovementStatus.RUNNING);
case RUNNING:
break;
default:
return state;
}
if (state.getStatus() != MovementStatus.RUNNING)
return state;
BlockPos playerFeet = playerFeet();
Rotation targetRotation = null;

View File

@ -121,14 +121,8 @@ public class MovementPillar extends Movement {
@Override
public MovementState updateState(MovementState state) {
super.updateState(state);
switch (state.getStatus()) {
case WAITING:
state.setStatus(MovementState.MovementStatus.RUNNING);
case RUNNING:
break;
default:
return state;
}
if (state.getStatus() != MovementState.MovementStatus.RUNNING)
return state;
IBlockState fromDown = BlockStateInterface.get(src);
boolean ladder = fromDown.getBlock() instanceof BlockLadder || fromDown.getBlock() instanceof BlockVine;

View File

@ -125,14 +125,8 @@ public class MovementTraverse extends Movement {
@Override
public MovementState updateState(MovementState state) {
super.updateState(state);
switch (state.getStatus()) {
case WAITING:
state.setStatus(MovementState.MovementStatus.RUNNING);
case RUNNING:
break;
default:
return state;
}
if (state.getStatus() != MovementState.MovementStatus.RUNNING)
return state;
state.setInput(InputOverrideHandler.Input.SNEAK, false);