Skip to content

Releases: Querz/NBT

Improve type safety

20 Dec 14:34
66f0d0d
Compare
Choose a tag to compare

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.
  • ListTag#equals(), ListTag#clone() and ListTag#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

19 Oct 13:29
6f39e38
Compare
Choose a tag to compare

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 the MCAFile, Chunk or Section class
  • Retrieve various other information like the biome, entities, structures, etc.
  • Unit tests

Bugfixes and Tests

07 Sep 18:51
ddf83f2
Compare
Choose a tag to compare

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 an IllegalArgumentException if the id is larger than Byte.MAX_VALUE
  • TagFactory.fromID() now throws a RuntimeException 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 intended
  • NBTUtil.applyDecompression() now uses GZIPInputStream.GZIP_MAGIC.

MCA file util

06 Sep 08:31
5dee013
Compare
Choose a tag to compare

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

22 Aug 08:37
Compare
Choose a tag to compare

This release fixes a serialization bug in ListTagss.

Changes:

  • serialization and deserialization of empty ListTags was not writing the size of the list to the DataOutputStream
  • CompoundTag is now directly iterable
  • Getting primitive types from CompoundTag should not throw a NullPointerException but return the default value if the key doesn't exist

Iterable CompoundTag and ListTag

21 Aug 13:41
Compare
Choose a tag to compare

This release makes CompoundTag and ListTag iterable.

Changes

  • added forEach method to CompoundTag, ListTag and StructTag
  • CompoundTag, ListTag and StructTag now implement Iterable
  • added CompoundTag#entrySet()
  • Map.Entry#setValue() throws a NullPointerException when trying to set a null value in the Set returned by CompoundTag#entrySet(). The NBT specification does not support null values.

Major rewrite

20 Aug 15:25
4644a3b
Compare
Choose a tag to compare

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 using TagFactory.registerCustomTag() now
  • removed NBTInputStream, as it was not doing anything special, use DataInputStream directly now
  • removed NBTOutputStream, as it was not doing anything special, use DataOutputStream directly now
  • removed util.Array
  • removed NBTFileWriter, use NBTUtil.readTag() instead
  • removed NBTFileReader, use NBTUtil.writeTag() instead
  • NBTUtil.readTag() and NBTUtil.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 tags
    • ListTag has some convenience methods to cast to specific types of ListTag, e.g. ListTag#asByteTagList() returns a ListTag<ByteTag> if you only have a ListTag<?>
  • custom tags now only have to extend Tag or any other class extending Tag
  • NumberTags don't expose Tag#getValue() anymore, use NumberTag#asByte(), NumberTag#asShort() etc. instead
  • NumberTags no longer throw an IllegalStateException when trying to convert a number of higher complexity to a number with lower complexity
  • renamed some methods to be more consistent in CompoundTag and ListTag
  • Tag#toString() now returns a json string with all information about the tag instead of the old custom notation
  • Tags no longer have a name, their name is now their key if they are stored inside of a CompoundTag
  • 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

14 Aug 07:20
Compare
Choose a tag to compare
  • forgot to add sourcesJar / javadocJar to artifacts

Method consistency

14 Aug 07:09
Compare
Choose a tag to compare
  • 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

03 Aug 12:09
e063253
Compare
Choose a tag to compare

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