diff options
| author | mat <git@matdoes.dev> | 2023-10-02 18:53:27 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-10-02 18:53:27 -0500 |
| commit | 7b10e5cd7e80be85f7b0517f941b175e733d3fc4 (patch) | |
| tree | 1c99d6f4670456da4792f5c6be369662676ddd82 /azalea/src | |
| parent | d0505f7de30e4a9a330ef99d0082849ee44723e0 (diff) | |
| download | azalea-drasl-7b10e5cd7e80be85f7b0517f941b175e733d3fc4.tar.xz | |
optimize pathfinder more
Diffstat (limited to 'azalea/src')
| -rw-r--r-- | azalea/src/pathfinder/moves/mod.rs | 4 | ||||
| -rw-r--r-- | azalea/src/pathfinder/moves/parkour.rs | 27 |
2 files changed, 17 insertions, 14 deletions
diff --git a/azalea/src/pathfinder/moves/mod.rs b/azalea/src/pathfinder/moves/mod.rs index caf4bbb4..9eb6462b 100644 --- a/azalea/src/pathfinder/moves/mod.rs +++ b/azalea/src/pathfinder/moves/mod.rs @@ -80,7 +80,7 @@ impl<'a> PathfinderCtx<'a> { // fast path return true; } - if block.shape() != &*collision::EMPTY_SHAPE { + if !block.is_shape_empty() { return false; } if block == azalea_registry::Block::Water.into() { @@ -107,7 +107,7 @@ impl<'a> PathfinderCtx<'a> { // fast path return false; } - block.shape() == &*collision::BLOCK_SHAPE + block.is_shape_full() } /// Whether this block and the block above are passable diff --git a/azalea/src/pathfinder/moves/parkour.rs b/azalea/src/pathfinder/moves/parkour.rs index 53f5a348..27763257 100644 --- a/azalea/src/pathfinder/moves/parkour.rs +++ b/azalea/src/pathfinder/moves/parkour.rs @@ -22,6 +22,10 @@ fn parkour_forward_1_move(ctx: &PathfinderCtx, pos: BlockPos) -> Vec<Edge> { let gap_offset = BlockPos::new(dir.x(), 0, dir.z()); let offset = BlockPos::new(dir.x() * 2, 0, dir.z() * 2); + // make sure we actually have to jump + if ctx.is_block_solid(&(pos + gap_offset).down(1)) { + continue; + } if !ctx.is_standable(&(pos + offset)) { continue; } @@ -31,10 +35,6 @@ fn parkour_forward_1_move(ctx: &PathfinderCtx, pos: BlockPos) -> Vec<Edge> { if !ctx.is_block_passable(&(pos + gap_offset).up(2)) { continue; } - // make sure we actually have to jump - if ctx.is_block_solid(&(pos + gap_offset).down(1)) { - continue; - } // make sure it's not a headhitter if !ctx.is_block_passable(&pos.up(2)) { continue; @@ -64,6 +64,13 @@ fn parkour_forward_2_move(ctx: &PathfinderCtx, pos: BlockPos) -> Vec<Edge> { let gap_2_offset = BlockPos::new(dir.x() * 2, 0, dir.z() * 2); let offset = BlockPos::new(dir.x() * 3, 0, dir.z() * 3); + // make sure we actually have to jump + if ctx.is_block_solid(&(pos + gap_1_offset).down(1)) + || ctx.is_block_solid(&(pos + gap_2_offset).down(1)) + { + continue; + } + if !ctx.is_standable(&(pos + offset)) { continue; } @@ -79,10 +86,6 @@ fn parkour_forward_2_move(ctx: &PathfinderCtx, pos: BlockPos) -> Vec<Edge> { if !ctx.is_block_passable(&(pos + gap_2_offset).up(2)) { continue; } - // make sure we actually have to jump - if ctx.is_block_solid(&(pos + gap_1_offset).down(1)) { - continue; - } // make sure it's not a headhitter if !ctx.is_block_passable(&pos.up(2)) { continue; @@ -114,6 +117,10 @@ fn parkour_headhitter_forward_1_move(ctx: &PathfinderCtx, pos: BlockPos) -> Vec< let gap_offset = BlockPos::new(dir.x(), 0, dir.z()); let offset = BlockPos::new(dir.x() * 2, 0, dir.z() * 2); + // make sure we actually have to jump + if ctx.is_block_solid(&(pos + gap_offset).down(1)) { + continue; + } if !ctx.is_standable(&(pos + offset)) { continue; } @@ -123,10 +130,6 @@ fn parkour_headhitter_forward_1_move(ctx: &PathfinderCtx, pos: BlockPos) -> Vec< if !ctx.is_block_passable(&(pos + gap_offset).up(2)) { continue; } - // make sure we actually have to jump - if ctx.is_block_solid(&(pos + gap_offset).down(1)) { - continue; - } // make sure it is a headhitter if !ctx.is_block_solid(&pos.up(2)) { continue; |
