[FIX] Forge 1.7.10 lwjgl3ify classpath order

This commit is contained in:
Gravita 2024-04-14 20:53:09 +07:00
parent 00ab20473c
commit cc6ed82afb
3 changed files with 22 additions and 9 deletions

View File

@ -31,6 +31,9 @@ public class MakeProfileHelper {
builder.setUpdateVerify(List.of("libraries", "natives", "mods", "minecraft.jar", "forge.jar", "liteloader.jar"));
{
List<String> classPath = new ArrayList<>(5);
if(findOption(options, MakeProfileOptionLaunchWrapper.class).isPresent()) {
classPath.add("libraries/net/minecraft/launchwrapper/1.12/launchwrapper-1.12.jar");
}
classPath.add("libraries");
classPath.add("minecraft.jar");
if (version.compareTo(ClientProfileVersions.MINECRAFT_1_12_2) <= 0) {

View File

@ -147,7 +147,7 @@ public class ClientLauncherProcess {
if (params.profile.getClassLoaderConfig() == ClientProfile.ClassLoaderConfig.AGENT) {
processArgs.add("-javaagent:".concat(IOHelper.getCodeSource(ClientLauncherEntryPoint.class).toAbsolutePath().toString()));
} else if (params.profile.getClassLoaderConfig() == ClientProfile.ClassLoaderConfig.SYSTEM_ARGS) {
systemClassPath.addAll(ClientLauncherEntryPoint.resolveClassPath(workDir, params.actions, params.profile)
systemClassPath.addAll(ClientLauncherEntryPoint.resolveClassPath(new HashSet<>(), workDir, params.actions, params.profile)
.filter(x -> !params.profile.getModulePath().contains(workDir.relativize(x).toString()))
.map(Path::toString)
.toList());

View File

@ -118,7 +118,8 @@ public class ClientLauncherEntryPoint {
// Verify ClientLauncher sign and classpath
LogHelper.debug("Verifying ClientLauncher sign and classpath");
List<Path> classpath = resolveClassPath(clientDir, params.actions, params.profile)
Set<Path> ignoredPath = new HashSet<>();
List<Path> classpath = resolveClassPath(ignoredPath, clientDir, params.actions, params.profile)
.filter(x -> !profile.getModulePath().contains(clientDir.relativize(x).toString()))
.collect(Collectors.toCollection(ArrayList::new));
if(LogHelper.isDevEnabled()) {
@ -252,11 +253,11 @@ public class ClientLauncherEntryPoint {
}
}
private static LinkedList<Path> resolveClassPathList(Path clientDir, String... classPath) throws IOException {
return resolveClassPathStream(clientDir, classPath).collect(Collectors.toCollection(LinkedList::new));
private static LinkedList<Path> resolveClassPathList(Set<Path> ignorePaths, Path clientDir, String... classPath) throws IOException {
return resolveClassPathStream(ignorePaths, clientDir, classPath).collect(Collectors.toCollection(LinkedList::new));
}
private static Stream<Path> resolveClassPathStream(Path clientDir, String... classPath) throws IOException {
private static Stream<Path> resolveClassPathStream(Set<Path> ignorePaths, Path clientDir, String... classPath) throws IOException {
Stream.Builder<Path> builder = Stream.builder();
for (String classPathEntry : classPath) {
Path path = clientDir.resolve(IOHelper.toPath(classPathEntry.replace(IOHelper.CROSS_SEPARATOR, IOHelper.PLATFORM_SEPARATOR)));
@ -265,20 +266,28 @@ public class ClientLauncherEntryPoint {
IOHelper.walk(path, new ClassPathFileVisitor(jars), false);
Collections.sort(jars);
for(var e : jars) {
if(ignorePaths.contains(e)) {
continue;
}
builder.accept(e);
ignorePaths.add(e);
}
continue;
}
if(ignorePaths.contains(path)) {
continue;
}
builder.accept(path);
ignorePaths.add(path);
}
return builder.build();
}
public static Stream<Path> resolveClassPath(Path clientDir, Set<OptionalAction> actions, ClientProfile profile) throws IOException {
Stream<Path> result = resolveClassPathStream(clientDir, profile.getClassPath());
public static Stream<Path> resolveClassPath(Set<Path> ignorePaths, Path clientDir, Set<OptionalAction> actions, ClientProfile profile) throws IOException {
Stream<Path> result = resolveClassPathStream(ignorePaths, clientDir, profile.getClassPath());
for (OptionalAction a : actions) {
if (a instanceof OptionalActionClassPath)
result = Stream.concat(result, resolveClassPathStream(clientDir, ((OptionalActionClassPath) a).args));
result = Stream.concat(result, resolveClassPathStream(ignorePaths, clientDir, ((OptionalActionClassPath) a).args));
}
return result;
}
@ -340,8 +349,9 @@ public class ClientLauncherEntryPoint {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
if (IOHelper.hasExtension(file, "jar") || IOHelper.hasExtension(file, "zip"))
if (IOHelper.hasExtension(file, "jar") || IOHelper.hasExtension(file, "zip")) {
result.add(file);
}
return super.visitFile(file, attrs);
}
}