aboutsummaryrefslogtreecommitdiff
path: root/azalea-nbt/src/decode.rs
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2021-12-18 20:33:16 -0600
committermat <github@matdoes.dev>2021-12-18 20:33:16 -0600
commitb030b9de9345d7b1cfef205e5b9a1e2c7dc6025e (patch)
tree1ce3beaae90328186d98e0de2c5c3c3f376f0d55 /azalea-nbt/src/decode.rs
parent76e1985fc4ab21c43e17fef685b17a567b1073a5 (diff)
downloadazalea-drasl-b030b9de9345d7b1cfef205e5b9a1e2c7dc6025e.tar.xz
nbt
Diffstat (limited to 'azalea-nbt/src/decode.rs')
-rw-r--r--azalea-nbt/src/decode.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/azalea-nbt/src/decode.rs b/azalea-nbt/src/decode.rs
index 704c8e2a..f3fbae54 100644
--- a/azalea-nbt/src/decode.rs
+++ b/azalea-nbt/src/decode.rs
@@ -1,10 +1,12 @@
use crate::Error;
use crate::Tag;
use byteorder::{ReadBytesExt, BE};
+use flate2::read::{GzDecoder, ZlibDecoder};
use std::{collections::HashMap, io::Read};
impl Tag {
fn read_known(stream: &mut impl Read, id: u8) -> Result<Tag, Error> {
+ println!("read_known: id={}", id);
let tag = match id {
// Signifies the end of a TAG_Compound. It is only ever used inside
// a TAG_Compound, and is not named despite being in a TAG_Compound
@@ -65,7 +67,9 @@ impl Tag {
10 => {
let mut map = HashMap::new();
loop {
+ println!("compound loop");
let tag_id = stream.read_u8().unwrap_or(0);
+ println!("compound loop tag_id={}", tag_id);
if tag_id == 0 {
break;
}
@@ -108,4 +112,14 @@ impl Tag {
// default to compound tag
Tag::read_known(stream, 10)
}
+
+ pub fn read_zlib(stream: &mut impl Read) -> Result<Tag, Error> {
+ let mut gz = ZlibDecoder::new(stream);
+ Tag::read(&mut gz)
+ }
+
+ pub fn read_gzip(stream: &mut impl Read) -> Result<Tag, Error> {
+ let mut gz = GzDecoder::new(stream);
+ Tag::read(&mut gz)
+ }
}