Compare commits

..
5 Commits
4 changed files with 14 additions and 159 deletions

No files matched your search

+1 -1
View File
@@ -145,7 +145,7 @@ modrinthProjectId = codechickencore-unofficial
# type can be one of [project, version], # type can be one of [project, version],
# and the name is the Modrinth project or version slug/id of the other mod. # 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 # 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 = modrinthRelations =
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens. # 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 { 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 net.minecraft.launchwrapper.Launch;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.ClassNode;
import com.google.common.collect.ImmutableList; 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.common.ModClassLoader;
import cpw.mods.fml.relauncher.CoreModManager; import cpw.mods.fml.relauncher.CoreModManager;
@SuppressWarnings("unused")
public class ClassDiscoverer { public class ClassDiscoverer {
public IStringMatcher matcher; public IStringMatcher matcher;
@@ -35,17 +37,12 @@ public class ClassDiscoverer {
for (int i = 0; i < superclasses.length; i++) for (int i = 0; i < superclasses.length; i++)
this.superclasses[i] = superclasses[i].getName().replace('.', '/'); this.superclasses[i] = superclasses[i].getName().replace('.', '/');
classes = new ArrayList<Class<?>>(); classes = new ArrayList<>();
modClassLoader = (ModClassLoader) Loader.instance().getModClassLoader(); modClassLoader = (ModClassLoader) Loader.instance().getModClassLoader();
} }
public ClassDiscoverer(Class<?>... superclasses) { public ClassDiscoverer(Class<?>... superclasses) {
this(new IStringMatcher() { this(test -> true, superclasses);
public boolean matches(String test) {
return true;
}
}, superclasses);
} }
public ArrayList<Class<?>> findClasses() { public ArrayList<Class<?>> findClasses() {
@@ -63,7 +60,7 @@ public class ClassDiscoverer {
byte[] bytes = Launch.classLoader.getClassBytes(classname); byte[] bytes = Launch.classLoader.getClassBytes(classname);
if (bytes == null) return; if (bytes == null) return;
ClassNode cnode = ASMHelper.createClassNode(bytes); ClassNode cnode = ASMHelper.createClassNode(bytes, ClassReader.SKIP_CODE);
for (String superclass : superclasses) for (String superclass : superclasses)
if (!cnode.interfaces.contains(superclass) && !cnode.superName.equals(superclass)) return; 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()) List<String> knownLibraries = ImmutableList.<String>builder().addAll(modClassLoader.getDefaultLibraries())
.addAll(CoreModManager.getLoadedCoremods()).build(); .addAll(CoreModManager.getLoadedCoremods()).build();
File[] minecraftSources = modClassLoader.getParentSources(); File[] minecraftSources = modClassLoader.getParentSources();
HashSet<String> searchedSources = new HashSet<String>(); HashSet<String> searchedSources = new HashSet<>();
for (File minecraftSource : minecraftSources) { for (File minecraftSource : minecraftSources) {
if (searchedSources.contains(minecraftSource.getAbsolutePath())) continue; if (searchedSources.contains(minecraftSource.getAbsolutePath())) continue;
searchedSources.add(minecraftSource.getAbsolutePath()); searchedSources.add(minecraftSource.getAbsolutePath());
@@ -1,159 +1,19 @@
package codechicken.core.launch; package codechicken.core.launch;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.Box;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import cpw.mods.fml.common.versioning.ComparableVersion;
import cpw.mods.fml.relauncher.IFMLCallHook; import cpw.mods.fml.relauncher.IFMLCallHook;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin; import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion; import cpw.mods.fml.relauncher.IFMLLoadingPlugin.MCVersion;
/** /**
* For autodownloading stuff. This is really unoriginal, mostly ripped off FML, credits to cpw. * This was used to download dependencies during runtime and inject them into the classloader. It is now hollowed out
* but kept in the mod so that if another mod copied-pasted this class into their mod, there is a chance this empty
* class will be loaded instead and it will do nothing.
*/ */
@MCVersion("1.7.10") @MCVersion("1.7.10")
public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook { public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
public interface IDownloadDisplay {
void resetProgress(int sizeGuess);
void setPokeThread(Thread currentThread);
void updateProgress(int fullLength);
boolean shouldStopIt();
void updateProgressString(String string, Object... data);
Object makeDialog();
void showErrorDialog(String name, String url);
}
@SuppressWarnings("serial")
public static class Downloader extends JOptionPane implements IDownloadDisplay {
boolean stopIt;
Thread pokeThread;
private Box makeProgressPanel() {
return null;
}
@Override
public JDialog makeDialog() {
return null;
}
protected void requestClose(String message) {}
@Override
public void updateProgressString(String progressUpdate, Object... data) {}
@Override
public void resetProgress(int sizeGuess) {}
@Override
public void updateProgress(int fullLength) {}
@Override
public void setPokeThread(Thread currentThread) {}
@Override
public boolean shouldStopIt() {
return true;
}
@Override
public void showErrorDialog(String name, String url) {}
}
public static class DummyDownloader implements IDownloadDisplay {
@Override
public void resetProgress(int sizeGuess) {}
@Override
public void setPokeThread(Thread currentThread) {}
@Override
public void updateProgress(int fullLength) {}
@Override
public boolean shouldStopIt() {
return false;
}
@Override
public void updateProgressString(String string, Object... data) {}
@Override
public Object makeDialog() {
return null;
}
@Override
public void showErrorDialog(String name, String url) {}
}
public static class VersionedFile {
public final Pattern pattern;
public final String filename;
public final ComparableVersion version;
public final String name;
public VersionedFile(String filename, Pattern pattern) {
this.pattern = pattern;
this.filename = filename;
Matcher m = pattern.matcher(filename);
if (m.matches()) {
name = m.group(1);
version = new ComparableVersion(m.group(2));
} else {
name = null;
version = null;
}
}
public boolean matches() {
return name != null;
}
}
public static class Dependency {
public String url;
public VersionedFile file;
public String existing;
/**
* Flag set to add this dep to the classpath immediately because it is required for a coremod.
*/
public boolean coreLib;
public Dependency(String url, VersionedFile file, boolean coreLib) {
this.url = url;
this.file = file;
this.coreLib = coreLib;
}
}
public static class DepLoadInst {
public DepLoadInst() {}
public void load() {}
}
public static void load() {}
@Override @Override
public String[] getASMTransformerClass() { public String[] getASMTransformerClass() {
return null; return null;
@@ -166,21 +26,19 @@ public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
@Override @Override
public String getSetupClass() { public String getSetupClass() {
return getClass().getName(); return null;
} }
@Override @Override
public void injectData(Map<String, Object> data) {} public void injectData(Map<String, Object> data) {}
@Override @Override
public Void call() { public String getAccessTransformerClass() {
load();
return null; return null;
} }
@Override @Override
public String getAccessTransformerClass() { public Void call() {
return null; return null;
} }
} }