Clarify nullability of ModelModifier.AfterBake ()

* Clarify nullability of AfterBake modifier

* Fix documentation

Null baked models are cached, but only in the inner cache, which is not accessible after all baking is finished. The term "cache" is also ambiguous, so its use has been removed.

* Add breaks for v0 <0.4.0
This commit is contained in:
PepperCode1 2023-07-25 07:04:00 -06:00 committed by GitHub
parent 4df89eb2a6
commit 709a9871d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions
fabric-model-loading-api-v1/src/client
java/net/fabricmc/fabric
api/client/model/loading/v1
impl/client/model/loading
resources

View file

@ -19,6 +19,7 @@ package net.fabricmc.fabric.api.client.model.loading.v1;
import java.util.function.Function;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.Baker;
@ -168,6 +169,10 @@ public final class ModelModifier {
* This handler is invoked to allow modification of the baked model instance right after it is baked and before
* it is cached.
*
* <p>Note that the passed baked model may be null and that this handler may return a null baked model, since
* {@link UnbakedModel#bake} and {@link Baker#bake} may also return null baked models. Null baked models are
* automatically mapped to the missing model during model retrieval.
*
* <p>For further information, see the docs of {@link ModelLoadingPlugin.Context#modifyModelAfterBake()}.
*
* @param model the current baked model instance
@ -175,7 +180,8 @@ public final class ModelModifier {
* @return the model that should be used in this scenario. If no changes are needed, just return {@code model} as-is.
* @see ModelLoadingPlugin.Context#modifyModelAfterBake
*/
BakedModel modifyModelAfterBake(BakedModel model, Context context);
@Nullable
BakedModel modifyModelAfterBake(@Nullable BakedModel model, Context context);
/**
* The context for an after bake model modification event.

View file

@ -279,7 +279,8 @@ public class ModelLoadingEventDispatcher {
return model;
}
public BakedModel modifyModelAfterBake(BakedModel model, Identifier id, UnbakedModel sourceModel, Function<SpriteIdentifier, Sprite> textureGetter, ModelBakeSettings settings, Baker baker) {
@Nullable
public BakedModel modifyModelAfterBake(@Nullable BakedModel model, Identifier id, UnbakedModel sourceModel, Function<SpriteIdentifier, Sprite> textureGetter, ModelBakeSettings settings, Baker baker) {
if (afterBakeModifierContextStack.isEmpty()) {
afterBakeModifierContextStack.add(new AfterBakeModifierContext());
}

View file

@ -19,6 +19,9 @@
"fabricloader": ">=0.14.21",
"fabric-api-base": "*"
},
"breaks": {
"fabric-models-v0": "<0.4.0"
},
"description": "Provides hooks for model loading.",
"mixins": [
{