collect canPlaceAgainst into one place
This commit is contained in:
parent
d433cbb90b
commit
a3e5714e91
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user