@@ -62,8 +62,15 @@ final class InstallerGUI {
6262 private static final String FULLSCREEN_LABEL =
6363 "FoxLoader " + BuildConfig .FOXLOADER_VERSION + " for ReIndev " + BuildConfig .REINDEV_VERSION ;
6464 private static final int PROGRESS_BAR_MAX = DependencyHelper .commonDependencies .length + 1 ;
65- private static final HashSet <String > MMC_PATCHES = new HashSet <>(Arrays .asList (
66- "com.fox2code.foxloader.json" , "net.minecraft.json" , "net.minecraftforge.json" ));
65+ private static final HashSet <String > MMC_PATCHES_ALL = new HashSet <>(Arrays .asList (
66+ "com.fox2code.foxloader.json" , "net.minecraft.json" ,
67+ "net.minecraftforge.json" , "com.fox2code.lwjglx.json" ));
68+ private static final String [] MMC_FILES = new String []{"patches/com.fox2code.foxloader.json" ,
69+ "patches/net.minecraft.json" , "patches/net.minecraftforge.json" ,
70+ "patches/org.lwjgl.json" , "instance.cfg" , "mmc-pack.json" };
71+ private static final String [] MMC_FILES_LWJGLX = new String []{"patches/com.fox2code.foxloader.json" ,
72+ "patches/net.minecraft.json" , "patches/net.minecraftforge.json" ,
73+ "patches/com.fox2code.lwjglx.json" , "instance.cfg" , "mmc-pack-lwjglx.json" };
6774 private final InstallerPlatform installerPlatform ;
6875 private final LauncherType launcherType ;
6976 private final JFrame jFrame ;
@@ -94,16 +101,16 @@ public InstallerGUI(InstallerPlatform installerPlatform) {
94101 languageContainer .add (TranslateEngine .makeLanguageSelectComponent ());
95102 JPanel clientContainer = makeContainer ("installer.install-client" );
96103 JButton minecraftButton ;
97- JButton mmcButton ;
98104 if (installerPlatform .specialLauncher ) {
99105 minecraftButton = makeButton (clientContainer ,
100106 "installer.install-special" , this ::installMineCraft , installerPlatform .platformName );
101- mmcButton = null ;
102107 } else {
103108 minecraftButton = makeButton (clientContainer ,
104109 "installer.install-minecraft" , this ::installMineCraft );
105- mmcButton = makeButton (clientContainer ,
106- "installer.extract-multimc" , this ::extractMMCInstance );
110+ makeButton (clientContainer ,
111+ "installer.extract-multimc" , () -> this .extractMMCInstance (false ));
112+ makeButton (clientContainer ,
113+ "installer.extract-multimc-lwjglx" , () -> this .extractMMCInstance (true ));
107114 }
108115 if (BuildConfig .IS_PRIVATE_DEV_BUILD ) {
109116 minecraftButton .setEnabled (false );
@@ -291,15 +298,15 @@ public void installMineCraft() {
291298 TranslateEngine .getTranslation ("installer.comment" ), false );
292299 }
293300
294- public void extractMMCInstance () {
301+ public void extractMMCInstance (boolean lwjglx ) {
295302 String fileName = Main .currentInstallerFile .getName ();
296303 if (fileName .endsWith ("-installer.jar" )) {
297304 fileName = fileName .replace ("-installer.jar" , ".jar" );
298305 }
299- this .extractMMCInstance (fileName );
306+ this .extractMMCInstance (fileName , lwjglx );
300307 }
301308
302- public void extractMMCInstance (String baseFileName ) {
309+ public void extractMMCInstance (String baseFileName , boolean lwjglx ) {
303310 if (this .checkInstaller (true )) {
304311 return ;
305312 }
@@ -309,7 +316,16 @@ public void extractMMCInstance(String baseFileName) {
309316 }
310317
311318 File instanceDest = new File (Main .currentInstallerFile .getParentFile (),
312- baseFileName .substring (0 , baseFileName .length () - 4 ) + "-mmc.zip" );
319+ baseFileName .substring (0 , baseFileName .length () - 4 ) +
320+ (lwjglx ? "-mmc-lwjglx.zip" : "-mmc.zip" ));
321+ String lwjglPatchId , lwjglVersion ;
322+ if (lwjglx ) {
323+ lwjglVersion = "3.3.3" ;
324+ lwjglPatchId = "org.lwjgl3" ;
325+ } else {
326+ lwjglVersion = "2.9.4-nightly-20150209" ;
327+ lwjglPatchId = "org.lwjgl" ;
328+ }
313329 try (ZipOutputStream zipOutputStream = new ZipOutputStream (Files .newOutputStream (instanceDest .toPath ()))) {
314330 zipOutputStream .putNextEntry (new ZipEntry ("libraries/foxloader-" + BuildConfig .FOXLOADER_VERSION + ".jar" ));
315331 copyCloseIn (Files .newInputStream (Main .currentInstallerFile .toPath ()), zipOutputStream );
@@ -320,16 +336,19 @@ public void extractMMCInstance(String baseFileName) {
320336 zipOutputStream .closeEntry ();
321337 }
322338 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream ();
323- for (String entry : new String []{ "patches/com.fox2code.foxloader.json" ,
324- "patches/net.minecraft.json" , "patches/net.minecraftforge.json" ,
325- "patches/org.lwjgl.json" , "instance.cfg" , "mmc-pack.json" }) {
326- zipOutputStream . putNextEntry ( new ZipEntry ( entry ));
339+ for (String entry : ( lwjglx ? MMC_FILES_LWJGLX : MMC_FILES )) {
340+ zipOutputStream . putNextEntry ( new ZipEntry (
341+ "mmc-pack-lwjglx .json" . equals ( entry ) ?
342+ "mmc-pack.json" : entry ));
327343 byteArrayOutputStream .reset ();
328344 IOUtils .copyAndClose (InstallerGUI .class .getResourceAsStream (
329345 "/mmc/" + entry ), byteArrayOutputStream );
330346 copyCloseIn (new ByteArrayInputStream (byteArrayOutputStream .toString ()
331347 .replace ("#version#" , this .versionName )
332348 .replace ("#foxloader_version#" , BuildConfig .FOXLOADER_VERSION )
349+ .replace ("#lwjglx_version#" , BuildConfig .LWJGLX_VERSION )
350+ .replace ("#lwjgl_version#" , lwjglVersion )
351+ .replace ("#lwjgl_uid#" , lwjglPatchId )
333352 .getBytes (StandardCharsets .UTF_8 )), zipOutputStream );
334353 zipOutputStream .closeEntry ();
335354 }
@@ -416,22 +435,42 @@ public void doSilentInstall() throws IOException {
416435 if (!patch .exists ()) {
417436 for (File file : Objects .requireNonNull (patches .listFiles ())) {
418437 if (file .getName ().endsWith (".json" ) &&
419- !MMC_PATCHES .contains (file .getName ())) {
438+ !MMC_PATCHES_ALL .contains (file .getName ())) {
420439 if (!file .delete ()) file .deleteOnExit ();
421440 }
422441 }
423442 }
443+ File patchLwjglx = new File (patches , "com.fox2code.lwjglx.json" );
444+ boolean lwjglx = patchLwjglx .exists ();
445+ String lwjglPatchId , lwjglVersion ;
446+ if (lwjglx ) {
447+ lwjglVersion = "3.3.3" ;
448+ lwjglPatchId = "org.lwjgl3" ;
449+ } else {
450+ lwjglVersion = "2.9.4-nightly-20150209" ;
451+ lwjglPatchId = "org.lwjgl" ;
452+ }
424453 ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream ();
425454 IOUtils .copyAndClose (InstallerGUI .class .getResourceAsStream (
426455 "/mmc/patches/com.fox2code.foxloader.json" ), byteArrayOutputStream );
427456 IOUtils .copyAndClose (new ByteArrayInputStream (byteArrayOutputStream .toString ()
428457 .replace ("#version#" , this .versionName )
429458 .replace ("#foxloader_version#" , BuildConfig .FOXLOADER_VERSION )
459+ .replace ("#lwjgl_version#" , lwjglVersion )
460+ .replace ("#lwjgl_uid#" , lwjglPatchId )
430461 .getBytes (StandardCharsets .UTF_8 )), Files .newOutputStream (patch .toPath ()));
462+ if (lwjglx ) {
463+ byteArrayOutputStream .reset ();
464+ IOUtils .copyAndClose (InstallerGUI .class .getResourceAsStream (
465+ "/mmc/patches/com.fox2code.lwjglx.json" ), byteArrayOutputStream );
466+ IOUtils .copyAndClose (new ByteArrayInputStream (byteArrayOutputStream .toString ()
467+ .replace ("#lwjglx_version#" , BuildConfig .LWJGLX_VERSION )
468+ .getBytes (StandardCharsets .UTF_8 )), Files .newOutputStream (patchLwjglx .toPath ()));
469+ }
431470 for (String entry : new String []{ // Fix in place replace!
432471 "patches/net.minecraft.json" , "patches/net.minecraftforge.json" }) {
433472 IOUtils .copyAndClose (InstallerGUI .class .getResourceAsStream (
434- "/mmc/patches/com.fox2code.foxloader .json" ),
473+ "/mmc/patches/" + entry + " .json" ),
435474 Files .newOutputStream (new File (entry ).toPath ()));
436475 }
437476 break ;
0 commit comments