diff options
Diffstat (limited to 'azalea-core/src')
| -rw-r--r-- | azalea-core/src/hit_result.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/azalea-core/src/hit_result.rs b/azalea-core/src/hit_result.rs index 96ff32c9..2f3d2403 100644 --- a/azalea-core/src/hit_result.rs +++ b/azalea-core/src/hit_result.rs @@ -43,8 +43,7 @@ impl HitResult { matches!(self, HitResult::Block(r) if !r.miss) } - /// Returns the [`BlockHitResult`], if we were looking at a block and it - /// wasn't a miss. + /// Returns the [`BlockHitResult`], if we were looking at a block. pub fn as_block_hit_result_if_not_miss(&self) -> Option<&BlockHitResult> { if let HitResult::Block(r) = self && !r.miss @@ -54,6 +53,16 @@ impl HitResult { None } } + + /// Returns the [`EntityHitResult`], if we were looking at an entity and it + /// wasn't a miss. + pub fn as_entity_hit_result(&self) -> Option<&EntityHitResult> { + if let HitResult::Entity(r) = self { + Some(r) + } else { + None + } + } } #[derive(Debug, Clone, PartialEq)] |
