mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-12 16:27:47 +00:00
When the window is closed during loading, exit the game quickly (#3858)
This commit is contained in:
1 parent
91cc592a3a
commit
e4d04afd95
5 files changed
+25
No files matched your search
@@ -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()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user