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-nbt/src/decode.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'azalea-nbt/src') diff --git a/azalea-nbt/src/decode.rs b/azalea-nbt/src/decode.rs index b21bd9a5..41689a46 100644 --- a/azalea-nbt/src/decode.rs +++ b/azalea-nbt/src/decode.rs @@ -121,7 +121,18 @@ impl Tag { R: AsyncRead + std::marker::Unpin + std::marker::Send, { // default to compound tag - Tag::read_known(stream, 10).await + + // the parent compound only ever has one item + let tag_id = stream.read_u8().await.unwrap_or(0); + if tag_id == 0 { + return Ok(Tag::End); + } + let name = read_string(stream).await?; + let tag = Tag::read_known(stream, tag_id).await?; + let mut map = HashMap::with_capacity(1); + map.insert(name, tag); + + Ok(Tag::Compound(map)) } pub async fn read_zlib(stream: &mut R) -> Result -- cgit v1.2.3