Adds two new helper NbtIo functions
This commit is contained in:
parent
2ab89defeb
commit
1525640d19
2 changed files with 23 additions and 3 deletions
|
@ -71,7 +71,8 @@ class NbtIo {
|
|||
return Tag.readNamedTag(_io) as CompoundTag;
|
||||
}
|
||||
|
||||
static Future<Uint8List> writeToStream(CompoundTag tag) async {
|
||||
/// Writes the NBT Data to stream in compressed mode
|
||||
static Future<Uint8List> writeToStreamCompressed(CompoundTag tag) async {
|
||||
_io = ByteLayer();
|
||||
Tag.writeNamedTag(tag, _io);
|
||||
_io.compress();
|
||||
|
@ -79,7 +80,7 @@ class NbtIo {
|
|||
return _io.bytes;
|
||||
}
|
||||
|
||||
static Future<CompoundTag> readFromStream(Uint8List list) async {
|
||||
static Future<CompoundTag> readFromStreamCompressed(Uint8List list) async {
|
||||
_io = ByteLayer();
|
||||
try {
|
||||
_io.writeBytes(list);
|
||||
|
@ -92,4 +93,23 @@ class NbtIo {
|
|||
return Tag.readNamedTag(_io) as CompoundTag;
|
||||
}
|
||||
}
|
||||
|
||||
static Future<Uint8List> writeToStream(CompoundTag tag) async {
|
||||
_io = ByteLayer();
|
||||
Tag.writeNamedTag(tag, _io);
|
||||
|
||||
return _io.bytes;
|
||||
}
|
||||
|
||||
static Future<CompoundTag> readFromStream(Uint8List list) async {
|
||||
_io = ByteLayer();
|
||||
try {
|
||||
_io.writeBytes(list);
|
||||
_io.resetPosition();
|
||||
} catch (E) {
|
||||
print(E);
|
||||
} finally {
|
||||
return Tag.readNamedTag(_io) as CompoundTag;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue