稍稍清理一下

This commit is contained in:
shenjack 2024-03-10 13:09:33 +08:00
parent 454b124e0d
commit 56468db169
Signed by: shenjack
GPG Key ID: 7B1134A979775551
2 changed files with 7 additions and 35 deletions

View File

@ -405,9 +405,7 @@ impl NbtReader<'_> {
self.cursor += 2;
value
}
/// 安全的读取 i16 类型的数据
///
/// 转换大小端(小端)
/// 安全的读取小端 i16 数据
///
/// 会在超出长度时 panic
#[inline]
@ -799,31 +797,4 @@ impl NbtReader<'_> {
self.cursor += len;
Ok(value.into_owned())
}
// /// 读取一个 NBT byte array
// pub fn read_nbt_i8_array(&mut self) -> Vec<i8> {
// let len = self.read_be_i32() as usize;
// let value = unsafe { self.read_i8_array_unsafe(len) };
// value
// }
// /// 读取一个 NBT int array
// pub fn read_nbt_i32_array(&mut self) -> Vec<i32> {
// let len = self.read_be_i32() as usize;
// let value = unsafe { self.read_i32_array_unsafe(len) };
// value
// }
// /// 读取一个 NBT long array
// pub fn read_nbt_i64_array(&mut self) -> Vec<i64> {
// let len = self.read_be_i32() as usize;
// let value = unsafe { self.read_i64_array_unsafe(len) };
// value
// }
// /// 读取一个 NBT string
// pub fn read_nbt_string(&mut self) -> NbtResult<String> {
// let len = self.read_be_u16() as usize;
// self.read_string(len)
// }
}

View File

@ -303,7 +303,7 @@ mod nbt {
#[test]
fn big_test() {
let data: [u8; 0x608] = [
let mut data: [u8; 0x608] = [
0x0A, 0x00, 0x05, 0x4C, 0x65, 0x76, 0x65, 0x6C, 0x04, 0x00, 0x08, 0x6C, 0x6F, 0x6E,
0x67, 0x54, 0x65, 0x73, 0x74, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x02,
0x00, 0x09, 0x73, 0x68, 0x6F, 0x72, 0x74, 0x54, 0x65, 0x73, 0x74, 0x7F, 0xFF, 0x08,
@ -416,8 +416,9 @@ mod nbt {
0x6F, 0x75, 0x62, 0x6C, 0x65, 0x54, 0x65, 0x73, 0x74, 0x3F, 0xDF, 0x8F, 0x6B, 0xBB,
0xFF, 0x6A, 0x5E, 0x00,
];
let value = NbtValue::from_binary::<nbt_version::Java>(&mut data.clone());
let value = NbtValue::from_binary::<nbt_version::Java>(&mut data);
println!("{:?}", value);
assert!(value.is_ok());
// 其他版本
}
}