Skip to content

Commit

Permalink
Floader 0.16.3
Browse files Browse the repository at this point in the history
  • Loading branch information
TheGlitch76 committed Sep 6, 2024
1 parent b0606ef commit 46ab673
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@

package org.quiltmc.loader.impl.game.minecraft;

import java.io.IOException;
import java.net.JarURLConnection;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLConnection;
import java.util.concurrent.CompletableFuture;

public final class BundlerClassPathCapture {
Expand All @@ -26,9 +29,42 @@ public final class BundlerClassPathCapture {
public static void main(String[] args) { // invoked by the bundler on a thread
try {
URLClassLoader cl = (URLClassLoader) Thread.currentThread().getContextClassLoader();
FUTURE.complete(cl.getURLs());
URL[] urls = cl.getURLs();

// suppress asm library since it conflicts with Loader's, needed for MC 24w33a

URL asmUrl = cl.findResource("org/objectweb/asm/ClassReader.class");

if (asmUrl != null && (asmUrl = getJarUrl(asmUrl)) != null) {
for (int i = 0; i < urls.length; i++) {
if (urls[i].equals(asmUrl)) {
URL[] newUrls = new URL[urls.length - 1];
System.arraycopy(urls, 0, newUrls, 0, i);
System.arraycopy(urls, i + 1, newUrls, i, urls.length - i - 1);
urls = newUrls;
break;
}
}
}

FUTURE.complete(urls);
} catch (Throwable t) {
FUTURE.completeExceptionally(t);
}
}

/**
* Transform jar:file url to its outer file url.
*
* <p>jar:file:/path/to.jar!/pkg/Cls.class -> file:/path/to.jar
*/
private static URL getJarUrl(URL url) throws IOException {
URLConnection connection = url.openConnection();

if (connection instanceof JarURLConnection) {
return ((JarURLConnection) connection).getJarFileURL();
}

return null;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/quilt.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"provides": [
{
"id": "fabricloader",
"version": "0.16.2"
"version": "0.16.3"
}
],
"depends": [
Expand Down

0 comments on commit 46ab673

Please sign in to comment.