diff options
| author | mat <git@matdoes.dev> | 2023-10-06 15:23:36 -0500 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2023-10-06 15:23:36 -0500 |
| commit | 30702d94f65a2bd86c9ac0a7c402675b89ac4364 (patch) | |
| tree | 1d4399d168e49479161f3dfa046a58442fcccb04 /azalea-client/src | |
| parent | 177864be60c08cb61fd577eb99ee5c99481fc03e (diff) | |
| download | azalea-drasl-30702d94f65a2bd86c9ac0a7c402675b89ac4364.tar.xz | |
fix QueryDoesNotMatch and improve error
Diffstat (limited to 'azalea-client/src')
| -rw-r--r-- | azalea-client/src/client.rs | 3 | ||||
| -rw-r--r-- | azalea-client/src/entity_query.rs | 14 | ||||
| -rw-r--r-- | azalea-client/src/packet_handling/configuration.rs | 1 |
3 files changed, 10 insertions, 8 deletions
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index 90d90e01..7c5cb82a 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -270,6 +270,7 @@ impl Client { received_registries: ReceivedRegistries::default(), local_player_events: LocalPlayerEvents(tx), game_profile: GameProfileComponent(game_profile), + client_information: crate::ClientInformation::default(), account: account.to_owned(), }, InConfigurationState, @@ -593,6 +594,7 @@ pub struct LocalPlayerBundle { pub received_registries: ReceivedRegistries, pub local_player_events: LocalPlayerEvents, pub game_profile: GameProfileComponent, + pub client_information: ClientInformation, pub account: Account, } @@ -604,7 +606,6 @@ pub struct JoinedClientBundle { pub instance_holder: InstanceHolder, pub physics_state: PhysicsState, pub inventory: InventoryComponent, - pub client_information: ClientInformation, pub tab_list: TabList, pub current_sequence_number: CurrentSequenceNumber, pub last_sent_direction: LastSentLookDirection, diff --git a/azalea-client/src/entity_query.rs b/azalea-client/src/entity_query.rs index ca41c872..7b140825 100644 --- a/azalea-client/src/entity_query.rs +++ b/azalea-client/src/entity_query.rs @@ -23,9 +23,10 @@ impl Client { /// # } /// ``` pub fn query<'w, Q: WorldQuery>(&self, ecs: &'w mut World) -> <Q as WorldQuery>::Item<'w> { - ecs.query::<Q>() - .get_mut(ecs, self.entity) - .expect("Our client is missing a required component.") + ecs.query::<Q>().get_mut(ecs, self.entity).expect(&format!( + "Our client is missing a required component {:?}", + std::any::type_name::<Q>() + )) } /// Return a lightweight [`Entity`] for the entity that matches the given @@ -66,9 +67,10 @@ impl Client { pub fn entity_component<Q: Component + Clone>(&mut self, entity: Entity) -> Q { let mut ecs = self.ecs.lock(); let mut q = ecs.query::<&Q>(); - let components = q - .get(&ecs, entity) - .expect("Entity components must be present in Client::entity)components."); + let components = q.get(&ecs, entity).expect(&format!( + "Entity is missing a required component {:?}", + std::any::type_name::<Q>() + )); components.clone() } diff --git a/azalea-client/src/packet_handling/configuration.rs b/azalea-client/src/packet_handling/configuration.rs index df1b1025..7c295bdb 100644 --- a/azalea-client/src/packet_handling/configuration.rs +++ b/azalea-client/src/packet_handling/configuration.rs @@ -134,7 +134,6 @@ pub fn process_packet_events(ecs: &mut World) { instance_holder, physics_state: crate::PhysicsState::default(), inventory: crate::inventory::InventoryComponent::default(), - client_information: crate::ClientInformation::default(), tab_list: crate::local_player::TabList::default(), current_sequence_number: crate::interact::CurrentSequenceNumber::default(), last_sent_direction: crate::movement::LastSentLookDirection::default(), |
