diff --git a/fabric-model-loading-api-v1/build.gradle b/fabric-model-loading-api-v1/build.gradle index ca3eb5eb1..3d2819264 100644 --- a/fabric-model-loading-api-v1/build.gradle +++ b/fabric-model-loading-api-v1/build.gradle @@ -4,6 +4,7 @@ moduleDependencies(project, ['fabric-api-base']) testDependencies(project, [ ':fabric-renderer-api-v1', + ':fabric-renderer-indigo', ':fabric-rendering-v1', ':fabric-resource-loader-v0' ]) diff --git a/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/BlockStateResolver.java b/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/BlockStateResolver.java index dacd2f1a4..4f350e43d 100644 --- a/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/BlockStateResolver.java +++ b/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/BlockStateResolver.java @@ -22,7 +22,6 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.render.model.ModelLoader; import net.minecraft.client.render.model.UnbakedModel; -import net.minecraft.client.util.ModelIdentifier; import net.minecraft.util.Identifier; /** @@ -72,7 +71,7 @@ public interface BlockStateResolver { void setModel(BlockState state, UnbakedModel model); /** - * Loads a model using an {@link Identifier} or {@link ModelIdentifier}, or gets it if it was already loaded. + * Loads a model using an {@link Identifier}, or gets it if it was already loaded. * * @param id the model identifier * @return the unbaked model, or a missing model if it is not present @@ -81,9 +80,6 @@ public interface BlockStateResolver { /** * The current model loader instance, which changes between resource reloads. - * - *

Do not call {@link ModelLoader#getOrLoadModel} as it does not supported nested model resolution; - * use {@link #getOrLoadModel} from the context instead. */ ModelLoader loader(); } diff --git a/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/DelegatingUnbakedModel.java b/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/DelegatingUnbakedModel.java index ee37263fd..081f5f6a0 100644 --- a/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/DelegatingUnbakedModel.java +++ b/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/DelegatingUnbakedModel.java @@ -27,7 +27,6 @@ import net.minecraft.client.render.model.Baker; import net.minecraft.client.render.model.ModelBakeSettings; import net.minecraft.client.render.model.UnbakedModel; import net.minecraft.client.texture.Sprite; -import net.minecraft.client.util.ModelIdentifier; import net.minecraft.client.util.SpriteIdentifier; import net.minecraft.util.Identifier; @@ -43,7 +42,7 @@ public final class DelegatingUnbakedModel implements UnbakedModel { /** * Constructs a new delegating model. * - * @param delegate The identifier (can be a {@link ModelIdentifier}) of the underlying baked model. + * @param delegate The identifier of the underlying baked model. */ public DelegatingUnbakedModel(Identifier delegate) { this.delegate = delegate; @@ -57,11 +56,12 @@ public final class DelegatingUnbakedModel implements UnbakedModel { @Override public void setParents(Function modelLoader) { + modelLoader.apply(delegate).setParents(modelLoader); } - @Nullable @Override - public BakedModel bake(Baker baker, Function textureGetter, ModelBakeSettings rotationContainer, Identifier modelId) { + @Nullable + public BakedModel bake(Baker baker, Function textureGetter, ModelBakeSettings rotationContainer) { return baker.bake(delegate, rotationContainer); } } diff --git a/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/FabricBakedModelManager.java b/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/FabricBakedModelManager.java index dbc5e0c4c..e0b8caba0 100644 --- a/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/FabricBakedModelManager.java +++ b/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/FabricBakedModelManager.java @@ -16,8 +16,6 @@ package net.fabricmc.fabric.api.client.model.loading.v1; -import org.jetbrains.annotations.Nullable; - import net.minecraft.client.render.model.BakedModel; import net.minecraft.client.render.model.BakedModelManager; import net.minecraft.client.util.ModelIdentifier; @@ -30,20 +28,18 @@ import net.minecraft.util.Identifier; */ public interface FabricBakedModelManager { /** - * An alternative to {@link BakedModelManager#getModel(ModelIdentifier)} that accepts an - * {@link Identifier} instead. Models loaded using {@link ModelLoadingPlugin.Context#addModels} - * do not have a corresponding {@link ModelIdentifier}, so the vanilla method cannot be used to - * retrieve them. The {@link Identifier} that was used to load them can be used in this method - * to retrieve them. + * Similar to {@link BakedModelManager#getModel(ModelIdentifier)}, but accepts an {@link Identifier} instead of a + * {@link ModelIdentifier}. Use this method to retrieve models loaded using + * {@link ModelLoadingPlugin.Context#addModels}, since those models do not have corresponding + * {@link ModelIdentifier}s. * *

This method, as well as its vanilla counterpart, should only be used after the * {@link BakedModelManager} has completed reloading. Otherwise, the result will be - * outdated or null. + * outdated or an exception will be thrown. * * @param id the id of the model * @return the model */ - @Nullable default BakedModel getModel(Identifier id) { throw new UnsupportedOperationException("Implemented via mixin."); } diff --git a/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/ModelLoadingPlugin.java b/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/ModelLoadingPlugin.java index 002deb2fa..5d15c8428 100644 --- a/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/ModelLoadingPlugin.java +++ b/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/ModelLoadingPlugin.java @@ -22,7 +22,6 @@ import org.jetbrains.annotations.ApiStatus; import net.minecraft.block.Block; import net.minecraft.client.render.model.json.JsonUnbakedModel; -import net.minecraft.client.util.ModelIdentifier; import net.minecraft.resource.ResourceManager; import net.minecraft.util.Identifier; @@ -53,13 +52,14 @@ public interface ModelLoadingPlugin { @ApiStatus.NonExtendable interface Context { /** - * Adds one or more models (can be {@link ModelIdentifier}s) to the list of models that will be loaded and - * baked. + * Adds one or more models that will be loaded, baked, and made available through + * {@link FabricBakedModelManager#getModel(Identifier)}. */ void addModels(Identifier... ids); /** - * Adds multiple models (can be {@link ModelIdentifier}s) to the list of models that will be loaded and baked. + * Adds multiple models that will be loaded, baked, and made available through + * {@link FabricBakedModelManager#getModel(Identifier)}. */ void addModels(Collection ids); diff --git a/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/ModelModifier.java b/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/ModelModifier.java index da6777996..0d8596b6d 100644 --- a/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/ModelModifier.java +++ b/fabric-model-loading-api-v1/src/client/java/net/fabricmc/fabric/api/client/model/loading/v1/ModelModifier.java @@ -20,6 +20,7 @@ import java.util.function.Function; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.UnknownNullability; import net.minecraft.client.render.model.BakedModel; import net.minecraft.client.render.model.Baker; @@ -39,7 +40,7 @@ import net.fabricmc.fabric.api.event.Event; * *

Example use cases: *