KyoriPowered / adventure

A user-interface library, formerly known as text, for Minecraft: Java Edition
https://docs.advntr.dev/
MIT License
678 stars 103 forks source link

NBT Component Serializer #1084

Open Codestech1 opened 3 weeks ago

Codestech1 commented 3 weeks ago

Adds a support for serializing components as NBT Binary Tags.

Resolves #995

Codestech1 commented 3 weeks ago

The serialization works now, but i need to clean it up, add backwards compatibility (old nbt), add javadocs and deserialization. But the hardest part with understanding how everything realted to this (in both adventure and Minecraft) is done.

Codestech1 commented 3 weeks ago

Component deserialization works properly (tested with a large component with many children and styling), component serialization however doesn't serialize lists of components (children, etc.) as anything else than compounds. I'll check if there's a way to make it check if all types of components can be serialized as a string without looping through the entire list twice (one time for checks, second time for creating the list).

What's left (let me know if i forgot anything):

Codestech1 commented 2 weeks ago

Another TODO: The hover event serializer should serialize legacy show achievement hover events with value key instead of contents key

Codestech1 commented 2 weeks ago

I forgot to add tests for hover event and click event, i'm adding them right now

Codestech1 commented 2 weeks ago

Ok, it's ready now, i think

Codestech1 commented 1 week ago

I've added a possibility to (de)-serialize a style without a component, because it's useful for new chat type registry in Minecraft. For example Minestom uses adventure styles to (de)-serialize the chat type styles.