diff options
| author | mat <github@matdoes.dev> | 2021-12-26 14:15:06 -0600 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2021-12-26 14:15:06 -0600 |
| commit | af28b0e57aeeca8790e3014f3e568c60ae892e39 (patch) | |
| tree | 497fa95e62393111f0b87d31926066153679bb52 /azalea-protocol/src/packets/game/mod.rs | |
| parent | 1cdd061a999bfa16907ebcc5ab38b1863839b5f1 (diff) | |
| download | azalea-drasl-af28b0e57aeeca8790e3014f3e568c60ae892e39.tar.xz | |
reading nbt in the protocol works
Diffstat (limited to 'azalea-protocol/src/packets/game/mod.rs')
| -rw-r--r-- | azalea-protocol/src/packets/game/mod.rs | 19 |
1 files changed, 13 insertions, 6 deletions
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<T: tokio::io::AsyncRead + std::marker::Unpin + std::marker::Send>( - _id: u32, + id: u32, flow: &PacketFlow, - _buf: &mut T, + buf: &mut T, ) -> Result<GamePacket, String> 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)), + }, + }) } } |
