Skip to content

ResourceKeySerializer

class ResourceKeySerializer<T : Any>(val registry: ResourceKey<out Registry<T>>) : KSerializer<ResourceKey<*>> 

A KSerializer for ResourceKey of a specific registry.

The serialized form is a ResourceLocation string (the key's location).

Example

val DIMENSION_KEY_SERIALIZER = ResourceKeySerializer(Registries.DIMENSION)

Parameters

  • registry: The ResourceKey of the registry this serializer is scoped to.

Constructors

ResourceKeySerializer

constructor(registry: ResourceKey<out Registry<T>>)

Parameters

  • registry: The ResourceKey of the registry this serializer is scoped to.

Types

Companion

object Companion

Properties

descriptor

open override val descriptor: SerialDescriptor

registry

val registry: ResourceKey<out Registry<T>>

Parameters

  • registry: The ResourceKey of the registry this serializer is scoped to.

Functions

codec

inline fun <T : Any> codec(): Codec<T>
inline fun <T : Any> KSerializer<T>.codec(): Codec<T>

deserialize

open override fun deserialize(decoder: Decoder): ResourceKey<*>

getStreamCodec

inline fun <T : Any> KSerializer<T>.getStreamCodec(): StreamCodec<RegistryFriendlyByteBuf, T>

serialize

open override fun serialize(encoder: Encoder, value: ResourceKey<*>)