Treat null as end tag in writeTag to match readTag.

This commit is contained in:
Steveice10 2019-08-27 23:17:56 -07:00
parent 9bf4adb2af
commit 9d32159125
1 changed files with 7 additions and 3 deletions

View File

@ -225,9 +225,13 @@ public class NBTIO {
* @throws java.io.IOException If an I/O error occurs.
*/
public static void writeTag(DataOutput out, Tag tag) throws IOException {
out.writeByte(TagRegistry.getIdFor(tag.getClass()));
out.writeUTF(tag.getName());
tag.write(out);
if(tag != null) {
out.writeByte(TagRegistry.getIdFor(tag.getClass()));
out.writeUTF(tag.getName());
tag.write(out);
} else {
out.writeByte(0);
}
}
private static class LittleEndianDataInputStream extends FilterInputStream implements DataInput {