collect canPlaceAgainst into one place

This commit is contained in:
Leijurv 2018-08-28 15:01:24 -07:00
parent d433cbb90b
commit a3e5714e91
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
3 changed files with 10 additions and 5 deletions

View File

@ -224,6 +224,12 @@ public interface MovementHelper extends ActionCosts, Helper {
return BlockStateInterface.get(pos).getBlock() instanceof BlockFalling;
}
static boolean canPlaceAgainst(BlockPos pos) {
IBlockState state = BlockStateInterface.get(pos);
// TODO isBlockNormalCube isn't the best check for whether or not we can place a block against it. e.g. glass isn't normalCube but we can place against it
return state.isBlockNormalCube();
}
static double getMiningDurationTicks(CalculationContext context, BlockPos position, boolean includeFalling) {
IBlockState state = BlockStateInterface.get(position);
return getMiningDurationTicks(context, position, state, includeFalling);

View File

@ -69,7 +69,7 @@ public class MovementAscend extends Movement {
if (against1.equals(src)) {
continue;
}
if (BlockStateInterface.get(against1).isBlockNormalCube()) {
if (MovementHelper.canPlaceAgainst(against1)) {
return JUMP_ONE_BLOCK_COST + WALK_ONE_BLOCK_COST + context.placeBlockCost() + getTotalHardnessOfBlocksToBreak(context);
}
}
@ -129,7 +129,7 @@ public class MovementAscend extends Movement {
if (anAgainst.equals(src)) {
continue;
}
if (BlockStateInterface.get(anAgainst).isBlockNormalCube()) {
if (MovementHelper.canPlaceAgainst(anAgainst)) {
if (!MovementHelper.throwaway(true)) {//get ready to place a throwaway block
return state.setStatus(MovementStatus.UNREACHABLE);
}

View File

@ -103,8 +103,7 @@ public class MovementTraverse extends Movement {
continue;
}
against1 = against1.down();
// TODO isBlockNormalCube isn't the best check for whether or not we can place a block against it. e.g. glass isn't normalCube but we can place against it
if (BlockStateInterface.get(against1).isBlockNormalCube()) {
if (MovementHelper.canPlaceAgainst(against1)) {
return WC + context.placeBlockCost() + getTotalHardnessOfBlocksToBreak(context);
}
}
@ -201,7 +200,7 @@ public class MovementTraverse extends Movement {
continue;
}
against1 = against1.down();
if (BlockStateInterface.get(against1).isBlockNormalCube()) {
if (MovementHelper.canPlaceAgainst(against1)) {
if (!MovementHelper.throwaway(true)) { // get ready to place a throwaway block
displayChatMessageRaw("bb pls get me some blocks. dirt or cobble");
return state.setStatus(MovementState.MovementStatus.UNREACHABLE);