[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 7bb7a1cb62
commit 15279dd5cd
2 changed files with 11 additions and 4 deletions

View file

@ -22,16 +22,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

@ -27,7 +27,6 @@ public class ModelManagerMixin {
Executor executor2,
CallbackInfoReturnable<CompletableFuture<Void>> cir
) {
//TODO: 1.20 check
BCLibClient.modelBakery.loadCustomModels(resourceManager);
BCLibClient.lazyModelbakery().loadCustomModels(resourceManager);
}
}