diff options
| author | mat <git@matdoes.dev> | 2025-09-27 18:41:36 -1030 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-09-27 20:26:41 -0845 |
| commit | 74dcb7b37d953ec4d45dd6aac4c8e598c87def7d (patch) | |
| tree | 22e6ab1849ee01d40f3d484ea0c8db52aa6649b5 /azalea-client/src/plugins/interact/pick.rs | |
| parent | 63bef6486dc1f3c9ef4b4f0d71e139d7035b6432 (diff) | |
| download | azalea-drasl-74dcb7b37d953ec4d45dd6aac4c8e598c87def7d.tar.xz | |
allow picking other bots in hit results
Diffstat (limited to 'azalea-client/src/plugins/interact/pick.rs')
| -rw-r--r-- | azalea-client/src/plugins/interact/pick.rs | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/azalea-client/src/plugins/interact/pick.rs b/azalea-client/src/plugins/interact/pick.rs index ae6c9502..580bb50c 100644 --- a/azalea-client/src/plugins/interact/pick.rs +++ b/azalea-client/src/plugins/interact/pick.rs @@ -1,5 +1,5 @@ use azalea_core::{ - aabb::AABB, + aabb::Aabb, direction::Direction, hit_result::{BlockHitResult, EntityHitResult, HitResult}, position::Vec3, @@ -15,7 +15,7 @@ use azalea_entity::{ }; use azalea_physics::{ clip::{BlockShapeType, ClipContext, FluidPickType}, - collision::entity_collisions::{PhysicsQuery, get_entities}, + collision::entity_collisions::{AabbQuery, get_entities}, }; use azalea_world::{Instance, InstanceContainer, InstanceName}; use bevy_ecs::prelude::*; @@ -44,7 +44,7 @@ pub fn update_hit_result_component( With<LocalEntity>, >, instance_container: Res<InstanceContainer>, - physics_query: PhysicsQuery, + aabb_query: AabbQuery, pickable_query: MaybePickableEntityQuery, ) { for ( @@ -76,7 +76,7 @@ pub fn update_hit_result_component( world: &world, entity_pick_range, block_pick_range, - physics_query: &physics_query, + aabb_query: &aabb_query, pickable_query: &pickable_query, }); if let Some(mut hit_result_ref) = hit_result_ref { @@ -109,7 +109,6 @@ pub type MaybePickableEntityQuery<'world, 'state, 'a> = Query< (With<AbstractLiving>, Without<Dead>), With<AbstractArrow>, )>, - Without<LocalEntity>, ), >; @@ -117,11 +116,11 @@ pub struct PickOpts<'world, 'state, 'a, 'b, 'c> { source_entity: Entity, look_direction: LookDirection, eye_position: Vec3, - aabb: &'a AABB, + aabb: &'a Aabb, world: &'a Instance, entity_pick_range: f64, block_pick_range: f64, - physics_query: &'a PhysicsQuery<'world, 'state, 'b>, + aabb_query: &'a AabbQuery<'world, 'state, 'b>, pickable_query: &'a MaybePickableEntityQuery<'world, 'state, 'c>, } @@ -163,6 +162,10 @@ pub fn pick(opts: PickOpts<'_, '_, '_, '_, '_>) -> HitResult { .inflate_all(inflate_by); let is_pickable = |entity: Entity| { + if entity == opts.source_entity { + return false; + } + // TODO: ender dragon has extra logic here. also, we shouldn't be able to pick // spectators. if let Ok((armor_stand_marker, arrow_in_ground)) = opts.pickable_query.get(entity) { @@ -180,7 +183,7 @@ pub fn pick(opts: PickOpts<'_, '_, '_, '_, '_>) -> HitResult { pick_range_squared: max_range_squared, predicate: &is_pickable, aabb: &pick_aabb, - physics_query: opts.physics_query, + aabb_query: opts.aabb_query, }); if let Some(entity_hit_result) = entity_hit_result @@ -246,8 +249,8 @@ struct PickEntityOpts<'world, 'state, 'a, 'b> { world: &'a azalea_world::Instance, pick_range_squared: f64, predicate: &'a dyn Fn(Entity) -> bool, - aabb: &'a AABB, - physics_query: &'a PhysicsQuery<'world, 'state, 'b>, + aabb: &'a Aabb, + aabb_query: &'a AabbQuery<'world, 'state, 'b>, } // port of getEntityHitResult @@ -260,7 +263,7 @@ fn pick_entity(opts: PickEntityOpts) -> Option<EntityHitResult> { Some(opts.source_entity), opts.aabb, opts.predicate, - opts.physics_query, + opts.aabb_query, ) { // TODO: if the entity is "REDIRECTABLE_PROJECTILE" then this should be 1.0. // azalea needs support for entity tags first for this to be possible. see |
