Skip to content

Commit 7994dbe

Browse files
committed
Cleaner UCP logic
1 parent 7621966 commit 7994dbe

File tree

1 file changed

+4
-16
lines changed
  • src/main/java/com/falsepattern/lib/internal/impl/mixin

1 file changed

+4
-16
lines changed

src/main/java/com/falsepattern/lib/internal/impl/mixin/UCPImpl.java

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
package com.falsepattern.lib.internal.impl.mixin;
2323

2424
import lombok.val;
25-
import sun.misc.URLClassPath;
2625

2726
import net.minecraft.launchwrapper.Launch;
2827
import net.minecraft.launchwrapper.LaunchClassLoader;
@@ -31,7 +30,6 @@
3130
import java.io.IOException;
3231

3332
public final class UCPImpl {
34-
private static final URLClassPath ucp;
3533
private static final boolean GRIMOIRE;
3634

3735
static {
@@ -49,24 +47,14 @@ public final class UCPImpl {
4947
}
5048
}
5149
GRIMOIRE = grimoire;
52-
if (!GRIMOIRE) {
53-
try {
54-
val ucpField = LaunchClassLoader.class.getSuperclass().getDeclaredField("ucp");
55-
ucpField.setAccessible(true);
56-
57-
ucp = (URLClassPath) ucpField.get(Launch.classLoader);
58-
} catch (NoSuchFieldException | IllegalAccessException e) {
59-
throw new RuntimeException(e.getMessage());
60-
}
61-
} else {
62-
ucp = null;
63-
System.err.println("Grimoire detected, disabling jar loading utility");
64-
}
6550
}
6651

6752
public static void addJar(File pathToJar) throws Exception {
6853
if (!GRIMOIRE) {
69-
ucp.addURL(pathToJar.toURI().toURL());
54+
final LaunchClassLoader loader = Launch.classLoader;
55+
loader.addURL(pathToJar.toURI().toURL());
56+
// Act as-if we only added the mod to ucp
57+
loader.getSources().remove(loader.getSources().size() - 1);
7058
}
7159
}
7260
}

0 commit comments

Comments
 (0)