Skip to content

Conversation

@CoreyShupe
Copy link

@CoreyShupe CoreyShupe commented Aug 12, 2022

In the minecraft net source code there is a "quick exit" during 0x00 reads for base NBT objects.

    private static Tag readUnnamedTag(DataInput dataInput, int n, NbtAccounter nbtAccounter) throws IOException {
        byte by = dataInput.readByte();
        if (by == 0) {
            return EndTag.INSTANCE;
        }
        StringTag.skipString(dataInput);
        try {
            return TagTypes.getType(by).load(dataInput, n, nbtAccounter);
        // omitted
    }

Here we see that when the tag is 0x00 it won't read a header - and instead exit early with a "blank object", we should replicate this behavior when we have an object with nothing to serialize. This is especially helpful for "empty" nbt tags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant