package org.betterx.bclib.client; import org.betterx.bclib.api.v2.ModIntegrationAPI; import org.betterx.bclib.api.v2.PostInitAPI; import org.betterx.bclib.api.v2.dataexchange.DataExchangeAPI; import org.betterx.bclib.client.models.CustomModelBakery; import org.betterx.bclib.client.textures.AtlasSetManager; import org.betterx.bclib.client.textures.SpriteLister; import org.betterx.bclib.config.Configs; import org.betterx.bclib.registry.BaseBlockEntityRenders; import org.betterx.bclib.registry.PresetsRegistryClient; import org.betterx.worlds.together.WorldsTogether; import org.betterx.worlds.together.client.WorldsTogetherClient; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.resources.ResourceLocation; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.model.*; import org.jetbrains.annotations.Nullable; public class BCLibClient implements ClientModInitializer, ModelResourceProvider, ModelVariantProvider { 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); ModelLoadingRegistry.INSTANCE.registerResourceProvider(rm -> this); ModelLoadingRegistry.INSTANCE.registerVariantProvider(rm -> this); PresetsRegistryClient.onLoad(); WorldsTogether.SURPRESS_EXPERIMENTAL_DIALOG = Configs.CLIENT_CONFIG.suppressExperimentalDialog(); AtlasSetManager.addSource(AtlasSetManager.VANILLA_BLOCKS, new SpriteLister("entity/chest")); AtlasSetManager.addSource(AtlasSetManager.VANILLA_BLOCKS, new SpriteLister("blocks")); } @Override public @Nullable UnbakedModel loadModelResource( ResourceLocation resourceId, ModelProviderContext context ) throws ModelProviderException { return modelBakery.getBlockModel(resourceId); } @Override public @Nullable UnbakedModel loadModelVariant( ModelResourceLocation modelId, ModelProviderContext context ) throws ModelProviderException { return modelId.getVariant().equals("inventory") ? modelBakery.getItemModel(modelId) : modelBakery.getBlockModel(modelId); } }