extend MovementFall breakability one more, fixes #97

This commit is contained in:
Leijurv
2018-08-26 08:31:03 -07:00
parent e8c644fc63
commit 5f6a5ea403
2 changed files with 17 additions and 14 deletions

View File

@@ -304,22 +304,22 @@ public interface MovementHelper extends ActionCosts, Helper {
static Movement generateMovementFallOrDescend(BlockPos pos, BlockPos dest, CalculationContext calcContext) { static Movement generateMovementFallOrDescend(BlockPos pos, BlockPos dest, CalculationContext calcContext) {
// A // A
//SA //SA
// B // A
// B // B
// C // C
// D // D
//if S is where you start, both of B need to be air for a movementfall //if S is where you start, B needs to be air for a movementfall
//A is plausibly breakable by either descend or fall //A is plausibly breakable by either descend or fall
//C, D, etc determine the length of the 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
//this doesn't guarantee descend is possible, it just guarantees fall is impossible if (!canWalkThrough(dest.down(2))) {
return new MovementDescend(pos, dest.down()); // standard move out by 1 and descend by 1 //if B in the diagram aren't air
} //have to do a descend, because fall is impossible
//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
} }
// we're clear for a fall 2 // we're clear for a fall 2
// let's see how far we can fall // let's see how far we can fall
for (int fallHeight = 3; true; fallHeight++) { for (int fallHeight = 3; true; fallHeight++) {

View File

@@ -56,14 +56,17 @@ public class MovementFall extends Movement {
} }
placeBucketCost = context.placeBlockCost(); placeBucketCost = context.placeBlockCost();
} }
double frontTwo = MovementHelper.getMiningDurationTicks(context, positionsToBreak[0]) + MovementHelper.getMiningDurationTicks(context, positionsToBreak[1]); double frontThree = 0;
if (frontTwo >= COST_INF) { for (int i = 0; i < 3; i++) {
return COST_INF; frontThree += MovementHelper.getMiningDurationTicks(context, positionsToBreak[i]);
if (frontThree >= COST_INF) {
return COST_INF;
}
} }
if (BlockStateInterface.get(positionsToBreak[0].up()).getBlock() instanceof BlockFalling) { if (BlockStateInterface.get(positionsToBreak[0].up()).getBlock() instanceof BlockFalling) {
return COST_INF; return COST_INF;
} }
for (int i = 2; i < positionsToBreak.length; i++) { for (int i = 3; i < positionsToBreak.length; i++) {
// TODO is this the right check here? // TODO is this the right check here?
// MiningDurationTicks is all right, but shouldn't it be canWalkThrough instead? // MiningDurationTicks is all right, but shouldn't it be canWalkThrough instead?
// Lilypads (i think?) are 0 ticks to mine, but they definitely cause fall damage // Lilypads (i think?) are 0 ticks to mine, but they definitely cause fall damage
@@ -74,7 +77,7 @@ public class MovementFall extends Movement {
return COST_INF; return COST_INF;
} }
} }
return WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[positionsToBreak.length - 1] + placeBucketCost + frontTwo; return WALK_OFF_BLOCK_COST + FALL_N_BLOCKS_COST[positionsToBreak.length - 1] + placeBucketCost + frontThree;
} }
@Override @Override