[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 static ClientProfile makeProfile(ClientProfile.Version version, String ti
builder.setUpdateVerify(List.of("libraries", "natives", "mods", "minecraft.jar", "forge.jar", "liteloader.jar")); builder.setUpdateVerify(List.of("libraries", "natives", "mods", "minecraft.jar", "forge.jar", "liteloader.jar"));
{ {
List<String> classPath = new ArrayList<>(5); 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("libraries");
classPath.add("minecraft.jar"); classPath.add("minecraft.jar");
if (version.compareTo(ClientProfileVersions.MINECRAFT_1_12_2) <= 0) { if (version.compareTo(ClientProfileVersions.MINECRAFT_1_12_2) <= 0) {

View file

@ -147,7 +147,7 @@ public void start(boolean pipeOutput) throws IOException, InterruptedException {
if (params.profile.getClassLoaderConfig() == ClientProfile.ClassLoaderConfig.AGENT) { if (params.profile.getClassLoaderConfig() == ClientProfile.ClassLoaderConfig.AGENT) {
processArgs.add("-javaagent:".concat(IOHelper.getCodeSource(ClientLauncherEntryPoint.class).toAbsolutePath().toString())); processArgs.add("-javaagent:".concat(IOHelper.getCodeSource(ClientLauncherEntryPoint.class).toAbsolutePath().toString()));
} else if (params.profile.getClassLoaderConfig() == ClientProfile.ClassLoaderConfig.SYSTEM_ARGS) { } 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())) .filter(x -> !params.profile.getModulePath().contains(workDir.relativize(x).toString()))
.map(Path::toString) .map(Path::toString)
.toList()); .toList());

View file

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