Releases: Querz/NBT
Releases · Querz/NBT
Improve type safety
This release improves type safety, especially for ListTag.
Details
- Fixed excessive use of raw types especially for Tag and ListTag
- Tags now implement
#hashCode()
matching their#equals()
method - Removed ability to change the type of a ListTag after a type has been specified
- The ListTag constructor now needs the class of it's type in addition to the generic type
- An empty untyped ListTag can be created using the protected static method
ListTag.createUnchecked()
- ListTags of type EndTag are not allowed anymore
- Empty untyped ListTags can be created during deserialisation though. Their type can be changed manually by either adding a new element or by calling one of the
ListTag#as...List()
methods.
- Empty untyped ListTags can be created during deserialisation though. Their type can be changed manually by either adding a new element or by calling one of the
ListTag#equals()
,ListTag#clone()
andListTag#hashCode()
are handled correctly with the above changes- Removed typeID from ListTag.
- TagFactory now has functionality to get a Tag class or a Tag Supplier from a type id or a type id from a Tag class.
- Serialisation and deserialisation are handled correctly with the above changes.
- ArrayTag now throws an
UnsupportedOperationException
when trying to create an ArrayTag that is not of an array type. - Adjusted Unit Tests accordingly and covered more cases.
Attention
This release changes method signatures and functionality and is NOT COMPATIBLE with previous versions!
MCA File API
This release adds an API to read, edit and write MCA files.
Details:
- Read MCA files with
MCAUtil.readMCAFile()
- Write MCA files with
MCAUtil.writeMCAFile()
- Get chunks using
MCAFile#getChunk()
- Get sections using
Chunk#getSection()
- Retrieve block states with
#getBlockStateAt()
and set them with#setBlockStateAt()
in either theMCAFile
,Chunk
orSection
class - Retrieve various other information like the biome, entities, structures, etc.
- Unit tests
Bugfixes and Tests
This release adds more unit tests and fixes some bugs and inconsistencies.
Details:
- Added tons of unit tests for better coverage
- Added coveralls badge to README
- Added checks for
compareTo()
methods if it receives a parameter of a wrong type - Added check in
TagFactory.registerCustomTag()
to throw anIllegalArgumentException
if the id is larger thanByte.MAX_VALUE
TagFactory.fromID()
now throws aRuntimeException
if the custom tag could not be instantiated- Moved unit tests to same package as classes to be tested
ListTag#addDouble()
now accepts a double instead of a byte as intendedNBTUtil.applyDecompression()
now usesGZIPInputStream.GZIP_MAGIC
.
MCA file util
This release adds a utility to read, change and write MCA files.
Details:
- MCAUtil#readMCAFile() returns an MCAFile object that contains all data.
- MCAUtil#writeMCAFile() writes the data from the MCAFile object to disk.
- MCAUtil has some convenience methods to create MCA file names from block, chunk and region coordinates and to convert block, chunk and region coordinates into each other.
Bugfixes
This release fixes a serialization bug in ListTags
s.
Changes:
- serialization and deserialization of empty
ListTag
s was not writing the size of the list to theDataOutputStream
- CompoundTag is now directly iterable
- Getting primitive types from
CompoundTag
should not throw aNullPointerException
but return the default value if the key doesn't exist
Iterable CompoundTag and ListTag
This release makes CompoundTag
and ListTag
iterable.
Changes
- added
forEach
method toCompoundTag
,ListTag
andStructTag
CompoundTag
,ListTag
andStructTag
now implementIterable
- added
CompoundTag#entrySet()
Map.Entry#setValue()
throws aNullPointerException
when trying to set a null value in the Set returned byCompoundTag#entrySet()
. The NBT specification does not support null values.
Major rewrite
This release contains a major rewrite and cleanup of the NBT library.
Warning
Version 2.0 is not compatible with older versions of this NBT library.
Changes
- removed
TagType
, custom tags are registered usingTagFactory.registerCustomTag()
now - removed
NBTInputStream
, as it was not doing anything special, useDataInputStream
directly now - removed
NBTOutputStream
, as it was not doing anything special, useDataOutputStream
directly now - removed
util.Array
- removed
NBTFileWriter
, useNBTUtil.readTag()
instead - removed
NBTFileReader
, useNBTUtil.writeTag()
instead NBTUtil.readTag()
andNBTUtil.writeTag()
can now throw an IOException that should be handled by the developer individually- removed
CustomTag
interface - added
TagFactory
for creating tags from IDs - tags now use generics
ListTag
now has a generic type, e.g.ListTag
for a list of byte tagsListTag
has some convenience methods to cast to specific types ofListTag
, e.g.ListTag#asByteTagList()
returns aListTag<ByteTag>
if you only have aListTag<?>
- custom tags now only have to extend
Tag
or any other class extendingTag
NumberTag
s don't exposeTag#getValue()
anymore, useNumberTag#asByte()
,NumberTag#asShort()
etc. insteadNumberTag
s no longer throw anIllegalStateException
when trying to convert a number of higher complexity to a number with lower complexity- renamed some methods to be more consistent in
CompoundTag
andListTag
Tag#toString()
now returns a json string with all information about the tag instead of the old custom notationTag
s no longer have a name, their name is now their key if they are stored inside of aCompoundTag
- wrote the unit tests more consistent and easier to understand
- made sure that null checks are used in the right places
- changed the version to 2.0
Add artifacts
- forgot to add sourcesJar / javadocJar to artifacts
Method consistency
- Added some convenience methods for consistency especially for CompoundTag and ListTag.
- sources jar and javadoc jar will be created with gradle so they should be available through jitpack.
Update to MC 1.13
This releases handles updates in NBT to String conversion for MC 1.13.
Changes:
- Array Tags can now specify their datatype
- Byte array: [B;1b,2b,3b]
- Int array: [I;1,2,3]
- Long array: [L;1l,2l,3l]
- Strings are now correctly escaped and put in double quotes if they contain any special characters
- Short tags now add an s to the end of the number