From da0972980bb0d8e906a9bb7ffc3c6b982b61aa66 Mon Sep 17 00:00:00 2001 From: Christian Date: Fri, 20 Sep 2013 17:02:56 -0400 Subject: [PATCH] Fix up a deep crash in the early server init hanging the client --- .../cpw/mods/fml/client/FMLClientHandler.java | 10 ++++++++++ .../cpw/mods/fml/common/FMLCommonHandler.java | 5 +++-- .../cpw/mods/fml/common/IFMLSidedHandler.java | 2 ++ .../cpw/mods/fml/server/FMLServerHandler.java | 14 ++++++++++---- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/fml/client/cpw/mods/fml/client/FMLClientHandler.java b/fml/client/cpw/mods/fml/client/FMLClientHandler.java index 694e41402..77773e923 100644 --- a/fml/client/cpw/mods/fml/client/FMLClientHandler.java +++ b/fml/client/cpw/mods/fml/client/FMLClientHandler.java @@ -612,4 +612,14 @@ public class FMLClientHandler implements IFMLSidedHandler { return client.func_135016_M().func_135041_c().func_135034_a(); } + + @Override + public void serverStopped() + { + // If the server crashes during startup, it might hang the client- reset the client so it can abend properly. + if (!getServer().func_71200_ad()) + { + ObfuscationReflectionHelper.setPrivateValue(MinecraftServer.class, getServer(), true, "field_71296"+"_Q","serverIs"+"Running"); + } + } } diff --git a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java index 5230df069..af75c186d 100644 --- a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java +++ b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java @@ -465,10 +465,11 @@ public class FMLCommonHandler public void handleServerStopped() { + sidedDelegate.serverStopped(); MinecraftServer server = getMinecraftServerInstance(); Loader.instance().serverStopped(); // FORCE the internal server to stop: hello optifine workaround! - if (server!=null) ObfuscationReflectionHelper.setPrivateValue(MinecraftServer.class, server, false, "field_71316_v", "u", "serverStopped"); + if (server!=null) ObfuscationReflectionHelper.setPrivateValue(MinecraftServer.class, server, false, "field_71316"+"_v", "u", "serverStopped"); } public String getModName() @@ -499,7 +500,7 @@ public class FMLCommonHandler public String getCurrentLanguage() { - + return sidedDelegate.getCurrentLanguage(); } } diff --git a/fml/common/cpw/mods/fml/common/IFMLSidedHandler.java b/fml/common/cpw/mods/fml/common/IFMLSidedHandler.java index 2e5f4a2e4..5eb071a66 100644 --- a/fml/common/cpw/mods/fml/common/IFMLSidedHandler.java +++ b/fml/common/cpw/mods/fml/common/IFMLSidedHandler.java @@ -68,4 +68,6 @@ public interface IFMLSidedHandler void updateResourcePackList(); String getCurrentLanguage(); + + void serverStopped(); } diff --git a/fml/common/cpw/mods/fml/server/FMLServerHandler.java b/fml/common/cpw/mods/fml/server/FMLServerHandler.java index 4c59cab6b..fe5ecbe5b 100644 --- a/fml/common/cpw/mods/fml/server/FMLServerHandler.java +++ b/fml/common/cpw/mods/fml/server/FMLServerHandler.java @@ -207,7 +207,7 @@ public class FMLServerHandler implements IFMLSidedHandler public void addModAsResource(ModContainer container) { File source = container.getSource(); - try + try { if (source.isDirectory()) { @@ -218,9 +218,9 @@ public class FMLServerHandler implements IFMLSidedHandler searchZipForENUSLanguage(source); } } - catch (IOException ioe) + catch (IOException ioe) { - + } } private static final Pattern assetENUSLang = Pattern.compile("assets/(.*)/lang/en_US.lang"); @@ -258,11 +258,17 @@ public class FMLServerHandler implements IFMLSidedHandler @Override public void updateResourcePackList() { - + } @Override public String getCurrentLanguage() { return "en_US"; } + + @Override + public void serverStopped() + { + // NOOP + } }