allow some break and fall

This commit is contained in:
Leijurv 2018-08-13 08:28:43 -07:00
parent a311829605
commit 2bf09cc5a3
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
2 changed files with 23 additions and 7 deletions

View File

@ -217,12 +217,21 @@ public interface MovementHelper extends ActionCosts, Helper {
static Movement generateMovementFallOrDescend(BlockPos pos, EnumFacing direction, CalculationContext calcContext) {
BlockPos dest = pos.offset(direction);
for (int i = 0; i < 4; i++) {
if (!(BlockStateInterface.get(dest.down(i - 1)).getBlock() instanceof BlockAir)) {
//if any of these four aren't air, that means that a fall N isn't possible
//so try a movementdescend
// A
//SA
// B
// B
// C
// D
//if S is where you start, both of B need to be air for a movementfall
//A is plausibly breakable by either descend or fall
//C, D, etc determine the length of the fall
for (int i = 1; i < 3; i++) {
if (!canWalkThrough(dest.down(i))) {
//if any of these two (B in the diagram) aren't air
//have to do a descend, because fall is impossible
//if all four of them are air, a movementdescend isn't possible anyway
//this doesn't guarantee descend is possible, it just guarantees fall is impossible
return new MovementDescend(pos, dest.down()); // standard move out by 1 and descend by 1
}
}

View File

@ -50,10 +50,17 @@ public class MovementFall extends Movement {
if (!BlockStateInterface.isWater(dest) && src.getY() - dest.getY() > 3) {
placeBucketCost = ActionCosts.PLACE_ONE_BLOCK_COST;
}
if (getTotalHardnessOfBlocksToBreak(context.getToolSet()) != 0) {
double frontTwo = MovementHelper.getMiningDurationTicks(context.getToolSet(), positionsToBreak[0]) + MovementHelper.getMiningDurationTicks(context.getToolSet(), positionsToBreak[1]);
if (frontTwo >= COST_INF) {
return COST_INF;
}
return WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[positionsToBreak.length - 1] + placeBucketCost;
for (int i = 2; i < positionsToBreak.length; i++) {
if (MovementHelper.getMiningDurationTicks(context.getToolSet(), positionsToBreak[i]) > 0) {
//can't break while falling
return COST_INF;
}
}
return WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[positionsToBreak.length - 1] + placeBucketCost + frontTwo;
}
@Override