11package net .hypercubemc .iris_installer ;
22
3+ import mjson .Json ;
34import net .fabricmc .installer .client .ProfileInstaller ;
45import net .fabricmc .installer .util .Reference ;
56import net .fabricmc .installer .util .Utils ;
1213import java .nio .file .Files ;
1314import java .nio .file .Path ;
1415import java .util .*;
15- import java .util .List ;
1616import java .util .stream .Collectors ;
1717
1818public class VanillaLauncherIntegration {
@@ -34,7 +34,7 @@ public static void installVersion(Path mcDir, String gameVersion, String loaderN
3434 String versionId = String .format ("%s-%s-%s" , loaderName , loaderVersion , gameVersion );
3535 Path versionsDir = mcDir .resolve ("versions" );
3636 Path profileDir = versionsDir .resolve (versionId );
37- Path profileJson = profileDir .resolve (versionId + ".json" );
37+ Path profileJsonPath = profileDir .resolve (versionId + ".json" );
3838 if (!Files .exists (profileDir )) {
3939 Files .createDirectories (profileDir );
4040 }
@@ -43,7 +43,27 @@ public static void installVersion(Path mcDir, String gameVersion, String loaderN
4343 Files .deleteIfExists (dummyJar );
4444 Files .createFile (dummyJar );
4545 URL profileUrl = new URL (Reference .getMetaServerEndpoint (String .format ("v2/versions/loader/%s/%s/profile/json" , gameVersion , loaderVersion )));
46- Utils .downloadFile (profileUrl , profileJson );
46+ Json profileJson = Json .read (profileUrl );
47+ if (loaderName .equals ("iris-fabric-loader" )) {
48+ editVersionJson (profileJson );
49+ }
50+ Utils .writeToFile (profileJsonPath , profileJson .toString ());
51+ }
52+
53+ private static void editVersionJson (Json profileJson ) {
54+ Json .Factory factory = Json .factory ();
55+ Map <String , Json > json = profileJson .asJsonMap ();
56+ // Replace fabric-loader-etc with iris-fabric-loader-etc
57+ json .compute ("id" , (ignored , existing ) -> factory .string ("iris-" + existing .asString ()));
58+ // Replace loader maven url and name
59+ for (Json entry : json .get ("libraries" ).asJsonList ()) {
60+ final String id = "net.fabricmc:fabric-loader:" ;
61+ String name = entry .asJsonMap ().get ("name" ).asString ();
62+ if (name .startsWith ("net.fabricmc:fabric-loader:" )) {
63+ entry .asJsonMap ().put ("name" , factory .string ("net.coderbot:iris-loader:" + name .substring (id .length ())));
64+ entry .asJsonMap ().put ("url" , factory .string ("https://raw.githubusercontent.com/IrisShaders/Iris-Installer-Maven/master/" ));
65+ }
66+ }
4767 }
4868
4969 private static void installProfile (Path mcDir , Path instanceDir , String profileName , String versionId , Icon icon , ProfileInstaller .LauncherType launcherType ) throws IOException {
0 commit comments