azalea_core/
block_hit_result.rs

1use crate::{
2    direction::Direction,
3    position::{BlockPos, Vec3},
4};
5
6#[derive(Debug, Clone, Copy, PartialEq)]
7pub struct BlockHitResult {
8    pub location: Vec3,
9    pub direction: Direction,
10    pub block_pos: BlockPos,
11    pub miss: bool,
12    pub inside: bool,
13    pub world_border: bool,
14}
15
16impl BlockHitResult {
17    pub fn miss(location: Vec3, direction: Direction, block_pos: BlockPos) -> Self {
18        Self {
19            location,
20            direction,
21            block_pos,
22            miss: true,
23            inside: false,
24            world_border: false,
25        }
26    }
27
28    pub fn with_direction(&self, direction: Direction) -> Self {
29        Self { direction, ..*self }
30    }
31    pub fn with_position(&self, block_pos: BlockPos) -> Self {
32        Self { block_pos, ..*self }
33    }
34}