Skip to content

Serializer

class Serializer<I : ACombinedIngredient>(
    val identifier: ResourceLocation, 
    factory: Function<List<Ingredient>, I>, 
    allowEmptyCodec: MapCodec<I>, 
    disallowEmptyCodec: MapCodec<I>
) : IACustomIngredientSerializer<I> 

Generic IACustomIngredientSerializer for ACombinedIngredient subtypes, built from a factory and empty/non-empty codecs.

Constructors

Serializer

constructor(
    identifier: ResourceLocation, 
    factory: Function<List<Ingredient>, I>, 
    allowEmptyCodec: MapCodec<I>, 
    disallowEmptyCodec: MapCodec<I>
)

Properties

identifier

open override val identifier: ResourceLocation

The id this serializer is registered under; used to identify it in recipe JSON.

packetCodec

open override val packetCodec: StreamCodec<RegistryFriendlyByteBuf, I>

The codec used to sync the ingredient to the client over the network.

Functions

getCodec

open override fun getCodec(allowEmpty: Boolean): MapCodec<I>

The codec used to read the ingredient from recipe JSON files.

Parameters

  • allowEmpty: Whether an ingredient matching no items should be accepted, mirroring Ingredient.CODEC vs Ingredient.CODEC_NONEMPTY.