When the window is closed during loading, exit the game quickly (#3858)

This commit is contained in:
mezz 2017-05-01 17:14:55 -07:00 committed by LexManos
parent 91cc592a3a
commit e4d04afd95
5 changed files with 25 additions and 0 deletions

View File

@ -637,6 +637,12 @@ public class FMLClientHandler implements IFMLSidedHandler
return loading;
}
@Override
public boolean isDisplayCloseRequested()
{
return Display.isCreated() && Display.isCloseRequested();
}
@Override
public boolean shouldServerShouldBeKilledQuietly()
{

View File

@ -438,6 +438,11 @@ public class FMLCommonHandler
if (!confirmed) StartupQuery.abort();
}
public boolean isDisplayCloseRequested()
{
return sidedDelegate != null && sidedDelegate.isDisplayCloseRequested();
}
public boolean shouldServerBeKilledQuietly()
{
if (sidedDelegate == null)

View File

@ -51,6 +51,8 @@ public interface IFMLSidedHandler
MinecraftServer getServer();
boolean isDisplayCloseRequested();
boolean shouldServerShouldBeKilledQuietly();
void addModAsResource(ModContainer container);

View File

@ -150,6 +150,12 @@ public class LoadController
public void transition(LoaderState desiredState, boolean forceState)
{
if (FMLCommonHandler.instance().isDisplayCloseRequested())
{
FMLLog.info("The game window is being closed by the player, exiting.");
FMLCommonHandler.instance().exitJava(0, false);
}
LoaderState oldState = state;
state = state.transition(!errors.isEmpty());
if (state != desiredState && !forceState)

View File

@ -222,6 +222,12 @@ public class FMLServerHandler implements IFMLSidedHandler
}
}
@Override
public boolean isDisplayCloseRequested()
{
return false;
}
@Override
public boolean shouldServerShouldBeKilledQuietly()
{