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;
|
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();
|
_io = ByteLayer();
|
||||||
Tag.writeNamedTag(tag, _io);
|
Tag.writeNamedTag(tag, _io);
|
||||||
_io.compress();
|
_io.compress();
|
||||||
|
@ -79,7 +80,7 @@ class NbtIo {
|
||||||
return _io.bytes;
|
return _io.bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<CompoundTag> readFromStream(Uint8List list) async {
|
static Future<CompoundTag> readFromStreamCompressed(Uint8List list) async {
|
||||||
_io = ByteLayer();
|
_io = ByteLayer();
|
||||||
try {
|
try {
|
||||||
_io.writeBytes(list);
|
_io.writeBytes(list);
|
||||||
|
@ -92,4 +93,23 @@ class NbtIo {
|
||||||
return Tag.readNamedTag(_io) as CompoundTag;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: libac_dart
|
name: libac_dart
|
||||||
description: "Aria's Creations code library"
|
description: "Aria's Creations code library"
|
||||||
version: 1.2.072224+0449
|
version: 1.2.072224+1906
|
||||||
homepage: "https://zontreck.com"
|
homepage: "https://zontreck.com"
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue