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;
|
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) {
|
static double getMiningDurationTicks(CalculationContext context, BlockPos position, boolean includeFalling) {
|
||||||
IBlockState state = BlockStateInterface.get(position);
|
IBlockState state = BlockStateInterface.get(position);
|
||||||
return getMiningDurationTicks(context, position, state, includeFalling);
|
return getMiningDurationTicks(context, position, state, includeFalling);
|
||||||
|
@ -69,7 +69,7 @@ public class MovementAscend extends Movement {
|
|||||||
if (against1.equals(src)) {
|
if (against1.equals(src)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (BlockStateInterface.get(against1).isBlockNormalCube()) {
|
if (MovementHelper.canPlaceAgainst(against1)) {
|
||||||
return JUMP_ONE_BLOCK_COST + WALK_ONE_BLOCK_COST + context.placeBlockCost() + getTotalHardnessOfBlocksToBreak(context);
|
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)) {
|
if (anAgainst.equals(src)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (BlockStateInterface.get(anAgainst).isBlockNormalCube()) {
|
if (MovementHelper.canPlaceAgainst(anAgainst)) {
|
||||||
if (!MovementHelper.throwaway(true)) {//get ready to place a throwaway block
|
if (!MovementHelper.throwaway(true)) {//get ready to place a throwaway block
|
||||||
return state.setStatus(MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementStatus.UNREACHABLE);
|
||||||
}
|
}
|
||||||
|
@ -103,8 +103,7 @@ public class MovementTraverse extends Movement {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
against1 = against1.down();
|
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 (MovementHelper.canPlaceAgainst(against1)) {
|
||||||
if (BlockStateInterface.get(against1).isBlockNormalCube()) {
|
|
||||||
return WC + context.placeBlockCost() + getTotalHardnessOfBlocksToBreak(context);
|
return WC + context.placeBlockCost() + getTotalHardnessOfBlocksToBreak(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -201,7 +200,7 @@ public class MovementTraverse extends Movement {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
against1 = against1.down();
|
against1 = against1.down();
|
||||||
if (BlockStateInterface.get(against1).isBlockNormalCube()) {
|
if (MovementHelper.canPlaceAgainst(against1)) {
|
||||||
if (!MovementHelper.throwaway(true)) { // get ready to place a throwaway block
|
if (!MovementHelper.throwaway(true)) { // get ready to place a throwaway block
|
||||||
displayChatMessageRaw("bb pls get me some blocks. dirt or cobble");
|
displayChatMessageRaw("bb pls get me some blocks. dirt or cobble");
|
||||||
return state.setStatus(MovementState.MovementStatus.UNREACHABLE);
|
return state.setStatus(MovementState.MovementStatus.UNREACHABLE);
|
||||||
|
Loading…
Reference in New Issue
Block a user