mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 19:39:22 +00:00
Give immediate and complete error messages when there is a crash during startup (#4869)
This commit is contained in:
1 parent
ad099a4bfe
commit
979797a2a6
12 files changed
+309
-256
No files matched your search
+8
-1
@@ -21,6 +21,7 @@ package net.minecraftforge.fml.client;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiErrorScreen;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.common.EnhancedRuntimeException;
|
||||
import net.minecraftforge.fml.common.IFMLHandledException;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
@@ -37,7 +38,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
*
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
public abstract class CustomModLoadingErrorDisplayException extends EnhancedRuntimeException implements IFMLHandledException
|
||||
public abstract class CustomModLoadingErrorDisplayException extends EnhancedRuntimeException implements IFMLHandledException, IDisplayableError
|
||||
{
|
||||
public CustomModLoadingErrorDisplayException() {
|
||||
}
|
||||
@@ -72,4 +73,10 @@ public abstract class CustomModLoadingErrorDisplayException extends EnhancedRunt
|
||||
public abstract void drawScreen(GuiErrorScreen errorScreen, FontRenderer fontRenderer, int mouseRelX, int mouseRelY, float tickTime);
|
||||
|
||||
@Override public void printStackTrace(EnhancedRuntimeException.WrappedPrintStream s){}; // Do Nothing unless the modder wants to.
|
||||
|
||||
@Override
|
||||
public final GuiScreen createGui()
|
||||
{
|
||||
return new GuiCustomModLoadingErrorScreen(this);
|
||||
}
|
||||
}
|
||||
@@ -112,6 +112,7 @@ import net.minecraftforge.registries.GameData;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.message.FormattedMessage;
|
||||
import org.lwjgl.LWJGLUtil;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.Display;
|
||||
@@ -171,19 +172,13 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
|
||||
private DummyModContainer optifineContainer;
|
||||
|
||||
@Deprecated // TODO remove in 1.13. mods are referencing this to get around client-only dependencies in old Forge versions
|
||||
private MissingModsException modsMissing;
|
||||
|
||||
private ModSortingException modSorting;
|
||||
|
||||
private boolean loading = true;
|
||||
|
||||
private WrongMinecraftVersionException wrongMC;
|
||||
|
||||
private CustomModLoadingErrorDisplayException customError;
|
||||
|
||||
private DuplicateModsFoundException dupesFound;
|
||||
|
||||
private MultipleModsErrored multipleModsErrored;
|
||||
@Nullable
|
||||
private IDisplayableError errorToDisplay;
|
||||
|
||||
private boolean serverShouldBeKilledQuietly;
|
||||
|
||||
@@ -209,7 +204,6 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
* @param resourcePackList The resource pack list we will populate with mods
|
||||
* @param resourceManager The resource manager
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void beginMinecraftLoading(Minecraft minecraft, List<IResourcePack> resourcePackList, IReloadableResourceManager resourceManager, MetadataSerializer metaSerializer)
|
||||
{
|
||||
detectOptifine();
|
||||
@@ -230,30 +224,11 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
{
|
||||
Loader.instance().loadMods(injectedModContainers);
|
||||
}
|
||||
catch (WrongMinecraftVersionException wrong)
|
||||
catch (WrongMinecraftVersionException | DuplicateModsFoundException | MissingModsException | ModSortingException | CustomModLoadingErrorDisplayException | MultipleModsErrored e)
|
||||
{
|
||||
wrongMC = wrong;
|
||||
}
|
||||
catch (DuplicateModsFoundException dupes)
|
||||
{
|
||||
dupesFound = dupes;
|
||||
}
|
||||
catch (MissingModsException missing)
|
||||
{
|
||||
modsMissing = missing;
|
||||
}
|
||||
catch (ModSortingException sorting)
|
||||
{
|
||||
modSorting = sorting;
|
||||
}
|
||||
catch (CustomModLoadingErrorDisplayException custom)
|
||||
{
|
||||
FMLLog.log.error("A custom exception was thrown by a mod, the game will now halt", custom);
|
||||
customError = custom;
|
||||
}
|
||||
catch (MultipleModsErrored multiple)
|
||||
{
|
||||
multipleModsErrored = multiple;
|
||||
FMLLog.log.error("An exception was thrown, the game will display an error screen and halt.", e);
|
||||
errorToDisplay = e;
|
||||
MinecraftForge.EVENT_BUS.shutdown();
|
||||
}
|
||||
catch (LoaderException le)
|
||||
{
|
||||
@@ -274,8 +249,9 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
if (le.getCause() instanceof CustomModLoadingErrorDisplayException)
|
||||
{
|
||||
CustomModLoadingErrorDisplayException custom = (CustomModLoadingErrorDisplayException) le.getCause();
|
||||
FMLLog.log.error("A custom exception was thrown by a mod, the game will now halt", custom);
|
||||
customError = custom;
|
||||
FMLLog.log.error("A custom exception was thrown by a mod, the game will display an error screen and halt.", custom);
|
||||
errorToDisplay = custom;
|
||||
MinecraftForge.EVENT_BUS.shutdown();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -284,6 +260,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String,Map<String,String>> sharedModList = (Map<String, Map<String, String>>) Launch.blackboard.get("modList");
|
||||
if (sharedModList == null)
|
||||
{
|
||||
@@ -332,7 +309,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
|
||||
public boolean hasError()
|
||||
{
|
||||
return modsMissing != null || wrongMC != null || customError != null || dupesFound != null || modSorting != null || multipleModsErrored != null;
|
||||
return errorToDisplay != null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,8 +333,9 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
if (le.getCause() instanceof CustomModLoadingErrorDisplayException)
|
||||
{
|
||||
CustomModLoadingErrorDisplayException custom = (CustomModLoadingErrorDisplayException) le.getCause();
|
||||
FMLLog.log.error("A custom exception was thrown by a mod, the game will now halt", custom);
|
||||
customError = custom;
|
||||
FMLLog.log.error("A custom exception was thrown by a mod, the game will display an error screen and halt.", custom);
|
||||
errorToDisplay = custom;
|
||||
MinecraftForge.EVENT_BUS.shutdown();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -369,6 +347,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
// This call is being phased out for performance reasons in 1.12,
|
||||
// but we are keeping an option here in case something needs it for a little longer.
|
||||
// See https://github.com/MinecraftForge/MinecraftForge/pull/4032
|
||||
// TODO remove in 1.13
|
||||
if (Boolean.parseBoolean(System.getProperty("fml.reloadResourcesOnStart", "false")))
|
||||
{
|
||||
client.refreshResources();
|
||||
@@ -401,7 +380,7 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
}
|
||||
loading = false;
|
||||
client.gameSettings.loadOptions(); //Reload options to load any mod added keybindings.
|
||||
if (customError == null)
|
||||
if (!hasError())
|
||||
Loader.instance().loadingComplete();
|
||||
SplashProgress.finish();
|
||||
}
|
||||
@@ -439,29 +418,10 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
// re-sync TEXTURE_2D, splash screen disables it with a direct GL call
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.enableTexture2D();
|
||||
if (wrongMC != null)
|
||||
if (errorToDisplay != null)
|
||||
{
|
||||
showGuiScreen(new GuiWrongMinecraft(wrongMC));
|
||||
}
|
||||
else if (modsMissing != null)
|
||||
{
|
||||
showGuiScreen(new GuiModsMissing(modsMissing));
|
||||
}
|
||||
else if (dupesFound != null)
|
||||
{
|
||||
showGuiScreen(new GuiDupesFound(dupesFound));
|
||||
}
|
||||
else if (modSorting != null)
|
||||
{
|
||||
showGuiScreen(new GuiSortingProblem(modSorting));
|
||||
}
|
||||
else if (customError != null)
|
||||
{
|
||||
showGuiScreen(new GuiCustomModLoadingErrorScreen(customError));
|
||||
}
|
||||
else if (multipleModsErrored != null)
|
||||
{
|
||||
showGuiScreen(new GuiMultipleModsErrored(multipleModsErrored));
|
||||
GuiScreen errorScreen = errorToDisplay.createGui();
|
||||
showGuiScreen(errorScreen);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -616,6 +576,10 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
return client.getIntegratedServer();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO remove in 1.13
|
||||
*/
|
||||
@Deprecated
|
||||
public void displayMissingMods(Object modMissingPacket)
|
||||
{
|
||||
// showGuiScreen(new GuiModsMissingForServer(modMissingPacket));
|
||||
@@ -679,7 +643,8 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new RuntimeException("An unexpected exception occurred constructing the custom resource pack for " + container.getName(), e);
|
||||
FormattedMessage message = new FormattedMessage("An unexpected exception occurred constructing the custom resource pack for {} ({})", container.getName(), container.getModId());
|
||||
throw new RuntimeException(message.getFormattedMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -698,14 +663,6 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
@Override
|
||||
public void serverStopped()
|
||||
{
|
||||
// If the server crashes during startup, it might hang the client - reset the client so it can abend properly.
|
||||
MinecraftServer server = getServer();
|
||||
|
||||
if (server != null && !server.serverIsInRunLoop())
|
||||
{
|
||||
// ObfuscationReflectionHelper.setPrivateValue(MinecraftServer.class, server, true, "field_71296"+"_Q","serverIs"+"Running");
|
||||
}
|
||||
|
||||
GameData.revertToFrozen();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package net.minecraftforge.fml.client;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public interface IDisplayableError
|
||||
{
|
||||
@SideOnly(Side.CLIENT)
|
||||
GuiScreen createGui();
|
||||
}
|
||||
Reference in new issue
Block a user