Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/allow quick exit #69

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

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