Releases: pmmp/NBT
Releases · pmmp/NBT
1.0.0
Changes since 0.3.4
- Added
BaseNbtSerializer->readHeadless()
andBaseNbtSerializer->writeHeadless()
. These are needed for one specific place in the Bedrock protocol and are otherwise not usually seen.
Despite the version bump to 1.0.0, this isn't a huge release. Staying on 0.x for so long was a mistake that needed to be corrected.
0.3.4
0.3.3
Changes since 0.3.2
JsonNbtParser
no longer throwsInvalidArgumentException
when attempting to create tags with out-of-bounds values (e.g. TAG_Byte with value larger than a byte) -NbtDataException
is now thrown instead.JsonNbtParser
no longer throwsTypeError
when attempting to createTAG_List
with mixed value types -NbtDataException
is now thrown instead.
0.3.2
0.2.19
0.3.1
0.3.0
This is a major release featuring significant API changes. It is not API-compatible with 0.2.x.
Changes since 0.2.x
- Error handling during decoding has been improved. Now, broken NBT will cause an
NbtDataException
to be thrown, instead of a generic\UnexpectedValueException
. - NBT serializers now use
BinaryStream
provided bypocketmine/binaryutils
to decode data, instead of an in-house implementation. - The library no longer depends on
ext-zlib
. Instead, decompressing of compressed NBT is left to the user, which allows more freedom of usage of the library, as well as enabling the usage of faster compressors such asext-libdeflate
. - The output format when using
__toString()
on tags has been revamped for improved readability.- The short names of tags are rendered in the output, instead of the full class name.
ByteArrayTag
s are now printed as base64 to prevent console breakage.
API changes
- The following classes have been renamed:
NBTStream
has been renamed toBaseNbtSerializer
.LittleEndianNBTStream
has been renamed toLittleEndianNbtSerializer
.BigEndianNBTStream
has been renamed toBigEndianNbtSerializer
.NamedTag
has been renamed toTag
(although all of the functionality that made itNamed
has been removed - see below).
NetworkLittleEndianNBTStream
has been removed. Since the format of this type of NBT is dependent on the current Minecraft protocol, and not standard, it's too volatile for inclusion in this library.- For users of PocketMine-MP,
NetworkNbtSerializer
serves as the replacement.
- For users of PocketMine-MP,
BaseNbtSerializer
(previouslyNBTStream
) has the following changes:write()
now accepts aTreeRoot
instead of aNamedTag
. Since tags don't contain names anymore, this allows the root tag to be named if desired.write()
no longer accepts an array of tags.writeMultiple()
has been added.read()
now returns aTreeRoot
instead of aNamedTag
.read()
no longer accepts a$doMultiple
parameter.readMultiple()
method has been added.read()
andreadMultiple()
now throwNbtDataException
on data errors, instead of\UnexpectedValueException
.toArray()
andfromArray()
were removed. This functionality had no clear purpose and was heavily broken for several years.readCompressed()
andwriteCompressed()
were removed. The user is now responsible for decompressing before decoding, and compressing after encoding (if necessary).
JsonNbtParser
has the following changes:parseJson()
now always returnsCompoundTag
. If an error occurs during deserialization, an exception will be thrown.parseJson()
now throwsNbtDataException
instead of\UnexpectedValueException
on bad data.
Tag
s no longer contain names. Since names are keys forTAG_Compound
, it didn't make sense for the tags themselves to contain them.- All
Tag
constructors have had the$name
argument removed. They now only accept values. - For the root tag, which may have a name even though it's not inside a
TAG_Compound
, aTreeRoot
class has been added. - The methods
getName()
andsetName()
have been removed. Tag
s with the same values will now compare as equal, regardless of their positions in lists or keys in compounds.
- All
Tag->read()
has been made static. This allows simple tag types to be immutable, which significantly improves performance during cloning.- All
Tag
implementations are nowfinal
. ListTag
has the following changes:- No longer supports
ArrayAccess
interfaces. SinceListTag
is strictly expected to behave like a list, it was too ambiguous what array access was supposed to do. - Now implements
IteratorAggregate
instead ofIterator
. This allows by-value modification of theListTag
while iterating over it, similar to how an array works.
- No longer supports
CompoundTag
has the following changes:ArrayAccess
is no longer supported. Its magical behaviour was impossible to statically analyse, and it was unclear what its behaviour was in some circumstances.IteratorAggregate
is now implemented instead ofIterator
. This allows by-value modification during iteration without breaking iteration, similar to how array copy-on-write works.getTagValue()
is no longer exposed to the public API.hasTag()
has been removed. It can be replaced by a statement likeif(($tag = $compound->getTag("name")) instanceof SomeTag)
instead, which is faster and more static-analysis-friendly.getTag()
no longer accepts an$expectedTagType
parameter (see previous point).setTag()
now requires a$name
argument before the$tag
.- The helper methods
setByte()
,setShort()
,setInt()
etc. now all require a$name
argument in addition to the$value
argument. - The helper methods
setByte()
,setShort()
,setInt()
etc. have had the$force
argument removed. - The helper methods
setByte()
,setShort()
,setInt()
etc. are now fluent. - The helper methods
getByte()
,getShort()
,getInt()
etc. have had the$badTagDefault
argument removed. - The helper methods
getByte()
,getShort()
,getInt()
etc. may now throwUnexpectedTagTypeException
orNoSuchTagException
when encountering incompatible data, instead of\UnexpectedValueException
. setTag()
no longer throws an exception when overwriting a tag of a different type. Since NBT should usually be built from scratch on save anyway, this check didn't make much sense.