#converting ComponentMap to usable minecraft String

10 messages · Page 1 of 1 (latest)

hushed parcel
#

The default .toString() gives some weird results, and I'm hoping to get the ComponentMap in a form that I can reuse. I am not very familiar with CODEC so I don't know what to do.
I have tried other things, but none of them really gave the right results.
Thanks for the help!

kind sand
#

Not sure if this helps, but you can use component.encode(JsonOps.INSTANCE).getOrThrow() to get an encoded JsonElement of each component :)
(and then pass it through Gson().toJson(...) if you want a JSON string)

hushed parcel
#

Thank you, i will take a look at that!

hushed parcel
#

wait I may have just gotten it, Thank you!

kind sand
#

Nice! No problem :D

hushed parcel
# kind sand Nice! No problem \:D

Hey Im very very close thanks to you!
But I am having a bit of a problem,
It seems to be repeating components

I am doing it with for (Component<?> type : componentMap)
And for some reason it lists the components over and over

#

hmm that problems fixed but now everything is a string

#

even the ints and minecraft doesnt like that

#

Fixed it!