Skip to content

how to serialize non featured data type? #1870

Answered by TheMode
Sombian asked this question in Help
Discussion options

You must be logged in to vote

The Tag API is ultimately a way to interact with a NBT Compound, so you can do anything using Tag.NBT and there is a dedicated Byte Array type present in the format: https://minecraft.fandom.com/wiki/NBT_format#Data_types

You would have to do something like

Tag<NBTByteArray> tag = Tag.class.cast(Tag.NBT("path"));

var handler = TagHandler.newHandler();
NBTByteArray byteArray = handler.getTag(tag);

For enums we do not have an util method for it, you have to choose between serializing the enum name using Tag.String, or its ordinal with Tag.Integer

// Store name
var handler = TagHandler.newHandler();
var tag = Tag.String("enum");
handler.setTag(tag, Test.A.name());

// Store ordinal
var handler

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Sombian
Comment options

@TheMode
Comment options

Answer selected by Sombian
@Sombian
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants