diff options
| author | mat <git@matdoes.dev> | 2026-05-07 01:42:52 -0330 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2026-05-07 08:05:58 -1200 |
| commit | ee7358ebc2d3a033b48b3a97af4255e1efba9ef9 (patch) | |
| tree | 7a69c0676225bab4e37b44fb398829d554708623 /azalea-physics/src/clip.rs | |
| parent | a6fbdea961c2f8a788b362cbde1eab356d298e84 (diff) | |
| download | azalea-drasl-ee7358ebc2d3a033b48b3a97af4255e1efba9ef9.tar.xz | |
correct shapes for blocks with random offsets
Diffstat (limited to 'azalea-physics/src/clip.rs')
| -rw-r--r-- | azalea-physics/src/clip.rs | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/azalea-physics/src/clip.rs b/azalea-physics/src/clip.rs index b35857d3..af853821 100644 --- a/azalea-physics/src/clip.rs +++ b/azalea-physics/src/clip.rs @@ -1,4 +1,4 @@ -use std::collections::HashSet; +use std::{borrow::Cow, collections::HashSet}; use azalea_block::{ BlockState, @@ -27,18 +27,18 @@ pub struct ClipContext { impl ClipContext { /// Get the shape of given block, using the type of shape set in /// [`Self::block_shape_type`]. - pub fn block_shape(&self, block_state: BlockState) -> &VoxelShape { + pub fn block_shape(&self, block_state: BlockState, pos: BlockPos) -> Cow<'static, VoxelShape> { // minecraft passes in the world and blockpos to this function but it's not // actually necessary. it is for fluid_shape though match self.block_shape_type { - BlockShapeType::Collider => block_state.collision_shape(), - BlockShapeType::Outline => block_state.outline_shape(), - BlockShapeType::Visual => block_state.collision_shape(), + BlockShapeType::Collider => block_state.collision_shape(pos), + BlockShapeType::Outline => block_state.outline_shape(pos), + BlockShapeType::Visual => block_state.collision_shape(pos), BlockShapeType::FallDamageResetting => { if tags::blocks::FALL_DAMAGE_RESETTING.contains(&BlockKind::from(block_state)) { - block_state.collision_shape() + block_state.collision_shape(pos) } else { - &EMPTY_SHAPE + Cow::Borrowed(&EMPTY_SHAPE) } } } @@ -98,12 +98,12 @@ pub fn clip(chunk_storage: &ChunkStorage, context: ClipContext) -> BlockHitResul let block_state = chunk_storage.get_block_state(block_pos).unwrap_or_default(); let fluid_state = FluidState::from(block_state); - let block_shape = ctx.block_shape(block_state); + let block_shape = ctx.block_shape(block_state, block_pos); let interaction_clip = clip_with_interaction_override( ctx.from, ctx.to, block_pos, - block_shape, + &block_shape, block_state, ); let fluid_shape = ctx.fluid_shape(fluid_state, chunk_storage, block_pos); |
