diff --git a/README.md b/README.md index 412abc3..9bab3f8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # nbt-rust -nbt解析器 by shenjack -writen in rust! \ No newline at end of file +nbt解析器 by shenjack + +writen in rust! diff --git a/src/data.rs b/src/data.rs index 8a19b88..f8fafbd 100644 --- a/src/data.rs +++ b/src/data.rs @@ -116,6 +116,7 @@ where /// NbtList /// 来力 +#[allow(unused)] impl NbtList>> where T: NbtListTrait + Clone, @@ -126,7 +127,52 @@ where let mut buff = [0_u8; 4]; _ = value.read(&mut buff).unwrap(); let len = NbtLength::from_be_bytes(buff); - let mut vec: Vec = Vec::with_capacity(len as usize); + let mut vec: Vec> = Vec::with_capacity(len as usize); + // 先读取 type + let mut type_buff = [0_u8; 1]; + _ = value.read(&mut type_buff).unwrap(); + match type_buff { + [0x00] => { + todo!() + } + [0x01] => { + for _ in 0..len { + vec.push(NbtItem::Value(NbtValue::from_bool(value))); + } + } + [0x02] => { + for _ in 0..len { + vec.push(NbtItem::Value(NbtValue::from_i16(value))); + } + } + [0x03] => { + for _ in 0..len { + vec.push(NbtItem::Value(NbtValue::from_i32(value))); + } + } + [0x04] => { + for _ in 0..len { + vec.push(NbtItem::Value(NbtValue::from_i64(value))); + } + } + [0x05] => { + for _ in 0..len { + vec.push(NbtItem::Value(NbtValue::from_f32(value))); + } + } + [0x06] => { + for _ in 0..len { + vec.push(NbtItem::Value(NbtValue::from_f64(value))); + } + } + [0x07] => { + for _ in 0..len { + for _ in 0..len { + vec.push(NbtItem::Array(NbtList::>::from_reader(value))); + } + } + } + } todo!() } }