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(net.fabricmc.fabric.api.recipe.v1.ingredient.CustomIngredientSerializer<?>) for deserialization to work.
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable CustomIngredientSerializer<?> get(Identifier identifier) Returns the custom ingredient serializer registered with the given identifier, ornullif there is no such serializer.com.mojang.serialization.Codec<T> getCodec(boolean allowEmpty) Returns the codec.Returns the identifier of this serializer.read(PacketByteBuf buf) Deserializes the custom ingredient from a packet buffer.static voidregister(CustomIngredientSerializer<?> serializer) Registers a custom ingredient serializer, using the serializer's identifier.voidwrite(PacketByteBuf buf, T ingredient) Serializes the custom ingredient to a packet buffer.
-
Method Details
-
register
Registers a custom ingredient serializer, using the serializer's identifier.- Throws:
IllegalArgumentException- if the serializer is already registered
-
get
Returns the custom ingredient serializer registered with the given identifier, ornullif there is no such serializer..- Returns:
- the custom ingredient serializer registered with the given identifier, or
nullif there is no such serializer
-
getIdentifier
Identifier getIdentifier()Returns the identifier of this serializer..- Returns:
- the identifier of this serializer
-
getCodec
Returns the codec..Codecs are used to read the ingredient from the recipe JSON files.
- Returns:
- the codec
- See Also:
-
read
Deserializes the custom ingredient from a packet buffer. -
write
Serializes the custom ingredient to a packet buffer.
-