aboutsummaryrefslogtreecommitdiff
path: root/azalea-core/src/block_hit_result.rs
diff options
context:
space:
mode:
Diffstat (limited to 'azalea-core/src/block_hit_result.rs')
-rwxr-xr-xazalea-core/src/block_hit_result.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/azalea-core/src/block_hit_result.rs b/azalea-core/src/block_hit_result.rs
index 420d4408..3b4f7257 100755
--- a/azalea-core/src/block_hit_result.rs
+++ b/azalea-core/src/block_hit_result.rs
@@ -1,6 +1,6 @@
use crate::{BlockPos, Direction, Vec3};
-#[derive(Debug, Clone, Copy)]
+#[derive(Debug, Clone, Copy, PartialEq)]
pub struct BlockHitResult {
pub location: Vec3,
pub direction: Direction,
@@ -8,3 +8,22 @@ pub struct BlockHitResult {
pub miss: bool,
pub inside: bool,
}
+
+impl BlockHitResult {
+ pub fn miss(location: Vec3, direction: Direction, block_pos: BlockPos) -> Self {
+ Self {
+ location,
+ direction,
+ block_pos,
+ miss: true,
+ inside: false,
+ }
+ }
+
+ pub fn with_direction(&self, direction: Direction) -> Self {
+ Self { direction, ..*self }
+ }
+ pub fn with_position(&self, block_pos: BlockPos) -> Self {
+ Self { block_pos, ..*self }
+ }
+}