Fix errors in preInit being lost when followed by a crash in fireRegistryEvents or objectHolder

This commit is contained in:
mezz 2018-01-22 23:03:17 -08:00
parent ca7a5eadc0
commit 603903db50
3 changed files with 21 additions and 2 deletions

View file

@ -174,11 +174,18 @@ public class LoadController
}
}
@Deprecated // TODO remove in 1.13
public void checkErrorsAfterAvailable()
{
checkErrors();
}
public void checkErrors()
{
if (errors.size() > 0)
{
FMLLog.log.fatal("Fatal errors were detected during {}. Loading cannot continue", LoaderState.AVAILABLE);
FMLLog.log.fatal("Fatal errors were detected during {}. Loading cannot continue.", state);
state = state.transition(true);
throw throwStoredErrors();
}
}

View file

@ -600,6 +600,7 @@ public class Loader
ItemStackHolderInjector.INSTANCE.findHolders(discoverer.getASMTable());
CapabilityManager.INSTANCE.injectCapabilities(discoverer.getASMTable());
modController.distributeStateMessage(LoaderState.PREINITIALIZATION, discoverer.getASMTable(), canonicalConfigDir);
modController.checkErrors();
GameData.fireRegistryEvents(rl -> !rl.equals(GameData.RECIPES));
FMLCommonHandler.instance().fireSidedRegistryEvents();
ObjectHolderRegistry.INSTANCE.applyObjectHolders();
@ -725,7 +726,7 @@ public class Loader
progressBar.step("Finishing up");
modController.transition(LoaderState.AVAILABLE, false);
modController.distributeStateMessage(LoaderState.AVAILABLE);
modController.checkErrorsAfterAvailable();
modController.checkErrors();
GameData.freezeData();
FMLLog.log.info("Forge Mod Loader has successfully loaded {} mod{}", mods.size(), mods.size() == 1 ? "" : "s");
progressBar.step("Completing Minecraft initialization");

View file

@ -2,11 +2,15 @@ package net.minecraftforge.debug;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiErrorScreen;
import net.minecraft.item.Item;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.client.CustomModLoadingErrorDisplayException;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLLoadCompleteEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@Mod(modid = "clientexceptiontest", version = "1.0", name = "Client Exception Test", clientSideOnly = true)
public class ClientExceptionTestMod
@ -22,10 +26,17 @@ public class ClientExceptionTestMod
{
if (ENABLE_PREINIT)
{
MinecraftForge.EVENT_BUS.register(this);
throwException("Thrown in Pre-Init");
}
}
@SubscribeEvent
public void registerItems(RegistryEvent<Item> itemRegistryEvent)
{
throw new RuntimeException("This should not be called because the mod threw an exception earlier in Pre-Init and is in a broken state.");
}
@Mod.EventHandler
public void onInit(FMLInitializationEvent e)
{