File tree 3 files changed +87
-65
lines changed
src/main/java/makamys/coretweaks
3 files changed +87
-65
lines changed Original file line number Diff line number Diff line change 15
15
import org .objectweb .asm .tree .MethodInsnNode ;
16
16
import org .objectweb .asm .tree .MethodNode ;
17
17
18
+ import makamys .coretweaks .util .DefaultLibraries ;
18
19
import net .minecraft .launchwrapper .IClassTransformer ;
19
20
20
21
public class ModDiscovererTransformer implements IClassTransformer {
@@ -81,66 +82,7 @@ private static byte[] doTransform(byte[] bytes) {
81
82
82
83
public static boolean redirectKnownLibrariesContains (List <String > list , String obj , File file ) {
83
84
assert file .getName ().equals (obj );
84
- return list .contains (obj ) || isDefaultLibrary (file );
85
- }
86
-
87
- /* From Forge 1.12.2-14.23.5.2847 */
88
- private static boolean isDefaultLibrary (File file )
89
- {
90
- String home = System .getProperty ("java.home" ); // Nullcheck just in case some JVM decides to be stupid
91
- if (home != null && file .getAbsolutePath ().startsWith (home )) return true ;
92
- // Should really pull this from the json somehow, but we dont have that at runtime.
93
- String name = file .getName ();
94
- if (!name .endsWith (".jar" )) return false ;
95
- String [] prefixes =
96
- {
97
- "launchwrapper-" ,
98
- "asm-all-" ,
99
- "akka-actor_2.11-" ,
100
- "config-" ,
101
- "scala-" ,
102
- "jopt-simple-" ,
103
- "lzma-" ,
104
- "realms-" ,
105
- "httpclient-" ,
106
- "httpcore-" ,
107
- "vecmath-" ,
108
- "trove4j-" ,
109
- "icu4j-core-mojang-" ,
110
- "codecjorbis-" ,
111
- "codecwav-" ,
112
- "libraryjavawound-" ,
113
- "librarylwjglopenal-" ,
114
- "soundsystem-" ,
115
- "netty-all-" ,
116
- "guava-" ,
117
- "commons-lang3-" ,
118
- "commons-compress-" ,
119
- "commons-logging-" ,
120
- "commons-io-" ,
121
- "commons-codec-" ,
122
- "jinput-" ,
123
- "jutils-" ,
124
- "gson-" ,
125
- "authlib-" ,
126
- "log4j-api-" ,
127
- "log4j-core-" ,
128
- "lwjgl-" ,
129
- "lwjgl_util-" ,
130
- "twitch-" ,
131
- "jline-" ,
132
- "jna-" ,
133
- "platform-" ,
134
- "oshi-core-" ,
135
- "netty-" ,
136
- "libraryjavasound-" ,
137
- "fastutil-" ,
138
- "lombok-"
139
- };
140
- for (String s : prefixes )
141
- {
142
- if (name .startsWith (s )) return true ;
143
- }
144
- return false ;
85
+ return list .contains (obj ) || DefaultLibraries .isDefaultLibrary (file );
145
86
}
87
+
146
88
}
Original file line number Diff line number Diff line change 20
20
import java .util .zip .ZipFile ;
21
21
22
22
import lombok .SneakyThrows ;
23
+ import makamys .coretweaks .util .DefaultLibraries ;
23
24
import net .minecraft .client .resources .DefaultResourcePack ;
24
25
import net .minecraft .launchwrapper .Launch ;
25
26
@@ -33,6 +34,8 @@ public class PrefixedClasspathResourceAccelerator {
33
34
34
35
private static final boolean DEBUG = Boolean .parseBoolean (System .getProperty ("coretweaks.debugPrefixedClasspathResourceAccelerator" , "false" ));
35
36
37
+ private boolean skipLibraries = true ;
38
+
36
39
private List <Index > classSources ;
37
40
38
41
private Map <String , List <Index >> directoryOwners = new HashMap <>();
@@ -41,10 +44,12 @@ private void init() {
41
44
long t0 = System .nanoTime ();
42
45
classSources = new ArrayList <>();
43
46
for (URL url : Launch .classLoader .getSources ().stream ().distinct ().collect (Collectors .toList ())) {
44
- try {
45
- classSources .add (Index .fromURL (url ));
46
- } catch (Exception e ) {
47
- LOGGER .warn ("Failed to index file " + url , e );
47
+ if (!skipLibraries || !DefaultLibraries .isDefaultLibrary (url )) {
48
+ try {
49
+ classSources .add (Index .fromURL (url ));
50
+ } catch (Exception e ) {
51
+ LOGGER .warn ("Failed to index file " + url , e );
52
+ }
48
53
}
49
54
}
50
55
long t1 = System .nanoTime ();
Original file line number Diff line number Diff line change
1
+ package makamys .coretweaks .util ;
2
+
3
+ import java .io .File ;
4
+ import java .net .URISyntaxException ;
5
+ import java .net .URL ;
6
+
7
+ public class DefaultLibraries {
8
+ /* From Forge 1.12.2-14.23.5.2847 */
9
+ public static boolean isDefaultLibrary (File file )
10
+ {
11
+ String home = System .getProperty ("java.home" ); // Nullcheck just in case some JVM decides to be stupid
12
+ if (home != null && file .getAbsolutePath ().startsWith (home )) return true ;
13
+ // Should really pull this from the json somehow, but we dont have that at runtime.
14
+ String name = file .getName ();
15
+ if (!name .endsWith (".jar" )) return false ;
16
+ String [] prefixes =
17
+ {
18
+ "launchwrapper-" ,
19
+ "asm-all-" ,
20
+ "akka-actor_2.11-" ,
21
+ "config-" ,
22
+ "scala-" ,
23
+ "jopt-simple-" ,
24
+ "lzma-" ,
25
+ "realms-" ,
26
+ "httpclient-" ,
27
+ "httpcore-" ,
28
+ "vecmath-" ,
29
+ "trove4j-" ,
30
+ "icu4j-core-mojang-" ,
31
+ "codecjorbis-" ,
32
+ "codecwav-" ,
33
+ "libraryjavawound-" ,
34
+ "librarylwjglopenal-" ,
35
+ "soundsystem-" ,
36
+ "netty-all-" ,
37
+ "guava-" ,
38
+ "commons-lang3-" ,
39
+ "commons-compress-" ,
40
+ "commons-logging-" ,
41
+ "commons-io-" ,
42
+ "commons-codec-" ,
43
+ "jinput-" ,
44
+ "jutils-" ,
45
+ "gson-" ,
46
+ "authlib-" ,
47
+ "log4j-api-" ,
48
+ "log4j-core-" ,
49
+ "lwjgl-" ,
50
+ "lwjgl_util-" ,
51
+ "twitch-" ,
52
+ "jline-" ,
53
+ "jna-" ,
54
+ "platform-" ,
55
+ "oshi-core-" ,
56
+ "netty-" ,
57
+ "libraryjavasound-" ,
58
+ "fastutil-" ,
59
+ "lombok-"
60
+ };
61
+ for (String s : prefixes )
62
+ {
63
+ if (name .startsWith (s )) return true ;
64
+ }
65
+ return false ;
66
+ }
67
+
68
+ public static boolean isDefaultLibrary (URL url ) {
69
+ try {
70
+ return isDefaultLibrary (new File (url .toURI ()));
71
+ } catch (URISyntaxException e ) {
72
+ return false ;
73
+ }
74
+ }
75
+ }
You can’t perform that action at this time.
0 commit comments