Skip to content

Commit 55cb94f

Browse files
committed
Add textureGetter parameter to onBakedModelLoad
1 parent a100622 commit 55cb94f

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

common/src/main/java/org/embeddedt/modernfix/api/entrypoint/ModernFixClientIntegration.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package org.embeddedt.modernfix.api.entrypoint;
22

3-
import net.minecraft.client.resources.model.BakedModel;
4-
import net.minecraft.client.resources.model.ModelBakery;
5-
import net.minecraft.client.resources.model.ModelState;
6-
import net.minecraft.client.resources.model.UnbakedModel;
3+
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
4+
import net.minecraft.client.resources.model.*;
75
import net.minecraft.resources.ResourceLocation;
86

7+
import java.util.function.Function;
8+
99

1010
/**
1111
* Implement this interface in a mod class and add it to "modernfix:integration_v1" in your mod metadata file
@@ -56,7 +56,22 @@ default UnbakedModel onUnbakedModelPreBake(ResourceLocation location, UnbakedMod
5656
* with dynamic resources on
5757
* @return the model which should actually be loaded for this resource location
5858
*/
59+
@Deprecated
5960
default BakedModel onBakedModelLoad(ResourceLocation location, UnbakedModel baseModel, BakedModel originalModel, ModelState state, ModelBakery bakery) {
6061
return originalModel;
6162
}
63+
64+
/**
65+
* Called to allow mods to observe the loading of a baked model and either make changes to it or wrap it with their
66+
* own instance.
67+
* @param location the ResourceLocation of the model (this may be a ModelResourceLocation)
68+
* @param originalModel the original model
69+
* @param bakery the model bakery - do not touch internal fields as they probably don't behave the way you expect
70+
* with dynamic resources on
71+
* @param textureGetter function to retrieve textures for this model
72+
* @return the model which should actually be loaded for this resource location
73+
*/
74+
default BakedModel onBakedModelLoad(ResourceLocation location, UnbakedModel baseModel, BakedModel originalModel, ModelState state, ModelBakery bakery, Function<Material, TextureAtlasSprite> textureGetter) {
75+
return onBakedModelLoad(location, baseModel, originalModel, state, bakery);
76+
}
6277
}

fabric/src/main/java/org/embeddedt/modernfix/fabric/mixin/perf/dynamic_resources/ModelBakerImplMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private BakedModel callBakedModelIntegration(UnbakedModel unbakedModel, ModelBak
120120
BakedModel model = operation.call(unbakedModel, baker, spriteGetter, state, location);
121121

122122
for(ModernFixClientIntegration integration : ModernFixClient.CLIENT_INTEGRATIONS) {
123-
model = integration.onBakedModelLoad(location, unbakedModel, model, state, this.field_40571);
123+
model = integration.onBakedModelLoad(location, unbakedModel, model, state, this.field_40571, spriteGetter);
124124
}
125125

126126
return model;

forge/src/main/java/org/embeddedt/modernfix/forge/mixin/perf/dynamic_resources/ModelBakerImplMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private BakedModel callBakedModelIntegration(UnbakedModel unbakedModel, ModelBak
9494
BakedModel model = operation.call(unbakedModel, baker, spriteGetter, state, location);
9595

9696
for(ModernFixClientIntegration integration : ModernFixClient.CLIENT_INTEGRATIONS) {
97-
model = integration.onBakedModelLoad(location, unbakedModel, model, state, this.field_40571);
97+
model = integration.onBakedModelLoad(location, unbakedModel, model, state, this.field_40571, spriteGetter);
9898
}
9999

100100
return model;

0 commit comments

Comments
 (0)