Skip to content

feature(nbt): getting BinaryTagTypes by their id #1267

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

Open
wants to merge 1 commit into
base: main/4
Choose a base branch
from

Conversation

tal5
Copy link

@tal5 tal5 commented Jul 9, 2025

Exposes BinaryTagType#binaryTagType(byte id), to get a tag type by it's byte id.
This is needed if you're writing any sort of custom serialization, as currently you can get the id to serialize, but there's no way to de-serialize.

I also changed BinaryTagType.List TYPES to a BinaryTagType[] - technically hard-coding the size is not great, but seeing as:

  • There haven't been any new types in over 8 years.
  • It's a very easy change to make if any ever get added.
  • It'll error on startup when calling register with any potential new tag type.

it should be fine imo; still, lmk if you want me to revert it to the old list iteration & compare id approach.

Also, maybe it should return null instead of throwing? I just followed what the method already did, but maybe it would be better to change that, idk.

image

@tal5 tal5 changed the title feature(nbt): getting BinaryTagTypes by their id feature(nbt): getting BinaryTagTypes by its id Jul 9, 2025
@tal5 tal5 changed the title feature(nbt): getting BinaryTagTypes by its id feature(nbt): getting BinaryTagTypes by their id Jul 9, 2025
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