实现了一些,但没完全实现

This commit is contained in:
shenjack 2023-08-04 00:01:19 +08:00
parent 32099a201b
commit fd9a9168ea
Signed by: shenjack
GPG Key ID: 7B1134A979775551
2 changed files with 50 additions and 3 deletions

View File

@ -1,4 +1,5 @@
# nbt-rust # nbt-rust
nbt解析器 by shenjack nbt解析器 by shenjack
writen in rust!
writen in rust!

View File

@ -116,6 +116,7 @@ where
/// NbtList /// NbtList
/// 来力 /// 来力
#[allow(unused)]
impl<T> NbtList<Vec<NbtItem<T>>> impl<T> NbtList<Vec<NbtItem<T>>>
where where
T: NbtListTrait + Clone, T: NbtListTrait + Clone,
@ -126,7 +127,52 @@ where
let mut buff = [0_u8; 4]; let mut buff = [0_u8; 4];
_ = value.read(&mut buff).unwrap(); _ = value.read(&mut buff).unwrap();
let len = NbtLength::from_be_bytes(buff); let len = NbtLength::from_be_bytes(buff);
let mut vec: Vec<T> = Vec::with_capacity(len as usize); let mut vec: Vec<NbtItem<T>> = 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::<Vec<bool>>::from_reader(value)));
}
}
}
}
todo!() todo!()
} }
} }