Skip to content

Commit

Permalink
Clarify nullability of AfterBake modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
PepperCode1 committed Jul 21, 2023
1 parent e3d1b5f commit b94c2fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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;
Expand Down Expand Up @@ -168,14 +169,19 @@ public interface AfterBake {
* 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} may also return a null baked model. Null baked models are not cached; if a baked
* model for a particular ID is queried but does not exist in the cache, the missing model is returned.
*
* <p>For further information, see the docs of {@link ModelLoadingPlugin.Context#modifyModelAfterBake()}.
*
* @param model the current baked model instance
* @param context context with additional information about the model/loader
* @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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,8 @@ public UnbakedModel modifyModelBeforeBake(UnbakedModel model, Identifier id, Fun
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());
}
Expand Down

0 comments on commit b94c2fa

Please sign in to comment.