aboutsummaryrefslogtreecommitdiff
path: root/azalea-client
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-09-21 09:16:10 -1030
committermat <git@matdoes.dev>2025-09-21 11:46:13 -0800
commitaefa908e32032616cb356e7f4165cbb8922edbcf (patch)
tree2c15096917c009b9fd823e7d57894382904f7951 /azalea-client
parentf049eee0496083fe6347e2f4a4f7b8e4512883ee (diff)
downloadazalea-drasl-aefa908e32032616cb356e7f4165cbb8922edbcf.tar.xz
fix pickable entity query
Diffstat (limited to 'azalea-client')
-rw-r--r--azalea-client/src/plugins/interact/pick.rs44
-rw-r--r--azalea-client/src/plugins/mining.rs3
2 files changed, 34 insertions, 13 deletions
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<InstanceContainer>,
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<Dead>, Without<Marker>, Without<LocalEntity>),
+ (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<Tnt>, Without<Dead>),
+ (With<FallingBlock>, Without<Dead>),
+ (With<AbstractMinecart>, Without<Dead>),
+ (With<AbstractBoat>, Without<Dead>),
+ With<ArmorStand>,
+ With<EndCrystal>,
+ With<Interaction>,
+ With<ShulkerBullet>,
+ (With<AbstractLiving>, Without<Dead>),
+ With<AbstractArrow>,
+ )>,
+ Without<LocalEntity>,
+ ),
>;
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 {
diff --git a/azalea-client/src/plugins/mining.rs b/azalea-client/src/plugins/mining.rs
index f9bd50f6..e42ea866 100644
--- a/azalea-client/src/plugins/mining.rs
+++ b/azalea-client/src/plugins/mining.rs
@@ -182,7 +182,8 @@ fn handle_start_mining_block_event(
(block_hit_result.direction, false)
} else {
debug!(
- "Got StartMiningBlockEvent but we're not looking at the block. Picking an arbitrary direction instead."
+ "Got StartMiningBlockEvent but we're not looking at the block ({:?}.block_pos != {:?}). Picking an arbitrary direction instead.",
+ hit_result, event.position
);
// we're not looking at the block, arbitrary direction
(Direction::Down, true)