Jump to content

[1.12] Write a NBTArray to json


Lhykos

Recommended Posts

Heya!

 

I currently work on the serialization of a nbt tag to a json file and I struggle at the point of saving an nbt array like NBTTagByteArray.
There is no problem for me to do that, but i want to use the class JsonToNBT for the deserialisation.

 

And here is the thing:
For me there is no possbile way to do that. Minecraft wants for the deserialization a struct that looks like that:

{
	"byte_array_name": [B;2B,4B,6B,9B]
}


For me that is no known or valid json format. Did I miss something or did minecraft something stupid here?

Link to comment
Share on other sites

I think JSONToNBT does not take in a whole JSON file, but rather takes in a single JSON tag. So I think you need to run it on the result of somthing like JsonUtils.getString(object, "tag") where object is of type JSON Object.

In other words, it just takes in the string value of the the element.

 

Look at the SetNBT class that extends LootFunction

Edited by jabelar

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.