diff options
| author | mat <git@matdoes.dev> | 2026-01-14 21:01:40 -1000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-01-15 12:10:10 -0530 |
| commit | 9c8cf7adea6da1c76d96f447b71345f63146be10 (patch) | |
| tree | daf473c8064fa49778a227d7d54ca365f85e1208 /azalea/src/pathfinder/moves/basic.rs | |
| parent | 14b9166afb5d6563774bf7a4336d4e6807e01ebb (diff) | |
| download | azalea-drasl-9c8cf7adea6da1c76d96f447b71345f63146be10.tar.xz | |
more optimal pathfinder ascend_move
Diffstat (limited to 'azalea/src/pathfinder/moves/basic.rs')
| -rw-r--r-- | azalea/src/pathfinder/moves/basic.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/azalea/src/pathfinder/moves/basic.rs b/azalea/src/pathfinder/moves/basic.rs index b0fea827..2814641c 100644 --- a/azalea/src/pathfinder/moves/basic.rs +++ b/azalea/src/pathfinder/moves/basic.rs @@ -87,6 +87,13 @@ fn ascend_move(ctx: &mut PathfinderCtx, pos: RelBlockPos) { stair_facing = Some(found_stair_facing); } + let break_cost_1 = ctx + .world + .cost_for_breaking_block(pos.up(2), ctx.mining_cache); + if break_cost_1 == f32::INFINITY { + return; + } + for dir in CardinalDirection::iter() { if let Some(stair_facing) = stair_facing { let expected_stair_facing = cardinal_direction_to_facing_property(dir); @@ -97,20 +104,13 @@ fn ascend_move(ctx: &mut PathfinderCtx, pos: RelBlockPos) { let offset = RelBlockPos::new(dir.x(), 1, dir.z()); - let break_cost_1 = ctx - .world - .cost_for_breaking_block(pos.up(2), ctx.mining_cache); - if break_cost_1 == f32::INFINITY { - continue; - } let break_cost_2 = ctx.world.cost_for_standing(pos + offset, ctx.mining_cache); if break_cost_2 == f32::INFINITY { continue; } - let cost = SPRINT_ONE_BLOCK_COST + let cost = f32::max(WALK_ONE_BLOCK_COST, *JUMP_ONE_BLOCK_COST) + JUMP_PENALTY - + *JUMP_ONE_BLOCK_COST + break_cost_1 + break_cost_2; |
