Split unbaked model load event into load and pre-bake stages
Allows mods like Continuity to wrap the model being baked separately from the model in the cache
This commit is contained in:
parent
be4c8607d4
commit
74eb8a0619
|
|
@ -34,6 +34,19 @@ public interface ModernFixClientIntegration {
|
||||||
return originalModel;
|
return originalModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called to allow mods to observe the use of an unbaked model at bake time 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
|
||||||
|
* @return the model which should actually be loaded for this resource location
|
||||||
|
*/
|
||||||
|
default UnbakedModel onUnbakedModelPreBake(ResourceLocation location, UnbakedModel originalModel, 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
|
* 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.
|
* own instance.
|
||||||
|
|
|
||||||
|
|
@ -448,6 +448,17 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
|
|
||||||
if(iunbakedmodel == missingModel && debugDynamicModelLoading)
|
if(iunbakedmodel == missingModel && debugDynamicModelLoading)
|
||||||
LOGGER.warn("Model {} not present", arg);
|
LOGGER.warn("Model {} not present", arg);
|
||||||
|
|
||||||
|
if(iunbakedmodel != missingModel) {
|
||||||
|
for(ModernFixClientIntegration integration : ModernFixClient.CLIENT_INTEGRATIONS) {
|
||||||
|
try {
|
||||||
|
iunbakedmodel = integration.onUnbakedModelPreBake(arg, iunbakedmodel, (ModelBakery)(Object)this);
|
||||||
|
} catch(RuntimeException e) {
|
||||||
|
ModernFix.LOGGER.error("Exception firing model pre-bake event for {}", arg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BakedModel ibakedmodel = null;
|
BakedModel ibakedmodel = null;
|
||||||
if (iunbakedmodel instanceof BlockModel) {
|
if (iunbakedmodel instanceof BlockModel) {
|
||||||
BlockModel blockmodel = (BlockModel)iunbakedmodel;
|
BlockModel blockmodel = (BlockModel)iunbakedmodel;
|
||||||
|
|
|
||||||
|
|
@ -322,6 +322,17 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
iunbakedmodel.getMaterials(this::getModel, new HashSet<>());
|
iunbakedmodel.getMaterials(this::getModel, new HashSet<>());
|
||||||
if(iunbakedmodel == missingModel && debugDynamicModelLoading)
|
if(iunbakedmodel == missingModel && debugDynamicModelLoading)
|
||||||
LOGGER.warn("Model {} not present", arg);
|
LOGGER.warn("Model {} not present", arg);
|
||||||
|
|
||||||
|
if(iunbakedmodel != missingModel) {
|
||||||
|
for(ModernFixClientIntegration integration : ModernFixClient.CLIENT_INTEGRATIONS) {
|
||||||
|
try {
|
||||||
|
iunbakedmodel = integration.onUnbakedModelPreBake(arg, iunbakedmodel, (ModelBakery)(Object)this);
|
||||||
|
} catch(RuntimeException e) {
|
||||||
|
ModernFix.LOGGER.error("Exception encountered firing bake event for {}", arg, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BakedModel ibakedmodel = null;
|
BakedModel ibakedmodel = null;
|
||||||
if (iunbakedmodel instanceof BlockModel) {
|
if (iunbakedmodel instanceof BlockModel) {
|
||||||
BlockModel blockmodel = (BlockModel)iunbakedmodel;
|
BlockModel blockmodel = (BlockModel)iunbakedmodel;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user