From 7a24de8cbdebae720767b552aac9f0ba75e8c219 Mon Sep 17 00:00:00 2001 From: mat Date: Mon, 13 Oct 2025 13:55:43 +1200 Subject: add Client::entity_interact and EntityInteractEvent for convenience --- azalea-core/src/hit_result.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'azalea-core/src') 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)] -- cgit v1.2.3