diff options
| author | mat <git@matdoes.dev> | 2024-08-15 01:25:11 +0000 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2024-08-15 01:25:11 +0000 |
| commit | 73091d8f937192aca4c4bbc740c78d4d188f6ee1 (patch) | |
| tree | 440e804d3a84583fb1b6b43a47724f5a17d001b7 /azalea-physics/src | |
| parent | dec544a52ba738e2d0e2c3a042e5ccc0cb336ffb (diff) | |
| download | azalea-drasl-73091d8f937192aca4c4bbc740c78d4d188f6ee1.tar.xz | |
fix sometimes being able to mine blocks through walls
Diffstat (limited to 'azalea-physics/src')
| -rw-r--r-- | azalea-physics/src/clip.rs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/azalea-physics/src/clip.rs b/azalea-physics/src/clip.rs index 8c2d0c8f..e44c59ca 100644 --- a/azalea-physics/src/clip.rs +++ b/azalea-physics/src/clip.rs @@ -2,7 +2,7 @@ use azalea_block::BlockState; use azalea_core::{ block_hit_result::BlockHitResult, direction::Direction, - math::{lerp, EPSILON}, + math::{self, lerp, EPSILON}, position::{BlockPos, Vec3}, }; use azalea_inventory::ItemSlot; @@ -111,13 +111,12 @@ fn clip_with_interaction_override( block_state: &BlockState, ) -> Option<BlockHitResult> { let block_hit_result = block_shape.clip(from, to, block_pos); + println!("block_hit_result: {block_hit_result:?}"); if let Some(block_hit_result) = block_hit_result { // TODO: minecraft calls .getInteractionShape here - // are there even any blocks that have a physics shape different from the - // interaction shape??? - // (if not then you can delete this comment) - // (if there are then you have to implement BlockState::interaction_shape, lol - // have fun) + // some blocks (like tall grass) have a physics shape that's different from the + // interaction shape, so we need to implement BlockState::interaction_shape. lol + // have fun let interaction_shape = block_state.shape(); let interaction_hit_result = interaction_shape.clip(from, to, block_pos); if let Some(interaction_hit_result) = interaction_hit_result { @@ -191,24 +190,27 @@ pub fn traverse_blocks<C, T>( let mut percentage = Vec3 { x: percentage_step.x * if vec_sign.x > 0. { - 1. - right_before_start.x.fract() + 1. - math::fract(right_before_start.x) } else { - right_before_start.x.fract().abs() + math::fract(right_before_start.x) }, y: percentage_step.y * if vec_sign.y > 0. { - 1. - right_before_start.y.fract() + 1. - math::fract(right_before_start.y) } else { - right_before_start.y.fract().abs() + math::fract(right_before_start.y) }, z: percentage_step.z * if vec_sign.z > 0. { - 1. - right_before_start.z.fract() + 1. - math::fract(right_before_start.z) } else { - right_before_start.z.fract().abs() + math::fract(right_before_start.z) }, }; + println!("percentage_step: {percentage_step:?}"); + println!("percentage: {percentage:?}"); + loop { if percentage.x > 1. && percentage.y > 1. && percentage.z > 1. { return get_miss_result(&context); |
