You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is no data holder converter registered to convert from a class net.kyori.adventure.nbt.api.BinaryTagHolderImpl instance to a interface net.kyori.adventure.text.serializer.gson.GsonDataComponentValue (on field minecraft:lore)
#1130
Open
that-apex opened this issue
Nov 18, 2024
· 0 comments
GsonComponentSerializer will fail to serialize an ItemStack that has components if it was previously deserialized with minimessage.
val item =ItemStack(Material.DIAMOND)
item.editMeta { it.lore(listOf(Component.text("my lore"))) }
val baseComponent =Component.translatable(item).hoverEvent(item.asHoverEvent())
val json1 =GsonComponentSerializer.gson().serialize(baseComponent) // fineprintln(json1)
try {
val reserialized =MiniMessage.miniMessage().deserialize(MiniMessage.miniMessage().serialize(baseComponent))
GsonComponentSerializer.gson().serialize(reserialized)
} catch (e:Exception) {
e.printStackTrace()
}
results in
{"hoverEvent":{"action":"show_item","contents":{"id":"minecraft:diamond","count":1,"components":{"minecraft:lore":["\"my lore\""]}}},"translate":"item.minecraft.diamond"}
java.lang.IllegalArgumentException: There is no data holder converter registered to convert from a class net.kyori.adventure.nbt.api.BinaryTagHolderImpl instance to a interface net.kyori.adventure.text.serializer.gson.GsonDataComponentValue (on field minecraft:lore)
at net.kyori.adventure.text.event.DataComponentValueConverterRegistry.convert(DataComponentValueConverterRegistry.java:90)
at net.kyori.adventure.text.event.HoverEvent$ShowItem.dataComponentsAs(HoverEvent.java:623)
at net.kyori.adventure.text.serializer.gson.ShowItemSerializer.write(ShowItemSerializer.java:139)
at net.kyori.adventure.text.serializer.gson.ShowItemSerializer.write(ShowItemSerializer.java:49)
at com.google.gson.TypeAdapter$1.write(TypeAdapter.java:196)
at com.google.gson.Gson.toJson(Gson.java:842)
at net.kyori.adventure.text.serializer.gson.StyleSerializer.write(StyleSerializer.java:296)
at net.kyori.adventure.text.serializer.gson.StyleSerializer.write(StyleSerializer.java:62)
at com.google.gson.TypeAdapter$1.write(TypeAdapter.java:196)
at com.google.gson.Gson.toJson(Gson.java:842)
at com.google.gson.Gson.toJsonTree(Gson.java:712)
at net.kyori.adventure.text.serializer.gson.ComponentSerializerImpl.write(ComponentSerializerImpl.java:252)
at net.kyori.adventure.text.serializer.gson.ComponentSerializerImpl.write(ComponentSerializerImpl.java:77)
at com.google.gson.TypeAdapter$1.write(TypeAdapter.java:196)
at com.google.gson.Gson.toJson(Gson.java:842)
at com.google.gson.Gson.toJson(Gson.java:812)
at com.google.gson.Gson.toJson(Gson.java:759)
at com.google.gson.Gson.toJson(Gson.java:736)
at net.kyori.adventure.text.serializer.gson.GsonComponentSerializerImpl.serialize(GsonComponentSerializerImpl.java:104)
at net.kyori.adventure.text.serializer.gson.GsonComponentSerializerImpl.serialize(GsonComponentSerializerImpl.java:41)
The text was updated successfully, but these errors were encountered:
GsonComponentSerializer
will fail to serialize an ItemStack that has components if it was previously deserialized with minimessage.results in
The text was updated successfully, but these errors were encountered: