From aefa908e32032616cb356e7f4165cbb8922edbcf Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 21 Sep 2025 09:16:10 -1030 Subject: fix pickable entity query --- azalea-client/src/plugins/interact/pick.rs | 44 ++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 12 deletions(-) (limited to 'azalea-client/src/plugins/interact/pick.rs') diff --git a/azalea-client/src/plugins/interact/pick.rs b/azalea-client/src/plugins/interact/pick.rs index c32ac5c7..85e20376 100644 --- a/azalea-client/src/plugins/interact/pick.rs +++ b/azalea-client/src/plugins/interact/pick.rs @@ -7,7 +7,10 @@ use azalea_core::{ use azalea_entity::{ Attributes, Dead, LocalEntity, LookDirection, Physics, Position, dimensions::EntityDimensions, - metadata::{ArmorStandMarker, Marker}, + metadata::{ + AbstractArrow, AbstractBoat, AbstractLiving, AbstractMinecart, ArmorStand, + ArmorStandMarker, EndCrystal, FallingBlock, InGround, Interaction, ShulkerBullet, Tnt, + }, view_vector, }; use azalea_physics::{ @@ -42,7 +45,7 @@ pub fn update_hit_result_component( >, instance_container: Res, physics_query: PhysicsQuery, - pickable_query: PickableEntityQuery, + pickable_query: MaybePickableEntityQuery, ) { for ( entity, @@ -86,11 +89,28 @@ pub fn update_hit_result_component( } } -pub type PickableEntityQuery<'world, 'state, 'a> = Query< +pub type MaybePickableEntityQuery<'world, 'state, 'a> = Query< 'world, 'state, - Option<&'a ArmorStandMarker>, - (Without, Without, Without), + (Option<&'a ArmorStandMarker>, Option<&'a InGround>), + // search "isPickable" in the decompiled minecraft code + ( + Or<( + // TODO: ender dragon parts are pickable but the ender dragon itself isn't. this needs + // more investigation. + (With, Without), + (With, Without), + (With, Without), + (With, Without), + With, + With, + With, + With, + (With, Without), + With, + )>, + Without, + ), >; pub struct PickOpts<'world, 'state, 'a, 'b, 'c> { @@ -102,7 +122,7 @@ pub struct PickOpts<'world, 'state, 'a, 'b, 'c> { entity_pick_range: f64, block_pick_range: f64, physics_query: &'a PhysicsQuery<'world, 'state, 'b>, - pickable_query: &'a PickableEntityQuery<'world, 'state, 'c>, + pickable_query: &'a MaybePickableEntityQuery<'world, 'state, 'c>, } /// Get the block or entity that a player would be looking at if their eyes were @@ -143,18 +163,18 @@ pub fn pick(opts: PickOpts<'_, '_, '_, '_, '_>) -> HitResult { .inflate_all(inflate_by); let is_pickable = |entity: Entity| { - // TODO: ender dragon and projectiles have extra logic here. also, we shouldn't - // be able to pick spectators. - if let Ok(armor_stand_marker) = opts.pickable_query.get(entity) { - if let Some(armor_stand_marker) = armor_stand_marker - && armor_stand_marker.0 + // 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) { + if armor_stand_marker == Some(&ArmorStandMarker(true)) + || arrow_in_ground == Some(&InGround(true)) { false } else { true } } else { - true + false } }; let entity_hit_result = pick_entity(PickEntityOpts { -- cgit v1.2.3