Class TagKeyCodecResolver
java.lang.Object
dev.scsupercraft.mc.libraries.corelib.serialization.resolver.unique.TagKeyCodecResolver
- All Implemented Interfaces:
CodecResolver
A codec resolver for
Annotate a type with
If not included upon serialization, the registry ref will be serialized with the tag instead.
Without @RegistryRef("block") - {"data": {"registryRef": "minecraft:block", id: "minecraft:needs_iron_tool"}}
With @RegistryRef("block") - {"data": "#minecraft:needs_iron_tool"}
TagKeys
Annotate a type with
RegistryRef to tell the codec resolver what registry the tag is for.
Not required but highly recommended.
If not included upon serialization, the registry ref will be serialized with the tag instead.
Without @RegistryRef("block") - {"data": {"registryRef": "minecraft:block", id: "minecraft:needs_iron_tool"}}
With @RegistryRef("block") - {"data": "#minecraft:needs_iron_tool"}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> @NotNull CodecHolder<T> resolveCodec(GenericClass<T> genericClass) Resolves a codec for the provided generic class.booleansupportsValue(GenericClass<?> genericClass) Is the generic class supported by this codec resolver?
-
Constructor Details
-
TagKeyCodecResolver
public TagKeyCodecResolver()Creates a newTagKeyCodecResolver.
-
-
Method Details
-
supportsValue
Description copied from interface:CodecResolverIs the generic class supported by this codec resolver?- Specified by:
supportsValuein interfaceCodecResolver- Parameters:
genericClass- The generic class.- Returns:
- Is the generic class supported?
-
resolveCodec
Description copied from interface:CodecResolverResolves a codec for the provided generic class.Called only if
CodecResolver.supportsValue(GenericClass)returned true.- Specified by:
resolveCodecin interfaceCodecResolver- Type Parameters:
T- The type of class contained in the generic class.- Parameters:
genericClass- The generic class.- Returns:
- A codec holder containing the codecs for the provided generic class.
-