1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 06:16:04 +00:00

Rename Connection::configuration to config and add some clientbound functions that already existed serverbound

taken from Shay's fork: b0ca6076ed
This commit is contained in:
mat 2025-01-25 22:34:00 +00:00
parent b6ddde99ea
commit fe423416b4
3 changed files with 20 additions and 6 deletions

View file

@ -451,7 +451,7 @@ impl Client {
p.game_profile p.game_profile
); );
conn.write(ServerboundLoginAcknowledged {}).await?; conn.write(ServerboundLoginAcknowledged {}).await?;
break (conn.configuration(), p.game_profile); break (conn.config(), p.game_profile);
} }
ClientboundLoginPacket::LoginDisconnect(p) => { ClientboundLoginPacket::LoginDisconnect(p) => {
debug!("Got disconnect {:?}", p); debug!("Got disconnect {:?}", p);

View file

@ -364,7 +364,7 @@ pub fn declare_state_packets(input: TokenStream) -> TokenStream {
} }
} }
/// Read a packet by its id, ConnectionProtocol, and flow /// Read a packet by its id, ConnectionProtocol, and flow.
fn read( fn read(
id: u32, id: u32,
buf: &mut std::io::Cursor<&[u8]>, buf: &mut std::io::Cursor<&[u8]>,
@ -408,7 +408,7 @@ pub fn declare_state_packets(input: TokenStream) -> TokenStream {
} }
} }
/// Read a packet by its id, ConnectionProtocol, and flow /// Read a packet by its id, ConnectionProtocol, and flow.
fn read( fn read(
id: u32, id: u32,
buf: &mut std::io::Cursor<&[u8]>, buf: &mut std::io::Cursor<&[u8]>,
@ -422,6 +422,13 @@ pub fn declare_state_packets(input: TokenStream) -> TokenStream {
}) })
} }
} }
impl crate::packets::Packet<#clientbound_state_name> for #clientbound_state_name {
/// No-op, exists so you can pass a packet enum when a Packet<> is expected.
fn into_variant(self) -> #clientbound_state_name {
self
}
}
}); });
contents.into() contents.into()

View file

@ -359,7 +359,7 @@ impl Connection<ClientboundLoginPacket, ServerboundLoginPacket> {
/// Change our state from login to configuration. This is the state where /// Change our state from login to configuration. This is the state where
/// the server sends us the registries and resource pack and stuff. /// the server sends us the registries and resource pack and stuff.
#[must_use] #[must_use]
pub fn configuration(self) -> Connection<ClientboundConfigPacket, ServerboundConfigPacket> { pub fn config(self) -> Connection<ClientboundConfigPacket, ServerboundConfigPacket> {
Connection::from(self) Connection::from(self)
} }
@ -493,7 +493,7 @@ impl Connection<ServerboundLoginPacket, ClientboundLoginPacket> {
/// Change our state back to configuration. /// Change our state back to configuration.
#[must_use] #[must_use]
pub fn configuration(self) -> Connection<ServerboundConfigPacket, ClientboundConfigPacket> { pub fn config(self) -> Connection<ServerboundConfigPacket, ClientboundConfigPacket> {
Connection::from(self) Connection::from(self)
} }
} }
@ -519,7 +519,14 @@ impl Connection<ClientboundConfigPacket, ServerboundConfigPacket> {
impl Connection<ClientboundGamePacket, ServerboundGamePacket> { impl Connection<ClientboundGamePacket, ServerboundGamePacket> {
/// Change our state back to configuration. /// Change our state back to configuration.
#[must_use] #[must_use]
pub fn configuration(self) -> Connection<ClientboundConfigPacket, ServerboundConfigPacket> { pub fn config(self) -> Connection<ClientboundConfigPacket, ServerboundConfigPacket> {
Connection::from(self)
}
}
impl Connection<ServerboundGamePacket, ClientboundGamePacket> {
/// Change our state back to configuration.
#[must_use]
pub fn config(self) -> Connection<ServerboundConfigPacket, ClientboundConfigPacket> {
Connection::from(self) Connection::from(self)
} }
} }