1
1
package net .hypercubemc .iris_installer ;
2
2
3
+ import mjson .Json ;
3
4
import net .fabricmc .installer .client .ProfileInstaller ;
4
5
import net .fabricmc .installer .util .Reference ;
5
6
import net .fabricmc .installer .util .Utils ;
12
13
import java .nio .file .Files ;
13
14
import java .nio .file .Path ;
14
15
import java .util .*;
15
- import java .util .List ;
16
16
import java .util .stream .Collectors ;
17
17
18
18
public class VanillaLauncherIntegration {
@@ -34,7 +34,7 @@ public static void installVersion(Path mcDir, String gameVersion, String loaderN
34
34
String versionId = String .format ("%s-%s-%s" , loaderName , loaderVersion , gameVersion );
35
35
Path versionsDir = mcDir .resolve ("versions" );
36
36
Path profileDir = versionsDir .resolve (versionId );
37
- Path profileJson = profileDir .resolve (versionId + ".json" );
37
+ Path profileJsonPath = profileDir .resolve (versionId + ".json" );
38
38
if (!Files .exists (profileDir )) {
39
39
Files .createDirectories (profileDir );
40
40
}
@@ -43,7 +43,27 @@ public static void installVersion(Path mcDir, String gameVersion, String loaderN
43
43
Files .deleteIfExists (dummyJar );
44
44
Files .createFile (dummyJar );
45
45
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
+ }
47
67
}
48
68
49
69
private static void installProfile (Path mcDir , Path instanceDir , String profileName , String versionId , Icon icon , ProfileInstaller .LauncherType launcherType ) throws IOException {
0 commit comments