[Fix] CustomModelBakery could cause a crash when Resourcepacks are reloaded by another Mod before BCLib was initialized (#114)
This commit is contained in:
parent
b189d8013e
commit
c664a83ccf
2 changed files with 11 additions and 3 deletions
|
@ -20,16 +20,24 @@ import net.fabricmc.fabric.api.client.model.*;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class BCLibClient implements ClientModInitializer, ModelResourceProvider, ModelVariantProvider {
|
||||
public static CustomModelBakery modelBakery;
|
||||
private static CustomModelBakery modelBakery;
|
||||
|
||||
public static CustomModelBakery lazyModelbakery() {
|
||||
if (modelBakery == null) {
|
||||
modelBakery = new CustomModelBakery();
|
||||
}
|
||||
return modelBakery;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInitializeClient() {
|
||||
modelBakery = new CustomModelBakery();
|
||||
|
||||
WorldsTogetherClient.onInitializeClient();
|
||||
ModIntegrationAPI.registerAll();
|
||||
BaseBlockEntityRenders.register();
|
||||
DataExchangeAPI.prepareClientside();
|
||||
PostInitAPI.postInit(true);
|
||||
modelBakery = new CustomModelBakery();
|
||||
ModelLoadingRegistry.INSTANCE.registerResourceProvider(rm -> this);
|
||||
ModelLoadingRegistry.INSTANCE.registerVariantProvider(rm -> this);
|
||||
|
||||
|
|
|
@ -20,6 +20,6 @@ public class ModelManagerMixin {
|
|||
ProfilerFiller profilerFiller,
|
||||
CallbackInfoReturnable<ModelBakery> info
|
||||
) {
|
||||
BCLibClient.modelBakery.loadCustomModels(resourceManager);
|
||||
BCLibClient.lazyModelbakery().loadCustomModels(resourceManager);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue