mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 19:39:22 +00:00
initial attempt at a better way to ask the user in case of startup issues
This commit is contained in:
1 parent
038fa17ad3
commit
49c623f59c
16 files changed
+482
-191
No files matched your search
@@ -25,6 +25,7 @@ import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.entity.EntityClientPlayerMP;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
@@ -32,6 +33,7 @@ import net.minecraft.client.gui.GuiIngameMenu;
|
||||
import net.minecraft.client.gui.GuiMainMenu;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiSelectWorld;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.gui.ServerListEntryNormal;
|
||||
import net.minecraft.client.multiplayer.GuiConnecting;
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
@@ -55,7 +57,10 @@ import net.minecraft.network.ServerStatusResponse;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.BiMap;
|
||||
@@ -67,6 +72,7 @@ import com.google.common.collect.Maps;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.common.DummyModContainer;
|
||||
import cpw.mods.fml.common.DuplicateModsFoundException;
|
||||
@@ -81,6 +87,7 @@ import cpw.mods.fml.common.MissingModsException;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
import cpw.mods.fml.common.ModMetadata;
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
import cpw.mods.fml.common.StartupQuery;
|
||||
import cpw.mods.fml.common.WorldAccessContainer;
|
||||
import cpw.mods.fml.common.WrongMinecraftVersionException;
|
||||
import cpw.mods.fml.common.event.FMLMissingMappingsEvent;
|
||||
@@ -88,7 +95,6 @@ import cpw.mods.fml.common.event.FMLMissingMappingsEvent.Action;
|
||||
import cpw.mods.fml.common.eventhandler.EventBus;
|
||||
import cpw.mods.fml.common.network.FMLNetworkEvent;
|
||||
import cpw.mods.fml.common.registry.GameData;
|
||||
import cpw.mods.fml.common.registry.GameRegistryException;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import cpw.mods.fml.common.toposort.ModSortingException;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -424,6 +430,39 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
client.displayGuiScreen(gui);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queryUser(StartupQuery query) throws InterruptedException
|
||||
{
|
||||
if (query.getResult() == null)
|
||||
{
|
||||
client.displayGuiScreen(new GuiNotification(query));
|
||||
}
|
||||
else
|
||||
{
|
||||
client.displayGuiScreen(new GuiConfirmation(query));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean handleLoadingScreen(ScaledResolution scaledResolution)
|
||||
{
|
||||
if (client.currentScreen instanceof GuiMainMenu)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
int width = scaledResolution.getScaledWidth();
|
||||
int height = scaledResolution.getScaledHeight();
|
||||
int mouseX = Mouse.getX() * width / client.displayWidth;
|
||||
int mouseZ = height - Mouse.getY() * height / client.displayHeight - 1;
|
||||
|
||||
client.currentScreen.drawScreen(mouseX, mouseZ, 0);
|
||||
client.currentScreen.handleInput();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public WorldClient getWorldClient()
|
||||
{
|
||||
return client.theWorld;
|
||||
@@ -596,42 +635,10 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
launchIntegratedServerCallback(dirName, saveName);
|
||||
client.launchIntegratedServer(dirName, saveName, (WorldSettings)null);
|
||||
}
|
||||
}
|
||||
|
||||
private CountDownLatch gameReleaseLatch;
|
||||
private Thread clientWaiter;
|
||||
private GameRegistryException gre;
|
||||
|
||||
public void launchIntegratedServerCallback(String dirName, String saveName)
|
||||
{
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
Thread.interrupted();
|
||||
gameReleaseLatch = new CountDownLatch(1);
|
||||
clientWaiter = Thread.currentThread();
|
||||
client.launchIntegratedServer(dirName, saveName, (WorldSettings)null);
|
||||
System.out.printf("POKEE %b\n", Thread.currentThread().isInterrupted());
|
||||
gameReleaseLatch.await();
|
||||
}
|
||||
catch (InterruptedException ie)
|
||||
{
|
||||
Thread.interrupted();
|
||||
throw gre;
|
||||
}
|
||||
}
|
||||
catch (GameRegistryException gre)
|
||||
{
|
||||
client.loadWorld(null);
|
||||
showGuiScreen(new GuiModItemsMissing(gre.getItems()));
|
||||
}
|
||||
Thread.interrupted();
|
||||
}
|
||||
|
||||
public void showInGameModOptions(GuiIngameMenu guiIngameMenu)
|
||||
{
|
||||
showGuiScreen(new GuiIngameModOptions(guiIngameMenu));
|
||||
@@ -826,57 +833,6 @@ public class FMLClientHandler implements IFMLSidedHandler
|
||||
return defaultMissingAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serverLoadedSuccessfully()
|
||||
{
|
||||
if (gameReleaseLatch!=null)
|
||||
{
|
||||
gameReleaseLatch.countDown();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void failedServerLoading(RuntimeException ex, WorldAccessContainer wac)
|
||||
{
|
||||
if (wac instanceof FMLContainer && ex instanceof GameRegistryException)
|
||||
{
|
||||
try
|
||||
{
|
||||
gre = (GameRegistryException) ex;
|
||||
Executors.newSingleThreadExecutor().submit(new Callable<Void>()
|
||||
{
|
||||
// This needs to happen in a separate thread so that the server can "crash"
|
||||
// The three pokes are for the client - it's in a sleep loop, and needs to get
|
||||
// out of it
|
||||
@Override
|
||||
public Void call() throws Exception
|
||||
{
|
||||
System.err.println("POKE");
|
||||
clientWaiter.interrupt();
|
||||
Thread.sleep(50);
|
||||
System.err.println("POKE");
|
||||
clientWaiter.interrupt();
|
||||
Thread.sleep(50);
|
||||
System.err.println("POKE");
|
||||
clientWaiter.interrupt();
|
||||
return null;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
FMLLog.log(Level.ERROR, t, "stuff");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean handlingCrash(CrashReport report)
|
||||
{
|
||||
return report.getCrashCause() instanceof GameRegistryException;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldAllowPlayerLogins()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user