Interface CustomIngredientSerializer<T extends CustomIngredient>

Type Parameters:
T - the type of the custom ingredient

public interface CustomIngredientSerializer<T extends CustomIngredient>
Serializer for a CustomIngredient.

All instances must be registered using register(CustomIngredientSerializer) for deserialization to work.

  • Method Summary

    Modifier and Type
    Method
    Description
    static @Nullable CustomIngredientSerializer<?>
    get(net.minecraft.resources.Identifier identifier)
    Returns the custom ingredient serializer registered with the given identifier, or null if there is no such serializer.
    com.mojang.serialization.MapCodec<T>
    Returns the codec.
    net.minecraft.resources.Identifier
    Returns the identifier of this serializer.
    net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, T>
    Returns the stream codec for serializing this ingredient.
    static void
    Registers a custom ingredient serializer, using the serializer's identifier.
  • Method Details

    • register

      static void register(CustomIngredientSerializer<?> serializer)
      Registers a custom ingredient serializer, using the serializer's identifier.
      Throws:
      IllegalArgumentException - if the serializer is already registered
    • get

      static @Nullable CustomIngredientSerializer<?> get(net.minecraft.resources.Identifier identifier)
      Returns the custom ingredient serializer registered with the given identifier, or null if there is no such serializer..
      Returns:
      the custom ingredient serializer registered with the given identifier, or null if there is no such serializer
    • getIdentifier

      net.minecraft.resources.Identifier getIdentifier()
      Returns the identifier of this serializer..
      Returns:
      the identifier of this serializer
    • getCodec

      com.mojang.serialization.MapCodec<T> getCodec()
      Returns the codec..

      Codecs are used to read the ingredient from the recipe JSON files.

      Returns:
      the codec
      See Also:
      • Ingredient.CODEC
    • getStreamCodec

      net.minecraft.network.codec.StreamCodec<net.minecraft.network.RegistryFriendlyByteBuf, T> getStreamCodec()
      Returns the stream codec for serializing this ingredient..
      Returns:
      the stream codec for serializing this ingredient
      See Also:
      • Ingredient.CONTENTS_STREAM_CODEC