diff options
| author | mat <git@matdoes.dev> | 2025-06-02 04:12:07 -0100 |
|---|---|---|
| committer | mat <git@matdoes.dev> | 2025-06-02 04:12:07 -0100 |
| commit | 8da179b221ae4a7bfd02245b3cb6357464adbc43 (patch) | |
| tree | 5f94f8dd7f4b9bf62b66d3d5468de6449da05070 /azalea-client/src/client.rs | |
| parent | 3d121722d7b995de1346f9838df15386aea5acc8 (diff) | |
| download | azalea-drasl-8da179b221ae4a7bfd02245b3cb6357464adbc43.tar.xz | |
simplify some join logic so the Entity is returned even on connection error
Diffstat (limited to 'azalea-client/src/client.rs')
| -rw-r--r-- | azalea-client/src/client.rs | 40 |
1 files changed, 12 insertions, 28 deletions
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs index f53e693c..190e999c 100644 --- a/azalea-client/src/client.rs +++ b/azalea-client/src/client.rs @@ -1,7 +1,7 @@ use std::{ collections::HashMap, fmt::Debug, - io, mem, + mem, net::SocketAddr, sync::Arc, thread, @@ -9,7 +9,6 @@ use std::{ }; use azalea_auth::game_profile::GameProfile; -use azalea_chat::FormattedText; use azalea_core::{ data_registry::ResolvableDataRegistry, position::Vec3, resource_location::ResourceLocation, tick::GameTick, @@ -22,9 +21,9 @@ use azalea_entity::{ use azalea_protocol::{ ServerAddress, common::client_information::ClientInformation, - connect::{ConnectionError, Proxy}, + connect::Proxy, packets::{ - self, Packet, + Packet, game::{self, ServerboundGamePacket}, }, resolver, @@ -54,7 +53,7 @@ use crate::{ events::Event, interact::CurrentSequenceNumber, inventory::Inventory, - join::{ConnectOpts, StartJoinCallback, StartJoinServerEvent}, + join::{ConnectOpts, StartJoinServerEvent}, local_player::{ GameProfileComponent, Hunger, InstanceHolder, PermissionLevel, PlayerAbilities, TabList, }, @@ -89,22 +88,8 @@ pub struct Client { pub enum JoinError { #[error("{0}")] Resolver(#[from] resolver::ResolverError), - #[error("{0}")] - Connection(#[from] ConnectionError), - #[error("{0}")] - ReadPacket(#[from] Box<azalea_protocol::read::ReadPacketError>), - #[error("{0}")] - Io(#[from] io::Error), - #[error("Failed to encrypt the challenge from the server for {0:?}")] - EncryptionError(packets::login::ClientboundHello), - #[error("{0}")] - SessionServer(#[from] azalea_auth::sessionserver::ClientSessionServerError), #[error("The given address could not be parsed into a ServerAddress")] InvalidAddress, - #[error("Couldn't refresh access token: {0}")] - Auth(#[from] azalea_auth::AuthError), - #[error("Disconnected: {reason}")] - Disconnect { reason: FormattedText }, } pub struct StartClientOpts { @@ -193,7 +178,7 @@ impl Client { resolved_address, Some(tx), )) - .await?; + .await; Ok((client, rx)) } @@ -209,7 +194,7 @@ impl Client { let client = Self::start_client( StartClientOpts::new(account, address, resolved_address, Some(tx)).proxy(proxy), ) - .await?; + .await; Ok((client, rx)) } @@ -222,25 +207,24 @@ impl Client { connect_opts, event_sender, }: StartClientOpts, - ) -> Result<Self, JoinError> { + ) -> Self { // send a StartJoinServerEvent let (start_join_callback_tx, mut start_join_callback_rx) = - mpsc::unbounded_channel::<Result<Entity, JoinError>>(); + mpsc::unbounded_channel::<Entity>(); ecs_lock.lock().send_event(StartJoinServerEvent { account, connect_opts, event_sender, - start_join_callback_tx: Some(StartJoinCallback(start_join_callback_tx)), + start_join_callback_tx: Some(start_join_callback_tx), }); let entity = start_join_callback_rx.recv().await.expect( - "StartJoinCallback should not be dropped before sending a message, this is a bug in Azalea", - )?; + "start_join_callback should not be dropped before sending a message, this is a bug in Azalea", + ); - let client = Client::new(entity, ecs_lock.clone()); - Ok(client) + Client::new(entity, ecs_lock) } /// Write a packet directly to the server. |
