aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormat <git@matdoes.dev>2025-01-25 22:34:00 +0000
committermat <git@matdoes.dev>2025-01-25 22:34:00 +0000
commitfe423416b494e91f72dc91308b157d734f8c50f2 (patch)
tree691cff16d96384eeda526976b957ea6c6c5c3d42
parentb6ddde99eaf03466744bc4448bc3a4117ea2cd86 (diff)
downloadazalea-drasl-fe423416b494e91f72dc91308b157d734f8c50f2.tar.xz
Rename Connection::configuration to config and add some clientbound functions that already existed serverbound
taken from Shay's fork: https://github.com/Shays-Forks/azalea/commit/b0ca6076ed411b31e32a4abaa0350eb297067476
-rw-r--r--azalea-client/src/client.rs2
-rwxr-xr-xazalea-protocol/azalea-protocol-macros/src/lib.rs11
-rwxr-xr-xazalea-protocol/src/connect.rs13
3 files changed, 20 insertions, 6 deletions
diff --git a/azalea-client/src/client.rs b/azalea-client/src/client.rs
index 5970ab40..662a1294 100644
--- a/azalea-client/src/client.rs
+++ b/azalea-client/src/client.rs
@@ -451,7 +451,7 @@ impl Client {
p.game_profile
);
conn.write(ServerboundLoginAcknowledged {}).await?;
- break (conn.configuration(), p.game_profile);
+ break (conn.config(), p.game_profile);
}
ClientboundLoginPacket::LoginDisconnect(p) => {
debug!("Got disconnect {:?}", p);
diff --git a/azalea-protocol/azalea-protocol-macros/src/lib.rs b/azalea-protocol/azalea-protocol-macros/src/lib.rs
index b536e73a..5cbf2925 100755
--- a/azalea-protocol/azalea-protocol-macros/src/lib.rs
+++ b/azalea-protocol/azalea-protocol-macros/src/lib.rs
@@ -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(
id: u32,
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(
id: u32,
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()
diff --git a/azalea-protocol/src/connect.rs b/azalea-protocol/src/connect.rs
index ef202378..e1ee639b 100755
--- a/azalea-protocol/src/connect.rs
+++ b/azalea-protocol/src/connect.rs
@@ -359,7 +359,7 @@ impl Connection<ClientboundLoginPacket, ServerboundLoginPacket> {
/// Change our state from login to configuration. This is the state where
/// the server sends us the registries and resource pack and stuff.
#[must_use]
- pub fn configuration(self) -> Connection<ClientboundConfigPacket, ServerboundConfigPacket> {
+ pub fn config(self) -> Connection<ClientboundConfigPacket, ServerboundConfigPacket> {
Connection::from(self)
}
@@ -493,7 +493,7 @@ impl Connection<ServerboundLoginPacket, ClientboundLoginPacket> {
/// Change our state back to configuration.
#[must_use]
- pub fn configuration(self) -> Connection<ServerboundConfigPacket, ClientboundConfigPacket> {
+ pub fn config(self) -> Connection<ServerboundConfigPacket, ClientboundConfigPacket> {
Connection::from(self)
}
}
@@ -519,7 +519,14 @@ impl Connection<ClientboundConfigPacket, ServerboundConfigPacket> {
impl Connection<ClientboundGamePacket, ServerboundGamePacket> {
/// Change our state back to configuration.
#[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)
}
}