diff options
author | Petr Mrázek <peterix@gmail.com> | 2017-07-14 08:43:35 +0200 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2017-07-14 08:43:35 +0200 |
commit | c19f6d4dcd0650f5f30c59a907d8022a4c642c8e (patch) | |
tree | f787dff3afeda4794e61e1c5253c3bee3cd3cf6d | |
parent | afb0db24a801d935e9945c948ea8d4b831b59d38 (diff) | |
download | MultiMC-c19f6d4dcd0650f5f30c59a907d8022a4c642c8e.tar MultiMC-c19f6d4dcd0650f5f30c59a907d8022a4c642c8e.tar.gz MultiMC-c19f6d4dcd0650f5f30c59a907d8022a4c642c8e.tar.lz MultiMC-c19f6d4dcd0650f5f30c59a907d8022a4c642c8e.tar.xz MultiMC-c19f6d4dcd0650f5f30c59a907d8022a4c642c8e.zip |
NOISSUE allow running legacy without the applet wrapper
Add 'noapplet' as a trait to do that.
-rw-r--r-- | libraries/launcher/org/multimc/onesix/OneSixLauncher.java | 93 |
1 files changed, 25 insertions, 68 deletions
diff --git a/libraries/launcher/org/multimc/onesix/OneSixLauncher.java b/libraries/launcher/org/multimc/onesix/OneSixLauncher.java index 61a30ede..f057e55a 100644 --- a/libraries/launcher/org/multimc/onesix/OneSixLauncher.java +++ b/libraries/launcher/org/multimc/onesix/OneSixLauncher.java @@ -111,34 +111,37 @@ public class OneSixLauncher implements Launcher System.setProperty("minecraft.applet.TargetDirectory", cwd); - String[] mcArgs = new String[2]; - mcArgs[0] = userName; - mcArgs[1] = sessionId; + if(!traits.contains("noapplet")) + { + Utils.log("Launching with applet wrapper..."); + try + { + Class<?> MCAppletClass = cl.loadClass(appletClass); + Applet mcappl = (Applet) MCAppletClass.newInstance(); + LegacyFrame mcWindow = new LegacyFrame(windowTitle); + mcWindow.start(mcappl, userName, sessionId, winSize, maximize); + return 0; + } catch (Exception e) + { + Utils.log("Applet wrapper failed:", "Error"); + e.printStackTrace(System.err); + Utils.log(); + Utils.log("Falling back to using main class."); + } + } - Utils.log("Launching with applet wrapper..."); + // init params for the main method to chomp on. + String[] paramsArray = mcparams.toArray(new String[mcparams.size()]); try { - Class<?> MCAppletClass = cl.loadClass(appletClass); - Applet mcappl = (Applet) MCAppletClass.newInstance(); - LegacyFrame mcWindow = new LegacyFrame(windowTitle); - mcWindow.start(mcappl, userName, sessionId, winSize, maximize); + mc.getMethod("main", String[].class).invoke(null, (Object) paramsArray); + return 0; } catch (Exception e) { - Utils.log("Applet wrapper failed:", "Error"); + Utils.log("Failed to invoke the Minecraft main class:", "Fatal"); e.printStackTrace(System.err); - Utils.log(); - Utils.log("Falling back to compatibility mode."); - try - { - mc.getMethod("main", String[].class).invoke(null, (Object) mcArgs); - } catch (Exception e1) - { - Utils.log("Failed to invoke the Minecraft main class:", "Fatal"); - e1.printStackTrace(System.err); - return -1; - } + return -1; } - return 0; } int launchWithMainClass() @@ -181,53 +184,7 @@ public class OneSixLauncher implements Launcher e.printStackTrace(System.err); return -1; } - /* - final java.nio.ByteBuffer[] icons = IconLoader.load("icon.png"); - new Thread() { - public void run() { - ClassLoader cl = ClassLoader.getSystemClassLoader(); - try - { - Class<?> Display; - Method isCreated; - Method setTitle; - Method setIcon; - Field fieldWindowCreated; - Boolean created = false; - Display = cl.loadClass("org.lwjgl.opengl.Display"); - fieldWindowCreated = Display.getDeclaredField("window_created"); - fieldWindowCreated.setAccessible( true ); - setTitle = Display.getMethod("setTitle", String.class); - setIcon = Display.getMethod("setIcon", java.nio.ByteBuffer[].class); - created = (Boolean) fieldWindowCreated.get( null ); - // set the window title? Maybe? - while(!created) - { - try - { - Thread.sleep(150); - created = (Boolean) fieldWindowCreated.get( null ); - } catch (InterruptedException ignored) {} - } - // Give it a bit more time ;) - Thread.sleep(150); - // set the title - setTitle.invoke(null,windowTitle); - // only set icon when there's actually something to set... - if(icons.length > 0) - { - setIcon.invoke(null,(Object)icons); - } - } - catch (Exception e) - { - System.err.println("Couldn't set window icon or title."); - e.printStackTrace(System.err); - } - } - } - .start(); - */ + // init params for the main method to chomp on. String[] paramsArray = mcparams.toArray(new String[mcparams.size()]); try |