Interface UnbakedModelDeserializer
The format for custom unbaked models is as follows:
{
"fabric:type": "<identifier of the deserializer>",
// extra model data, dependent on the deserializer
}
Alternatively, "fabric:type" may be an object with the required string field "id", specifying the
identifier of the deserializer, and the optional boolean field "optional" with default false,
specifying whether the model should fail loading (false) or continue loading as a vanilla model
(true) when the specified deserializer has not been registered.
All instances must be registered using register(net.minecraft.util.Identifier, net.fabricmc.fabric.api.client.model.loading.v1.UnbakedModelDeserializer) for deserialization to work.
-
Method Summary
Modifier and TypeMethodDescriptiondeserialize(com.google.gson.JsonObject jsonObject, com.google.gson.JsonDeserializationContext context) Deserialize anUnbakedModelgiven aJsonObjectrepresenting the entire model file.static UnbakedModeldeserialize(Reader reader) Deserializes anUnbakedModelfrom aReader, respecting custom deserializers.static @Nullable UnbakedModelDeserializerget(Identifier id) Returns the custom model deserializer registered with the given identifier, ornullif there is no such deserializer.static voidregister(Identifier id, UnbakedModelDeserializer deserializer) Registers a custom model deserializer.
-
Method Details
-
register
Registers a custom model deserializer.- Throws:
IllegalArgumentException- if the deserializer is already registered
-
get
Returns the custom model deserializer registered with the given identifier, ornullif there is no such deserializer.- Returns:
- the custom model deserializer registered with the given identifier, or
nullif there is no such deserializer
-
deserialize
Deserializes anUnbakedModelfrom aReader, respecting custom deserializers. Prefer using this method toJsonUnbakedModel.deserialize(Reader).- Throws:
com.google.gson.JsonParseException
-
deserialize
UnbakedModel deserialize(com.google.gson.JsonObject jsonObject, com.google.gson.JsonDeserializationContext context) Deserialize anUnbakedModelgiven aJsonObjectrepresenting the entire model file.The provided deserialization context is able to deserialize objects of the following types:
For example, to deserialize a nested
UnbakedModel, usecontext.deserialize(nestedModelJson, UnbakedModel.class).This method is allowed and encouraged to throw exceptions, as they will be caught and logged by the caller.
- Parameters:
jsonObject- the JSON object representing the entire model filecontext- the deserialization context- Returns:
- the unbaked model
-