Bake models with custom geometry at startup time
Fixes #18 (not the way I want though)
This commit is contained in:
parent
318afbe3bf
commit
7742a9507f
|
|
@ -76,6 +76,13 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
return ibakedmodel;
|
return ibakedmodel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean requiresBake(IUnbakedModel model) {
|
||||||
|
if(model instanceof BlockModel && ((BlockModel)model).customData.hasCustomGeometry())
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Inject(method = "processLoading", at = @At(value = "INVOKE", target = "Lnet/minecraft/profiler/IProfiler;pop()V"))
|
@Inject(method = "processLoading", at = @At(value = "INVOKE", target = "Lnet/minecraft/profiler/IProfiler;pop()V"))
|
||||||
private void bakeModels(IProfiler pProfiler, int p_i226056_4_, CallbackInfo ci) {
|
private void bakeModels(IProfiler pProfiler, int p_i226056_4_, CallbackInfo ci) {
|
||||||
pProfiler.popPush("atlas");
|
pProfiler.popPush("atlas");
|
||||||
|
|
@ -104,21 +111,20 @@ public abstract class ModelBakeryMixin implements IExtendedModelBakery {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/* Then store them as top-level models if needed, and set up the lazy models */
|
/* Then store them as top-level models if needed, and set up the lazy models */
|
||||||
this.topLevelModels.keySet().forEach((p_229350_1_) -> {
|
this.topLevelModels.forEach((location, value) -> {
|
||||||
if(incompatibleLazyBakedModels.contains(p_229350_1_.getNamespace())) {
|
if (incompatibleLazyBakedModels.contains(location.getNamespace()) || requiresBake(value)) {
|
||||||
IBakedModel model = this.bakeIfPossible(p_229350_1_);
|
IBakedModel model = this.bakeIfPossible(location);
|
||||||
if(model != null)
|
if (model != null)
|
||||||
this.bakedTopLevelModels.put(p_229350_1_, model);
|
this.bakedTopLevelModels.put(location, model);
|
||||||
} else {
|
} else {
|
||||||
this.bakedTopLevelModels.put(p_229350_1_, new LazyBakedModel(() -> {
|
this.bakedTopLevelModels.put(location, new LazyBakedModel(() -> {
|
||||||
synchronized (this.bakedCache) {
|
synchronized (this.bakedCache) {
|
||||||
IBakedModel ibakedmodel = this.bakeIfPossible(p_229350_1_);
|
IBakedModel ibakedmodel = this.bakeIfPossible(location);
|
||||||
|
|
||||||
return ibakedmodel != null ? ibakedmodel : missingModel;
|
return ibakedmodel != null ? ibakedmodel : missingModel;
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user