1515import java .nio .file .Paths ;
1616import java .nio .file .StandardOpenOption ;
1717import java .nio .file .attribute .BasicFileAttributes ;
18+ import java .util .ArrayList ;
1819import java .util .Arrays ;
1920import java .util .HashSet ;
21+ import java .util .List ;
2022import java .util .Set ;
2123
2224public class Utils {
@@ -84,19 +86,37 @@ public static Path findMinecraftJar(Path maybeFgCache) {
8486 return absolutePath ;
8587 }
8688 String mcVersion = mcVersion ();
89+ List <Path > attemptedPaths = new ArrayList <>();
8790
8891 if (maybeFgCache != null ) {
8992 // provided likely FG cache:
93+ Path fg1fg2Path = maybeFgCache .resolve ("net/minecraft/minecraft" )
94+ .resolve (mcVersion ).resolve ("minecraft-" + mcVersion + ".jar" ).toAbsolutePath ();
95+ attemptedPaths .add (fg1fg2Path );
96+ if (Files .exists (fg1fg2Path )) {
97+ LOGGER .info ("Found Minecraft jar {} from FG1.x/FG2.x (provided cache)" , fg1fg2Path );
98+ return fg1fg2Path ;
99+ }
100+ // RetroFuturaGradle https://github.com/GTNewHorizons/RetroFuturaGradle
101+ //caches/retro_futura_gradle/mc-vanilla/1.12.2/
102+ Path rfgPath = maybeFgCache .resolve ("mc-vanilla" ).resolve (mcVersion ).resolve (mcVersion + ".jar" ).toAbsolutePath ();
103+ attemptedPaths .add (rfgPath );
104+ if (Files .exists (rfgPath )) {
105+ LOGGER .info ("Found Minecraft jar {} from RetroFuturaGradle (provided cache)" , rfgPath );
106+ return rfgPath ;
107+ }
90108 // FG3 - FG5
91109 Path fg3plusPath = maybeFgCache .resolve ("minecraft_repo/versions" )
92110 .resolve (mcVersion ).resolve ("client.jar" ).toAbsolutePath ();
111+ attemptedPaths .add (fg3plusPath );
93112 if (Files .exists (fg3plusPath )) {
94113 LOGGER .info ("Found Minecraft jar {} from FG3+ (provided cache)" , fg3plusPath );
95114 return fg3plusPath ;
96115 }
97116 // very old FG3 versions used slightly different path
98117 Path oldFg3Path = maybeFgCache .resolve ("minecraft_repo/version" )
99118 .resolve (mcVersion ).resolve ("client.jar" ).toAbsolutePath ();
119+ attemptedPaths .add (oldFg3Path );
100120 if (Files .exists (oldFg3Path )) {
101121 LOGGER .info ("Found Minecraft jar {} from old FG3 (provided cache)" , oldFg3Path );
102122 return oldFg3Path ;
@@ -112,6 +132,7 @@ public static Path findMinecraftJar(Path maybeFgCache) {
112132 // FG1 - FG2
113133 Path fg1fg2Path = gradleHome .resolve ("caches/minecraft/net/minecraft/minecraft" )
114134 .resolve (mcVersion ).resolve ("minecraft-" + mcVersion + ".jar" ).toAbsolutePath ();
135+ attemptedPaths .add (fg1fg2Path );
115136 if (Files .exists (fg1fg2Path )) {
116137 LOGGER .info ("Found Minecraft jar {} from FG1.x/FG2.x (global cache)" , fg1fg2Path );
117138 return fg1fg2Path ;
@@ -120,6 +141,7 @@ public static Path findMinecraftJar(Path maybeFgCache) {
120141 //caches/retro_futura_gradle/mc-vanilla/1.12.2/
121142 Path rfgPath = gradleHome .resolve ("caches/retro_futura_gradle/mc-vanilla" )
122143 .resolve (mcVersion ).resolve (mcVersion + ".jar" ).toAbsolutePath ();
144+ attemptedPaths .add (rfgPath );
123145 if (Files .exists (rfgPath )) {
124146 LOGGER .info ("Found Minecraft jar {} from RetroFuturaGradle (global cache)" , rfgPath );
125147 return rfgPath ;
@@ -128,25 +150,27 @@ public static Path findMinecraftJar(Path maybeFgCache) {
128150 // FG3 - FG5
129151 Path fg3plusPath = Utils .gradleHome ().resolve ("caches/forge_gradle/minecraft_repo/versions" )
130152 .resolve (mcVersion ).resolve ("client.jar" ).toAbsolutePath ();
153+ attemptedPaths .add (fg3plusPath );
131154 if (Files .exists (fg3plusPath )) {
132155 LOGGER .info ("Found Minecraft jar {} from FG3+ (global cache)" , fg3plusPath );
133156 return fg3plusPath ;
134157 }
135158 // very old FG3 versions used slightly different path
136159 Path oldFg3Path = Utils .gradleHome ().resolve ("caches/forge_gradle/minecraft_repo/version" )
137160 .resolve (mcVersion ).resolve ("client.jar" ).toAbsolutePath ();
161+ attemptedPaths .add (oldFg3Path );
138162 if (Files .exists (oldFg3Path )) {
139163 LOGGER .info ("Found Minecraft jar {} from old FG3 (global cache)" , oldFg3Path );
140164 return oldFg3Path ;
141165 }
142166 // as a last resort, attempt vanilla launcher
143167 Path mcLauncherJar = Paths .get (System .getProperty ("user.home" )).resolve (".minecraft/versions" ).resolve (mcVersion ).resolve (mcVersion + ".jar" );
168+ attemptedPaths .add (mcLauncherJar );
144169 if (Files .exists (mcLauncherJar )) {
145170 LOGGER .info ("Found Minecraft jar {} from Minecraft Launcher" , mcLauncherJar );
146171 return mcLauncherJar ;
147172 }
148- String list = String .join ("\n \t " ,
149- fg1fg2Path .toString (), rfgPath .toString (), fg3plusPath .toString (), oldFg3Path .toString (), mcLauncherJar .toString ());
173+ String list = String .join ("\n \t " , attemptedPaths .stream ().map (Object ::toString ).toArray (String []::new ));
150174 throw new IllegalStateException ("Could not fine Minecraft jar file. Try specifying Minecraft jar location with -Dofdev.mcjar=path\n \t "
151175 + "Attempted locations:\n \t " + list );
152176 }
0 commit comments