"Sputnik" help  
Sputnik Help
NbtCompoundReadCompressed(<binary/ByteBuffer>)

Description

Reads a compressed (GZip) version of an NBT compound from a binary string or a ByteBuffer instance.

Parameters

<binary/ByteBuffer> The binary string or ByteBuffer instance from which to read the compressed NBT compound.

Return Value

Success: Returns the decompressed NBT compound read from the binary string or ByteBuffer.
Failure: Returns null if there is an error during the read operation, if the provided input is invalid, or if the input is not a valid compressed NBT compound.

Remarks

The NbtCompoundReadCompressed function allows you to read a compressed (GZip) version of an NBT compound from a binary string or a ByteBuffer instance. It takes the binary string or ByteBuffer as input and performs the necessary operations to decompress and create an NBT compound from the provided data.

If a binary string is provided as the input, the function internally creates a ByteBuffer from the binary string and performs the decompression before reading the NBT compound.

Related

Example

Example of usage:

my $nbt1 = NbtNew(@NbtCompound);
NbtCompoundSet($nbt1, "Cat1", "Meow1");
NbtCompoundSet($nbt1, "Dog1", "Woof1");

my $nbt2 = NbtNew(@NbtCompound);
NbtCompoundSet($nbt2, "Cat2", "Meow2");
NbtCompoundSet($nbt2, "Dog2", "Woof2");

my $data1 = NbtCompoundWriteCompressed($nbt1);
my $data2 = NbtCompoundWriteCompressed($nbt2);

say BinaryExpand($data1);
say BinaryExpand($data2);

my $nbtRead1 = NbtCompoundReadCompressed($data1);
my $nbtRead2 = NbtCompoundReadCompressed($data2);

say $nbtRead1;
foreach(my $k => my $v in $nbtRead1)
    say $k . " -> " . $v;
say $nbtRead2;
foreach(my $k => my $v in $nbtRead2)
    say $k . " -> " . $v;

// PRINTS
// 00 | 4E 42 54 21 35 00 00 00 1F 8B 08 00 00 00 00 00 NBT!5...........
// 01 | 04 00 F3 73 0A 51 E4 62 60 60 60 71 4E 2C 31 04 ..ós.Qäb```qN,1.
// 02 | D2 AC BE A9 F9 E5 86 60 11 97 FC 74 B0 48 78 7E Ò¬.©ùå.`..üt°Hx~
// 03 | 7E 9A 21 03 00 50 CF 96 1F 29 00 00 00 -- -- -- ~.!..PÏ..)...
// 00 | 4E 42 54 21 35 00 00 00 1F 8B 08 00 00 00 00 00 NBT!5...........
// 01 | 04 00 F3 73 0A 51 E4 62 60 60 60 71 4E 2C 31 02 ..ós.Qäb```qN,1.
// 02 | D2 AC BE A9 F9 E5 46 60 11 97 FC 74 B0 48 78 7E Ò¬.©ùåF`..üt°Hx~
// 03 | 7E 9A 11 03 00 34 DC F8 A7 29 00 00 00 -- -- -- ~....4Üø§)...
// {NBTTag;Compound::[Cat1:Meow1,Dog1:Woof1]}
// Cat1 -> Meow1
// Dog1 -> Woof1
// {NBTTag;Compound::[Cat2:Meow2,Dog2:Woof2]}
// Cat2 -> Meow2
// Dog2 -> Woof2

Example of using a ByteBuffer class:

my $nbt1 = NbtNew(@NbtCompound);
NbtCompoundSet($nbt1, "Cat1", "Meow1");
NbtCompoundSet($nbt1, "Dog1", "Woof1");

my $nbt2 = NbtNew(@NbtCompound);
NbtCompoundSet($nbt2, "Cat2", "Meow2");
NbtCompoundSet($nbt2, "Dog2", "Woof2");

my $buf = new ByteBuffer();

NbtCompoundWriteCompressed($nbt1, $buf);
NbtCompoundWriteCompressed($nbt2, $buf);

say BinaryExpand($buf->ReadAll());

$buf->Rewind();

my $nbtRead1 = NbtCompoundReadCompressed($buf);
my $nbtRead2 = NbtCompoundReadCompressed($buf);

say $nbtRead1;
foreach(my $k => my $v in $nbtRead1)
    say $k . " -> " . $v;
say $nbtRead2;
foreach(my $k => my $v in $nbtRead2)
    say $k . " -> " . $v;

// PRINTS
// 00 | 4E 42 54 21 35 00 00 00 1F 8B 08 00 00 00 00 00 NBT!5...........
// 01 | 04 00 F3 73 0A 51 E4 62 60 60 60 71 4E 2C 31 04 ..ós.Qäb```qN,1.
// 02 | D2 AC BE A9 F9 E5 86 60 11 97 FC 74 B0 48 78 7E Ò¬.©ùå.`..üt°Hx~
// 03 | 7E 9A 21 03 00 50 CF 96 1F 29 00 00 00 4E 42 54 ~.!..PÏ..)...NBT
// 04 | 21 35 00 00 00 1F 8B 08 00 00 00 00 00 04 00 F3 !5.............ó
// 05 | 73 0A 51 E4 62 60 60 60 71 4E 2C 31 02 D2 AC BE s.Qäb```qN,1.Ò¬.
// 06 | A9 F9 E5 46 60 11 97 FC 74 B0 48 78 7E 7E 9A 11 ©ùåF`..üt°Hx~~..
// 07 | 03 00 34 DC F8 A7 29 00 00 00 -- -- -- -- -- -- ..4Üø§)...
// {NBTTag;Compound::[Cat1:Meow1,Dog1:Woof1]}
// Cat1 -> Meow1
// Dog1 -> Woof1
// {NBTTag;Compound::[Cat2:Meow2,Dog2:Woof2]}
// Cat2 -> Meow2
// Dog2 -> Woof2

 


Contact
Cheryl (uberfox@hotmail.com)
Homepage
http://ubersoft.org