-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
151 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
package me.hydos.focu; | ||
|
||
import me.hydos.focu.mald.logic.MalderLoader; | ||
import me.hydos.focu.providers.ForgeProvider; | ||
|
||
import java.nio.file.Paths; | ||
import java.nio.file.Path; | ||
|
||
public class Main { | ||
|
||
public static void main(String[] args) { | ||
MalderLoader malderLoader = new MalderLoader() | ||
.loadMalder(Paths.get("malders/TitleScreen.class")); | ||
ForgeProvider forge = ForgeProvider.createFromClient( | ||
Path.of("C:/Users/hayde/AppData/Roaming/.minecraft"), | ||
"1.18.2", | ||
"40.1.0" | ||
); | ||
|
||
ForgePatcher patcher = new ForgePatcher(Paths.get("C:/Users/hayde/AppData/Roaming/.minecraft"), malderLoader, "1.18.2-40.0.52"); | ||
MalderLoader malderLoader = new MalderLoader(); | ||
//.loadMalder(Paths.get("malders/TitleScreen.class")); | ||
|
||
ForgePatcher patcher = new ForgePatcher(forge, malderLoader); | ||
patcher.apply(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package me.hydos.focu.providers; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.List; | ||
import java.util.stream.Stream; | ||
|
||
public record ForgeProvider( | ||
List<Path> targets, | ||
Path mojmap, | ||
Path minecraftSrg | ||
) { | ||
|
||
public static ForgeProvider createFromClient(Path dotMinecraftDir, String minecraftVersion, String forgeVersion) { | ||
String fullForgeVersion = minecraftVersion + "-" + forgeVersion; | ||
String fullMinecraftVersion = detectFullMinecraftVersion(minecraftVersion, dotMinecraftDir); | ||
Path librariesFolder = dotMinecraftDir.resolve("libraries"); | ||
Path forgeOrgFolder = librariesFolder.resolve("net/minecraftforge/forge/" + fullForgeVersion); | ||
Path minecraftOrgFolder = librariesFolder.resolve("net/minecraft/client/" + fullMinecraftVersion); | ||
|
||
Path mcSrg = minecraftOrgFolder.resolve("client-" + fullMinecraftVersion + "-srg.jar"); | ||
return new ForgeProvider(List.of( | ||
forgeOrgFolder.resolve("forge-" + fullForgeVersion + "-client.jar"), | ||
forgeOrgFolder.resolve("forge-" + fullForgeVersion + "-universal.jar"), | ||
mcSrg | ||
), minecraftOrgFolder, mcSrg); | ||
} | ||
|
||
private static String detectFullMinecraftVersion(String minecraftVersion, Path dotMinecraftDir) { | ||
try { | ||
try (Stream<Path> list = Files.list(dotMinecraftDir.resolve("libraries/net/minecraft/client"))) { | ||
List<Path> results = list.filter(Files::isDirectory).filter(path -> path.toString().contains(minecraftVersion)).toList(); | ||
if (results.isEmpty()) { | ||
throw new RuntimeException("Forge Installer has not been run!"); | ||
} else if (results.size() > 1) { | ||
System.out.println("More than one version of " + minecraftVersion + ". Patcher may not work!"); | ||
} | ||
|
||
return minecraftVersion + results.get(0).getFileName().toString().substring(minecraftVersion.length()); | ||
} | ||
} catch (IOException e) { | ||
throw new RuntimeException("Failed to detect full minecraft version", e); | ||
} | ||
} | ||
} |
Oops, something went wrong.