Skip to main content

CollisionWorld

Trait CollisionWorld 

Source
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§

Source

fn get_block_state(&self, pos: BlockPos) -> BlockStateId

Gets the block state at the given position.

Source

fn get_block_collisions(&self, aabb: &WorldAabb) -> Vec<WorldAabb>

Queries all block collision shapes that intersect with the given AABB.

Returns a list of world-space AABBs representing solid block collisions.

Provided Methods§

Source

fn has_block_collision(&self, aabb: &WorldAabb) -> bool

Returns whether any block collision shape intersects with the given AABB.

Source

fn get_block_collisions_with_context( &self, aabb: &WorldAabb, context: BlockCollisionContext, ) -> Vec<WorldAabb>

Queries all block collision shapes with a vanilla collision context.

Source

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.

Source

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.

Source

fn has_entity_collision(&self, aabb: &WorldAabb) -> bool

Returns whether any entity collision shape intersects with the given AABB.

Source

fn get_world_border_collisions(&self, aabb: &WorldAabb) -> Vec<WorldAabb>

Queries world-border collision shapes intersecting the given AABB.

Source

fn has_world_border_collision(&self, aabb: &WorldAabb) -> bool

Returns whether any world-border collision shape intersects with the given AABB.

Source

fn get_collisions_with_context( &self, aabb: &WorldAabb, context: BlockCollisionContext, ) -> Vec<WorldAabb>

Queries entity, world-border, then block collisions with a vanilla context.

Source

fn has_collision_with_context( &self, aabb: &WorldAabb, context: BlockCollisionContext, ) -> bool

Returns whether any entity, world-border, or block collision shape intersects the AABB.

Source

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 movement
  • old_bottom_center - The entity’s bottom-center position before movement
  • descending - 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".

Implementors§