Skip to content

Commit

Permalink
Add textureGetter parameter to onBakedModelLoad
Browse files Browse the repository at this point in the history
  • Loading branch information
embeddedt committed Jan 24, 2024
1 parent a100622 commit 55cb94f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
@@ -1,11 +1,11 @@
package org.embeddedt.modernfix.api.entrypoint;

import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelState;
import net.minecraft.client.resources.model.UnbakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.resources.model.*;
import net.minecraft.resources.ResourceLocation;

import java.util.function.Function;


/**
* Implement this interface in a mod class and add it to "modernfix:integration_v1" in your mod metadata file
Expand Down Expand Up @@ -56,7 +56,22 @@ default UnbakedModel onUnbakedModelPreBake(ResourceLocation location, UnbakedMod
* with dynamic resources on
* @return the model which should actually be loaded for this resource location
*/
@Deprecated
default BakedModel onBakedModelLoad(ResourceLocation location, UnbakedModel baseModel, BakedModel originalModel, ModelState state, ModelBakery bakery) {
return originalModel;
}

/**
* Called to allow mods to observe the loading of a baked model and either make changes to it or wrap it with their
* own instance.
* @param location the ResourceLocation of the model (this may be a ModelResourceLocation)
* @param originalModel the original model
* @param bakery the model bakery - do not touch internal fields as they probably don't behave the way you expect
* with dynamic resources on
* @param textureGetter function to retrieve textures for this model
* @return the model which should actually be loaded for this resource location
*/
default BakedModel onBakedModelLoad(ResourceLocation location, UnbakedModel baseModel, BakedModel originalModel, ModelState state, ModelBakery bakery, Function<Material, TextureAtlasSprite> textureGetter) {
return onBakedModelLoad(location, baseModel, originalModel, state, bakery);
}
}
Expand Up @@ -120,7 +120,7 @@ private BakedModel callBakedModelIntegration(UnbakedModel unbakedModel, ModelBak
BakedModel model = operation.call(unbakedModel, baker, spriteGetter, state, location);

for(ModernFixClientIntegration integration : ModernFixClient.CLIENT_INTEGRATIONS) {
model = integration.onBakedModelLoad(location, unbakedModel, model, state, this.field_40571);
model = integration.onBakedModelLoad(location, unbakedModel, model, state, this.field_40571, spriteGetter);
}

return model;
Expand Down
Expand Up @@ -94,7 +94,7 @@ private BakedModel callBakedModelIntegration(UnbakedModel unbakedModel, ModelBak
BakedModel model = operation.call(unbakedModel, baker, spriteGetter, state, location);

for(ModernFixClientIntegration integration : ModernFixClient.CLIENT_INTEGRATIONS) {
model = integration.onBakedModelLoad(location, unbakedModel, model, state, this.field_40571);
model = integration.onBakedModelLoad(location, unbakedModel, model, state, this.field_40571, spriteGetter);
}

return model;
Expand Down

0 comments on commit 55cb94f

Please sign in to comment.