2018-06-06 15:37:56 +00:00
|
|
|
/*
|
|
|
|
* Minecraft Forge
|
2019-02-10 22:57:03 +00:00
|
|
|
* Copyright (c) 2016-2019.
|
2018-06-06 15:37:56 +00:00
|
|
|
*
|
|
|
|
* 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;
|
2018-09-05 00:23:45 +00:00
|
|
|
import net.minecraft.client.resources.DownloadingPackFinder;
|
2019-05-23 23:02:15 +00:00
|
|
|
import net.minecraft.client.resources.ClientResourcePackInfo;
|
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;
|
2019-03-11 22:32:37 +00:00
|
|
|
import net.minecraftforge.common.ForgeConfig;
|
2019-05-12 17:07:17 +00:00
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
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;
|
2019-03-11 22:32:37 +00:00
|
|
|
import net.minecraftforge.fml.ModLoadingWarning;
|
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;
|
2018-10-06 01:42:15 +00:00
|
|
|
import net.minecraftforge.fml.packs.ResourcePackLoader;
|
2019-03-11 22:32:37 +00:00
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
import com.mojang.blaze3d.platform.GlStateManager;
|
|
|
|
|
2019-03-11 22:32:37 +00:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import static net.minecraftforge.fml.loading.LogMarkers.LOADING;
|
2018-06-06 15:37:56 +00:00
|
|
|
|
2018-06-21 19:37:32 +00:00
|
|
|
@OnlyIn(Dist.CLIENT)
|
2018-06-06 15:37:56 +00:00
|
|
|
public class ClientModLoader
|
|
|
|
{
|
2019-03-11 22:32:37 +00:00
|
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
2018-06-19 18:04:05 +00:00
|
|
|
private static boolean loading;
|
|
|
|
private static Minecraft mc;
|
2018-09-29 01:07:46 +00:00
|
|
|
private static LoadingFailedException error;
|
2018-06-19 18:04:05 +00:00
|
|
|
|
2019-05-23 23:02:15 +00:00
|
|
|
public static void begin(final Minecraft minecraft, final ResourcePackList<ClientResourcePackInfo> defaultResourcePacks, final IReloadableResourceManager mcResourceManager, DownloadingPackFinder metadataSerializer)
|
2018-06-06 15:37:56 +00:00
|
|
|
{
|
2018-06-19 18:04:05 +00:00
|
|
|
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) {
|
2019-05-12 17:07:17 +00:00
|
|
|
MinecraftForge.EVENT_BUS.shutdown();
|
2018-09-29 01:07:46 +00:00
|
|
|
error = e;
|
2019-06-16 07:48:38 +00:00
|
|
|
TEMP_printLoadingExceptions(e);
|
2018-09-29 01:07:46 +00:00
|
|
|
}
|
2018-06-23 02:45:01 +00:00
|
|
|
ResourcePackLoader.loadResourcePacks(defaultResourcePacks);
|
2018-06-06 15:37:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void end()
|
|
|
|
{
|
2018-09-29 01:07:46 +00:00
|
|
|
try {
|
|
|
|
ModLoader.get().finishMods();
|
|
|
|
} catch (LoadingFailedException e) {
|
2019-05-12 17:07:17 +00:00
|
|
|
MinecraftForge.EVENT_BUS.shutdown();
|
2018-09-29 01:07:46 +00:00
|
|
|
if (error == null) error = e;
|
2019-06-16 07:48:38 +00:00
|
|
|
TEMP_printLoadingExceptions(e);
|
2018-09-29 01:07:46 +00:00
|
|
|
}
|
2018-06-19 18:04:05 +00:00
|
|
|
loading = false;
|
|
|
|
mc.gameSettings.loadOptions();
|
2018-06-06 15:37:56 +00:00
|
|
|
}
|
|
|
|
|
2018-06-11 01:12:46 +00:00
|
|
|
public static VersionChecker.Status checkForUpdates()
|
2018-06-06 15:37:56 +00:00
|
|
|
{
|
2018-06-11 01:12:46 +00:00
|
|
|
return VersionChecker.Status.UP_TO_DATE;
|
2018-06-06 15:37:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static void complete()
|
|
|
|
{
|
2019-05-23 23:02:15 +00:00
|
|
|
GlStateManager.disableTexture();
|
|
|
|
GlStateManager.enableTexture();
|
2019-03-11 22:32:37 +00:00
|
|
|
List<ModLoadingWarning> warnings = ModLoader.get().getWarnings();
|
2019-03-23 00:58:10 +00:00
|
|
|
boolean showWarnings = true;
|
|
|
|
try {
|
|
|
|
showWarnings = ForgeConfig.CLIENT.showLoadWarnings.get();
|
|
|
|
} catch (NullPointerException e) {
|
|
|
|
// We're in an early error state, config is not available. Assume true.
|
|
|
|
}
|
|
|
|
if (!showWarnings) {
|
2019-03-11 22:32:37 +00:00
|
|
|
//User disabled warning screen, as least log them
|
|
|
|
if (!warnings.isEmpty()) {
|
|
|
|
LOGGER.warn(LOADING, "Mods loaded with {} warning(s)", warnings.size());
|
|
|
|
warnings.forEach(warning -> LOGGER.warn(LOADING, warning.formatToString()));
|
|
|
|
}
|
|
|
|
warnings = Collections.emptyList(); //Clear warnings, as the user does not want to see them
|
|
|
|
}
|
|
|
|
if (error != null || !warnings.isEmpty()) {
|
|
|
|
mc.displayGuiScreen(new LoadingErrorScreen(error, warnings));
|
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
|
|
|
}
|
2018-06-19 18:04:05 +00:00
|
|
|
|
|
|
|
public static boolean isLoading()
|
|
|
|
{
|
|
|
|
return loading;
|
|
|
|
}
|
2019-06-16 07:48:38 +00:00
|
|
|
|
|
|
|
private static void TEMP_printLoadingExceptions(LoadingFailedException error)
|
|
|
|
{
|
|
|
|
error.getErrors().forEach(e -> LOGGER.error("Exception: " + e.formatToString()));
|
|
|
|
throw new RuntimeException(error);
|
|
|
|
}
|
2018-06-06 15:37:56 +00:00
|
|
|
}
|