When the window is closed during loading, exit the game quickly (#3858)
This commit is contained in:
parent
91cc592a3a
commit
e4d04afd95
5 changed files with 25 additions and 0 deletions
|
@ -637,6 +637,12 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
return loading;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplayCloseRequested()
|
||||
{
|
||||
return Display.isCreated() && Display.isCloseRequested();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldServerShouldBeKilledQuietly()
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -51,6 +51,8 @@ public interface IFMLSidedHandler
|
|||
|
||||
MinecraftServer getServer();
|
||||
|
||||
boolean isDisplayCloseRequested();
|
||||
|
||||
boolean shouldServerShouldBeKilledQuietly();
|
||||
|
||||
void addModAsResource(ModContainer container);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -222,6 +222,12 @@ public class FMLServerHandler implements IFMLSidedHandler
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisplayCloseRequested()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldServerShouldBeKilledQuietly()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue