Merge branch 'master' into parkour

This commit is contained in:
Leijurv 2018-09-07 20:45:10 -07:00
commit 5ffd21dddc
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
10 changed files with 27 additions and 61 deletions

View File

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

View File

@ -294,7 +294,11 @@ public interface MovementHelper extends ActionCosts, Helper {
return COST_INF; return COST_INF;
} }
double m = Blocks.CRAFTING_TABLE.equals(block) ? 10 : 1; // TODO see if this is still necessary. it's from MineBot when we wanted to penalize breaking its crafting table double m = Blocks.CRAFTING_TABLE.equals(block) ? 10 : 1; // TODO see if this is still necessary. it's from MineBot when we wanted to penalize breaking its crafting table
double result = m / context.getToolSet().getStrVsBlock(state); double strVsBlock = context.getToolSet().getStrVsBlock(state);
if (strVsBlock < 0)
return COST_INF;
double result = m / strVsBlock;
if (includeFalling) { if (includeFalling) {
BlockPos up = position.up(); BlockPos up = position.up();
IBlockState above = BlockStateInterface.get(up); IBlockState above = BlockStateInterface.get(up);

View File

@ -123,14 +123,8 @@ public class MovementAscend extends Movement {
super.updateState(state); 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 // 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) // 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()) { if (state.getStatus() != MovementStatus.RUNNING)
case WAITING:
state.setStatus(MovementStatus.RUNNING);
case RUNNING:
break;
default:
return state; return state;
}
if (playerFeet().equals(dest)) { if (playerFeet().equals(dest)) {
return state.setStatus(MovementStatus.SUCCESS); return state.setStatus(MovementStatus.SUCCESS);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -77,7 +77,7 @@ public class ToolSet implements Helper {
/** /**
* Calculates how long would it take to mine the specified block given the best tool * Calculates how long would it take to mine the specified block given the best tool
* in this toolset is used. * in this toolset is used. A negative value is returned if the specified block is unbreakable.
* *
* @param state the blockstate to be mined * @param state the blockstate to be mined
* @return how long it would take in ticks * @return how long it would take in ticks
@ -87,9 +87,8 @@ public class ToolSet implements Helper {
ItemStack contents = player().inventory.getStackInSlot(slot); ItemStack contents = player().inventory.getStackInSlot(slot);
float blockHard = state.getBlockHardness(null, null); float blockHard = state.getBlockHardness(null, null);
if (blockHard < 0) { if (blockHard < 0)
return 0; return -1;
}
float speed = contents.getDestroySpeed(state); float speed = contents.getDestroySpeed(state);
if (speed > 1) { if (speed > 1) {