BenWoodworth / knbt

Kotlin NBT library for kotlinx.serialization
GNU Lesser General Public License v3.0
77 stars 2 forks source link

Support Enum serialization #19

Open BenWoodworth opened 1 year ago

BenWoodworth commented 1 year ago

Minecraft appears to encode all enum-like values as an ordinal, so consider doing the same with enum values instead of throwing an "unsupported" error.

BenWoodworth commented 1 year ago

Minecraft seems to use TAG_Byte and TAG_Int for enums, so there doesn't seem to be an obvious default. It might be better to leave it up to the serializer to decide. Or perhaps some kind of @NbtEnum annotation to make it easy.

image

Ayfri commented 1 year ago

I like the idea of @NbtEnum, it should have a parameter to decide which type to use !