ForgePatch/src/main/java/net/minecraftforge/fml/client/ClientModLoader.java

91 lines
3.0 KiB
Java
Raw Normal View History

/*
* Minecraft Forge
* Copyright (c) 2016-2019.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation version 2.1
* of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package net.minecraftforge.fml.client;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
2018-09-05 00:23:45 +00:00
import net.minecraft.client.resources.DownloadingPackFinder;
import net.minecraft.client.resources.ResourcePackInfoClient;
2018-08-27 17:10:07 +00:00
import net.minecraft.resources.IReloadableResourceManager;
2018-09-05 00:23:45 +00:00
import net.minecraft.resources.ResourcePackList;
2018-06-21 19:37:32 +00:00
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
2018-09-29 01:07:46 +00:00
import net.minecraftforge.fml.LoadingFailedException;
2018-06-23 02:45:01 +00:00
import net.minecraftforge.fml.LogicalSidedProvider;
2018-09-29 01:07:46 +00:00
import net.minecraftforge.fml.ModLoader;
2018-06-11 01:12:46 +00:00
import net.minecraftforge.fml.SidedProvider;
import net.minecraftforge.fml.VersionChecker;
2018-09-29 01:07:46 +00:00
import net.minecraftforge.fml.client.gui.LoadingErrorScreen;
import net.minecraftforge.fml.packs.ResourcePackLoader;
2018-06-21 19:37:32 +00:00
@OnlyIn(Dist.CLIENT)
public class ClientModLoader
{
private static boolean loading;
private static Minecraft mc;
2018-09-29 01:07:46 +00:00
private static LoadingFailedException error;
2018-09-05 00:23:45 +00:00
public static void begin(final Minecraft minecraft, final ResourcePackList<ResourcePackInfoClient> defaultResourcePacks, final IReloadableResourceManager mcResourceManager, DownloadingPackFinder metadataSerializer)
{
loading = true;
ClientModLoader.mc = minecraft;
2018-06-11 01:12:46 +00:00
SidedProvider.setClient(()->minecraft);
2018-06-23 02:45:01 +00:00
LogicalSidedProvider.setClient(()->minecraft);
2018-09-29 01:07:46 +00:00
try {
ModLoader.get().loadMods();
} catch (LoadingFailedException e) {
error = e;
}
2018-06-23 02:45:01 +00:00
ResourcePackLoader.loadResourcePacks(defaultResourcePacks);
}
public static void end()
{
2018-09-29 01:07:46 +00:00
try {
ModLoader.get().finishMods();
} catch (LoadingFailedException e) {
if (error == null) error = e;
}
loading = false;
mc.gameSettings.loadOptions();
}
2018-06-11 01:12:46 +00:00
public static VersionChecker.Status checkForUpdates()
{
2018-06-11 01:12:46 +00:00
return VersionChecker.Status.UP_TO_DATE;
}
public static void complete()
{
GlStateManager.disableTexture2D();
GlStateManager.enableTexture2D();
2018-09-29 01:07:46 +00:00
if (error != null) {
mc.displayGuiScreen(new LoadingErrorScreen(error));
2018-12-21 22:45:35 +00:00
} else {
ClientHooks.logMissingTextureErrors();
2018-09-29 01:07:46 +00:00
}
2018-06-11 01:12:46 +00:00
}
public static boolean isLoading()
{
return loading;
}
}