diff --git a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java index f0c6d818d7..920fbbaa31 100644 --- a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java +++ b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java @@ -465,7 +465,10 @@ public class FMLCommonHandler public void handleServerStopped() { + MinecraftServer server = getMinecraftServerInstance(); Loader.instance().serverStopped(); + // FORCE the internal server to stop: hello optifine workaround! + ObfuscationReflectionHelper.setPrivateValue(MinecraftServer.class, server, false, "field_71316_v", "u", "serverStopped"); } public String getModName() diff --git a/fml/common/cpw/mods/fml/common/LoadController.java b/fml/common/cpw/mods/fml/common/LoadController.java index a0b137a9b7..1fdb3a2bf0 100644 --- a/fml/common/cpw/mods/fml/common/LoadController.java +++ b/fml/common/cpw/mods/fml/common/LoadController.java @@ -104,11 +104,11 @@ public class LoadController } } - public void transition(LoaderState desiredState) + public void transition(LoaderState desiredState, boolean forceState) { LoaderState oldState = state; state = state.transition(!errors.isEmpty()); - if (state != desiredState) + if (state != desiredState && !forceState) { Throwable toThrow = null; FMLLog.severe("Fatal errors were detected during the transition from %s to %s. Loading cannot continue", oldState, desiredState); @@ -147,6 +147,12 @@ public class LoadController throw new LoaderException(toThrow); } } + else if (state != desiredState && forceState) + { + FMLLog.info("The state engine was in incorrect state %s and forced into state %s. Errors may have been discarded.", state, desiredState); + forceState(desiredState); + } + } public ModContainer activeContainer() diff --git a/fml/common/cpw/mods/fml/common/Loader.java b/fml/common/cpw/mods/fml/common/Loader.java index b512712e5f..1d83d7afa4 100644 --- a/fml/common/cpw/mods/fml/common/Loader.java +++ b/fml/common/cpw/mods/fml/common/Loader.java @@ -476,7 +476,7 @@ public class Loader mods = Lists.newArrayList(); namedMods = Maps.newHashMap(); modController = new LoadController(this); - modController.transition(LoaderState.LOADING); + modController.transition(LoaderState.LOADING, false); ModDiscoverer disc = identifyMods(); disableRequestedMods(); FMLLog.fine("Reloading logging properties from %s", loggingProperties.getPath()); @@ -500,7 +500,7 @@ public class Loader } } } - modController.transition(LoaderState.CONSTRUCTING); + modController.transition(LoaderState.CONSTRUCTING, false); modController.distributeStateMessage(LoaderState.CONSTRUCTING, modClassLoader, disc.getASMTable()); FMLLog.fine("Mod signature data"); for (ModContainer mod : getActiveModList()) @@ -511,9 +511,9 @@ public class Loader { FMLLog.fine("No user mod signature data found"); } - modController.transition(LoaderState.PREINITIALIZATION); + modController.transition(LoaderState.PREINITIALIZATION, false); modController.distributeStateMessage(LoaderState.PREINITIALIZATION, disc.getASMTable(), canonicalConfigDir); - modController.transition(LoaderState.INITIALIZATION); + modController.transition(LoaderState.INITIALIZATION, false); } private void disableRequestedMods() @@ -689,12 +689,12 @@ public class Loader { // Mod controller should be in the initialization state here modController.distributeStateMessage(LoaderState.INITIALIZATION); - modController.transition(LoaderState.POSTINITIALIZATION); + modController.transition(LoaderState.POSTINITIALIZATION, false); // Construct the "mod object table" so mods can refer to it in IMC and postinit GameData.buildModObjectTable(); modController.distributeStateMessage(FMLInterModComms.IMCEvent.class); modController.distributeStateMessage(LoaderState.POSTINITIALIZATION); - modController.transition(LoaderState.AVAILABLE); + modController.transition(LoaderState.AVAILABLE, false); modController.distributeStateMessage(LoaderState.AVAILABLE); // Dump the custom registry data map, if necessary GameData.dumpRegistry(minecraftDir); @@ -738,7 +738,7 @@ public class Loader try { modController.distributeStateMessage(LoaderState.SERVER_STARTING, server); - modController.transition(LoaderState.SERVER_STARTING); + modController.transition(LoaderState.SERVER_STARTING, false); } catch (Throwable t) { @@ -751,13 +751,13 @@ public class Loader public void serverStarted() { modController.distributeStateMessage(LoaderState.SERVER_STARTED); - modController.transition(LoaderState.SERVER_STARTED); + modController.transition(LoaderState.SERVER_STARTED, false); } public void serverStopping() { modController.distributeStateMessage(LoaderState.SERVER_STOPPING); - modController.transition(LoaderState.SERVER_STOPPING); + modController.transition(LoaderState.SERVER_STOPPING, false); } public BiMap getModObjectList() @@ -796,16 +796,8 @@ public class Loader public void serverStopped() { modController.distributeStateMessage(LoaderState.SERVER_STOPPED); - try - { - modController.transition(LoaderState.SERVER_STOPPED); - } - catch (LoaderException e) - { - modController.forceState(LoaderState.SERVER_STOPPED); - // Discard any exceptions here - they mask other, real, exceptions - } - modController.transition(LoaderState.AVAILABLE); + modController.transition(LoaderState.SERVER_STOPPED, true); + modController.transition(LoaderState.AVAILABLE, true); } public boolean serverAboutToStart(Object server) @@ -813,7 +805,7 @@ public class Loader try { modController.distributeStateMessage(LoaderState.SERVER_ABOUT_TO_START, server); - modController.transition(LoaderState.SERVER_ABOUT_TO_START); + modController.transition(LoaderState.SERVER_ABOUT_TO_START, false); } catch (Throwable t) { diff --git a/fml/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch b/fml/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch index f99efab3f4..2dfdd271a4 100644 --- a/fml/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch +++ b/fml/patches/minecraft/net/minecraft/server/MinecraftServer.java.patch @@ -51,15 +51,16 @@ this.func_71260_j(); this.field_71316_v = true; } -@@ -438,6 +454,7 @@ +@@ -438,6 +454,8 @@ } finally { + FMLCommonHandler.instance().handleServerStopped(); ++ this.field_71316_v = true; this.func_71240_o(); } } -@@ -454,8 +471,10 @@ +@@ -454,8 +472,10 @@ public void func_71217_p() { @@ -70,7 +71,7 @@ ++this.field_71315_w; if (this.field_71295_T) -@@ -501,6 +520,7 @@ +@@ -501,6 +521,7 @@ this.field_71304_b.func_76319_b(); this.field_71304_b.func_76319_b(); @@ -78,7 +79,7 @@ } public void func_71190_q() -@@ -528,6 +548,7 @@ +@@ -528,6 +549,7 @@ } this.field_71304_b.func_76320_a("tick"); @@ -86,7 +87,7 @@ CrashReport crashreport; try -@@ -552,6 +573,7 @@ +@@ -552,6 +574,7 @@ throw new ReportedException(crashreport); } @@ -94,7 +95,7 @@ this.field_71304_b.func_76319_b(); this.field_71304_b.func_76320_a("tracker"); worldserver.func_73039_n().func_72788_a(); -@@ -679,7 +701,7 @@ +@@ -679,7 +702,7 @@ public String getServerModName() { @@ -103,7 +104,7 @@ } public CrashReport func_71230_b(CrashReport p_71230_1_) -@@ -1137,6 +1159,13 @@ +@@ -1137,6 +1160,13 @@ @SideOnly(Side.SERVER) public static void main(String[] p_main_0_) {