4848import io .toadlabs .jfgjds .JsonDeserializer ;
4949import io .toadlabs .jfgjds .JsonSerializer ;
5050import io .toadlabs .jfgjds .data .JsonObject ;
51+ import io .toadlabs .jfgjds .data .JsonValue ;
5152
5253/**
5354 * The installer backend.
@@ -57,7 +58,7 @@ public final class Installer {
5758 private static final String MR_SLUG = "axolotlclient-modpack" ;
5859 private static final String QUILT_LOADER = "https://meta.quiltmc.org/v3/versions/loader/%s/%s/profile/json" ;
5960 private static final String FABRIC_LOADER = "https://meta.fabricmc.net/v2/versions/loader/%s/%s/profile/json" ;
60- private static final String LEGACY_FABRIC_LOADER = "https://meta.legacyfabric .net/v2 /versions/loader/%s/%s/profile/json" ;
61+ private static final String ORNITHE_LOADER = "https://meta.ornithemc .net/v3 /versions/fabric- loader/%s/%s/profile/json" ;
6162 private static final String COMBAT_SNAPSHOT_FABRIC_LOADER = "https://meta.fabric.rizecookey.net/v2/versions/loader/%s/%s/profile/json" ;
6263 private static final String ICON ;
6364
@@ -114,29 +115,31 @@ public void install(ProjectVersion version, Path launcherDir, Path gameDir, Prog
114115 progress .update (tr ("installing_loader" ), -1 );
115116
116117 String gameVersion = pack .getDependencies ().get ("minecraft" );
118+ boolean fixInheritsFrom = false ;
119+
117120 if (pack .getDependencies ().containsKey ("quilt-loader" )) {
118121 // install quilt!
119122 String quiltLoader = pack .getDependencies ().get ("quilt-loader" );
120123 url = new URL (String .format (QUILT_LOADER , gameVersion , quiltLoader ));
121- versionName = "quilt-loader-" + quiltLoader ;
124+ versionName = "quilt-loader-" + quiltLoader + '-' + gameVersion ;
122125 } else if (pack .getDependencies ().containsKey ("fabric-loader" )) {
123126 // install fabric!
124127 String fabricLoader = pack .getDependencies ().get ("fabric-loader" );
125128
126- versionName = "fabric-loader-" + fabricLoader ;
129+ versionName = "fabric-loader-" + fabricLoader + '-' + gameVersion ;
127130
128131 // heuristic for legacy fabric, version range: ([1.0;1.13.2]) (both ends inclusive)
129- if (MinecraftVersionComparator .INSTANCE .compare (gameVersion , "1.13.2" ) <= 0 && MinecraftVersionComparator .INSTANCE .compare (gameVersion , "1.0" ) >= 0 )
130- url = new URL (String .format (LEGACY_FABRIC_LOADER , gameVersion , fabricLoader ));
131- else if (gameVersion .equals ("1.16_combat-6" ))
132+ if (MinecraftVersionComparator .INSTANCE .compare (gameVersion , "1.13.2" ) <= 0 && MinecraftVersionComparator .INSTANCE .compare (gameVersion , "1.0" ) >= 0 ) {
133+ url = new URL (String .format (ORNITHE_LOADER , gameVersion , fabricLoader ));
134+ versionName += "-ornithe-gen1" ;
135+ fixInheritsFrom = true ;
136+ } else if (gameVersion .equals ("1.16_combat-6" ))
132137 url = new URL (String .format (COMBAT_SNAPSHOT_FABRIC_LOADER , gameVersion , fabricLoader ));
133138 else
134139 url = new URL (String .format (FABRIC_LOADER , gameVersion , fabricLoader ));
135140 } else
136141 throw new UnsupportedOperationException ("Cannot find supported mod loader!" );
137142
138- versionName += '-' + gameVersion ;
139-
140143 Path versionDir = versions .resolve (versionName );
141144 Path versionJson = versionDir .resolve (versionName + ".json" );
142145
@@ -145,7 +148,24 @@ else if (gameVersion.equals("1.16_combat-6"))
145148 Files .createDirectories (versionDir );
146149
147150 try (InputStream in = Util .openStream (url )) {
148- Files .copy (in , versionJson );
151+ if (fixInheritsFrom ) {
152+ JsonObject versionObj = JsonDeserializer .read (in , StandardCharsets .UTF_8 ).asObject ();
153+
154+ if (versionObj .contains ("inheritsFrom" )) {
155+ String inheritsFrom = versionObj .get ("inheritsFrom" ).getStringValue ();
156+ String vanillaSuffix = "-vanilla" ;
157+
158+ if (inheritsFrom .endsWith (vanillaSuffix ))
159+ inheritsFrom = inheritsFrom .substring (0 , inheritsFrom .length () - vanillaSuffix .length ());
160+
161+ versionObj .put ("inheritsFrom" , inheritsFrom );
162+ }
163+
164+ try (OutputStream out = Files .newOutputStream (versionJson )) {
165+ JsonSerializer .write (versionObj , out , StandardCharsets .UTF_8 );
166+ }
167+ } else
168+ Files .copy (in , versionJson );
149169 }
150170 }
151171
0 commit comments