pub trait CollisionWorld {
// Required methods
fn get_block_state(&self, pos: BlockPos) -> BlockStateId;
fn get_block_collisions(&self, aabb: &WorldAabb) -> Vec<WorldAabb> ⓘ;
// Provided methods
fn has_block_collision(&self, aabb: &WorldAabb) -> bool { ... }
fn get_block_collisions_with_context(
&self,
aabb: &WorldAabb,
context: BlockCollisionContext,
) -> Vec<WorldAabb> ⓘ { ... }
fn has_block_collision_with_context(
&self,
aabb: &WorldAabb,
context: BlockCollisionContext,
) -> bool { ... }
fn get_entity_collisions(&self, aabb: &WorldAabb) -> Vec<WorldAabb> ⓘ { ... }
fn has_entity_collision(&self, aabb: &WorldAabb) -> bool { ... }
fn get_world_border_collisions(&self, aabb: &WorldAabb) -> Vec<WorldAabb> ⓘ { ... }
fn has_world_border_collision(&self, aabb: &WorldAabb) -> bool { ... }
fn get_collisions_with_context(
&self,
aabb: &WorldAabb,
context: BlockCollisionContext,
) -> Vec<WorldAabb> ⓘ { ... }
fn has_collision_with_context(
&self,
aabb: &WorldAabb,
context: BlockCollisionContext,
) -> bool { ... }
fn get_pre_move_collisions(
&self,
aabb: &WorldAabb,
old_bottom_center: DVec3,
descending: bool,
) -> Vec<WorldAabb> ⓘ { ... }
}Expand description
Trait for querying collision shapes from the world.
This abstraction allows testing physics without a full world instance.
Required Methods§
Sourcefn get_block_state(&self, pos: BlockPos) -> BlockStateId
fn get_block_state(&self, pos: BlockPos) -> BlockStateId
Gets the block state at the given position.
Provided Methods§
Sourcefn has_block_collision(&self, aabb: &WorldAabb) -> bool
fn has_block_collision(&self, aabb: &WorldAabb) -> bool
Returns whether any block collision shape intersects with the given AABB.
Sourcefn get_block_collisions_with_context(
&self,
aabb: &WorldAabb,
context: BlockCollisionContext,
) -> Vec<WorldAabb> ⓘ
fn get_block_collisions_with_context( &self, aabb: &WorldAabb, context: BlockCollisionContext, ) -> Vec<WorldAabb> ⓘ
Queries all block collision shapes with a vanilla collision context.
Sourcefn has_block_collision_with_context(
&self,
aabb: &WorldAabb,
context: BlockCollisionContext,
) -> bool
fn has_block_collision_with_context( &self, aabb: &WorldAabb, context: BlockCollisionContext, ) -> bool
Returns whether any block collision shape intersects with the given AABB and context.
Sourcefn get_entity_collisions(&self, aabb: &WorldAabb) -> Vec<WorldAabb> ⓘ
fn get_entity_collisions(&self, aabb: &WorldAabb) -> Vec<WorldAabb> ⓘ
Queries all entity collision shapes intersecting the given AABB.
Path-navigation regions and test worlds use the default empty entity
collision list. Live entity movement supplies these through
WorldCollisionProvider.
Sourcefn has_entity_collision(&self, aabb: &WorldAabb) -> bool
fn has_entity_collision(&self, aabb: &WorldAabb) -> bool
Returns whether any entity collision shape intersects with the given AABB.
Sourcefn get_world_border_collisions(&self, aabb: &WorldAabb) -> Vec<WorldAabb> ⓘ
fn get_world_border_collisions(&self, aabb: &WorldAabb) -> Vec<WorldAabb> ⓘ
Queries world-border collision shapes intersecting the given AABB.
Sourcefn has_world_border_collision(&self, aabb: &WorldAabb) -> bool
fn has_world_border_collision(&self, aabb: &WorldAabb) -> bool
Returns whether any world-border collision shape intersects with the given AABB.
Sourcefn get_collisions_with_context(
&self,
aabb: &WorldAabb,
context: BlockCollisionContext,
) -> Vec<WorldAabb> ⓘ
fn get_collisions_with_context( &self, aabb: &WorldAabb, context: BlockCollisionContext, ) -> Vec<WorldAabb> ⓘ
Queries entity, world-border, then block collisions with a vanilla context.
Sourcefn has_collision_with_context(
&self,
aabb: &WorldAabb,
context: BlockCollisionContext,
) -> bool
fn has_collision_with_context( &self, aabb: &WorldAabb, context: BlockCollisionContext, ) -> bool
Returns whether any entity, world-border, or block collision shape intersects the AABB.
Sourcefn get_pre_move_collisions(
&self,
aabb: &WorldAabb,
old_bottom_center: DVec3,
descending: bool,
) -> Vec<WorldAabb> ⓘ
fn get_pre_move_collisions( &self, aabb: &WorldAabb, old_bottom_center: DVec3, descending: bool, ) -> Vec<WorldAabb> ⓘ
Gets collision shapes for vanilla pre-move checks.
§Arguments
aabb- The entity’s bounding box after intended movementold_bottom_center- The entity’s bottom-center position before movementdescending- Whether the source entity is descending.
§Returns
Collision shapes intersecting the target box.
Vanilla includes entity collisions and uses the old bottom-center Y as block collision context.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".