aboutsummaryrefslogtreecommitdiff
path: root/azalea-protocol/src/packets/game/mod.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-12-26 14:15:06 -0600
committermat <github@matdoes.dev>2021-12-26 14:15:06 -0600
commitaf28b0e57aeeca8790e3014f3e568c60ae892e39 (patch)
tree497fa95e62393111f0b87d31926066153679bb52 /azalea-protocol/src/packets/game/mod.rs
parent1cdd061a999bfa16907ebcc5ab38b1863839b5f1 (diff)
downloadazalea-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.rs19
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)),
+ },
+ })
}
}