Skip to content

Commit

Permalink
fix(common): Add DCV converter for MM -> Gson
Browse files Browse the repository at this point in the history
  • Loading branch information
zml2008 committed Dec 22, 2024
1 parent 2790357 commit 07f187d
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,20 @@ public final class DataComponentValueConverterProvider implements DataComponentV
DataComponentValue.Removed.class,
ModDataComponentValue.class,
(k, $) -> ModDataComponentValue.Removed.INSTANCE
),
DataComponentValueConverterRegistry.Conversion.convert(
DataComponentValue.TagSerializable.class,
GsonDataComponentValue.class,
(k, tagSerializable) -> {
final Tag decodedSnbt;
try {
decodedSnbt = tagSerializable.asBinaryTag().get(ModDataComponentValue.SNBT_CODEC);
} catch (final CommandSyntaxException ex) {
throw new IllegalArgumentException("Unable to parse SNBT value", ex);
}

return GsonDataComponentValue.gsonDataComponentValue(NbtOps.INSTANCE.convertTo(JsonOps.INSTANCE, decodedSnbt));
}
)
);
}
Expand Down

0 comments on commit 07f187d

Please sign in to comment.