From af28b0e57aeeca8790e3014f3e568c60ae892e39 Mon Sep 17 00:00:00 2001 From: mat Date: Sun, 26 Dec 2021 14:15:06 -0600 Subject: reading nbt in the protocol works --- azalea-protocol/src/packets/game/mod.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'azalea-protocol/src/packets/game/mod.rs') diff --git a/azalea-protocol/src/packets/game/mod.rs b/azalea-protocol/src/packets/game/mod.rs index 932435d9..5697a0ad 100644 --- a/azalea-protocol/src/packets/game/mod.rs +++ b/azalea-protocol/src/packets/game/mod.rs @@ -25,16 +25,23 @@ impl ProtocolPacket for GamePacket { /// Read a packet by its id, ConnectionProtocol, and flow async fn read( - _id: u32, + id: u32, flow: &PacketFlow, - _buf: &mut T, + buf: &mut T, ) -> Result where Self: Sized, { - match flow { - PacketFlow::ServerToClient => Err("HandshakePacket::read not implemented".to_string()), - PacketFlow::ClientToServer => Err("HandshakePacket::read not implemented".to_string()), - } + Ok(match flow { + PacketFlow::ServerToClient => match id { + 0x26 => clientbound_login_packet::ClientboundLoginPacket::read(buf).await?, + + _ => return Err(format!("Unknown ServerToClient game packet id: {}", id)), + }, + PacketFlow::ClientToServer => match id { + // 0x00 => serverbound_hello_packet::ServerboundHelloPacket::read(buf).await?, + _ => return Err(format!("Unknown ClientToServer game packet id: {}", id)), + }, + }) } } -- cgit v1.2.3