Compare commits

...
2 Commits
Author SHA1 Message Date
Dream Master 0ffe3048cb update 2025-07-29 14:31:37 +07:00
Alexdoru 69d1335aea Speedup ClassDiscoverer by using ClassReader.SKIP_CODE 2025-07-27 21:37:55 +02:00
3 changed files with 8 additions and 11 deletions

No files matched your search

+1 -1
View File
@@ -145,7 +145,7 @@ modrinthProjectId = codechickencore-unofficial
# type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod.
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
modrinthRelations =
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
+1 -1
View File
@@ -17,7 +17,7 @@ pluginManagement {
}
plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.38'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.41'
}
@@ -11,6 +11,7 @@ import java.util.zip.ZipFile;
import net.minecraft.launchwrapper.Launch;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.tree.ClassNode;
import com.google.common.collect.ImmutableList;
@@ -22,6 +23,7 @@ import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModClassLoader;
import cpw.mods.fml.relauncher.CoreModManager;
@SuppressWarnings("unused")
public class ClassDiscoverer {
public IStringMatcher matcher;
@@ -35,17 +37,12 @@ public class ClassDiscoverer {
for (int i = 0; i < superclasses.length; i++)
this.superclasses[i] = superclasses[i].getName().replace('.', '/');
classes = new ArrayList<Class<?>>();
classes = new ArrayList<>();
modClassLoader = (ModClassLoader) Loader.instance().getModClassLoader();
}
public ClassDiscoverer(Class<?>... superclasses) {
this(new IStringMatcher() {
public boolean matches(String test) {
return true;
}
}, superclasses);
this(test -> true, superclasses);
}
public ArrayList<Class<?>> findClasses() {
@@ -63,7 +60,7 @@ public class ClassDiscoverer {
byte[] bytes = Launch.classLoader.getClassBytes(classname);
if (bytes == null) return;
ClassNode cnode = ASMHelper.createClassNode(bytes);
ClassNode cnode = ASMHelper.createClassNode(bytes, ClassReader.SKIP_CODE);
for (String superclass : superclasses)
if (!cnode.interfaces.contains(superclass) && !cnode.superName.equals(superclass)) return;
@@ -86,7 +83,7 @@ public class ClassDiscoverer {
List<String> knownLibraries = ImmutableList.<String>builder().addAll(modClassLoader.getDefaultLibraries())
.addAll(CoreModManager.getLoadedCoremods()).build();
File[] minecraftSources = modClassLoader.getParentSources();
HashSet<String> searchedSources = new HashSet<String>();
HashSet<String> searchedSources = new HashSet<>();
for (File minecraftSource : minecraftSources) {
if (searchedSources.contains(minecraftSource.getAbsolutePath())) continue;
searchedSources.add(minecraftSource.getAbsolutePath());