[Fix] CustomModelBakery could cause a crash when Resourcepacks are reloaded by another Mod before BCLib was initialized (#114)

This commit is contained in:
Frank 2023-07-08 11:01:26 +02:00
parent b189d8013e
commit c664a83ccf
2 changed files with 11 additions and 3 deletions

View file

@ -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);

View file

@ -20,6 +20,6 @@ public class ModelManagerMixin {
ProfilerFiller profilerFiller,
CallbackInfoReturnable<ModelBakery> info
) {
BCLibClient.modelBakery.loadCustomModels(resourceManager);
BCLibClient.lazyModelbakery().loadCustomModels(resourceManager);
}
}