WIP
This commit is contained in:
parent
b806438bf9
commit
6dbf4b5a12
|
|
@ -1,14 +1,38 @@
|
||||||
package org.embeddedt.modernfix.classloading;
|
package org.embeddedt.modernfix.classloading;
|
||||||
|
|
||||||
import net.minecraftforge.fml.loading.LoadingModList;
|
import net.minecraftforge.fml.loading.LoadingModList;
|
||||||
|
import net.minecraftforge.fml.loading.moddiscovery.AbstractJarFileLocator;
|
||||||
|
import net.minecraftforge.fml.loading.moddiscovery.ExplodedDirectoryLocator;
|
||||||
|
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||||
|
import net.minecraftforge.fml.loading.moddiscovery.ModFileInfo;
|
||||||
|
import net.minecraftforge.forgespi.locating.IModLocator;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class ModernFixResourceFinder {
|
public class ModernFixResourceFinder {
|
||||||
|
private static HashMap<String, ArrayList<URL>> urlsForClass = null;
|
||||||
|
public static void init() {
|
||||||
|
urlsForClass = new HashMap<>();
|
||||||
|
for(ModFileInfo fileInfo : LoadingModList.get().getModFiles()) {
|
||||||
|
ModFile file = fileInfo.getFile();
|
||||||
|
IModLocator locator = file.getLocator();
|
||||||
|
Path rootPath = locator.findPath(file, ".");
|
||||||
|
System.out.println(rootPath.getParent().toAbsolutePath());
|
||||||
|
}
|
||||||
|
for(ArrayList<URL> list : urlsForClass.values()) {
|
||||||
|
list.trimToSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
public static Enumeration<URL> findAllURLsForResource(String input) {
|
public static Enumeration<URL> findAllURLsForResource(String input) {
|
||||||
System.out.println(input);
|
ArrayList<URL> urlList = urlsForClass.get(input);
|
||||||
return Collections.emptyEnumeration(); //LoadingModList.get().findAllURLsForResource(input);
|
if(urlList != null)
|
||||||
|
return Collections.enumeration(urlList);
|
||||||
|
else
|
||||||
|
return Collections.emptyEnumeration();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,7 @@ public class ModernFixMixinPlugin implements IMixinConfigPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Function<String, Enumeration<URL>> constructResourceFinder() throws ReflectiveOperationException {
|
private Function<String, Enumeration<URL>> constructResourceFinder() throws ReflectiveOperationException {
|
||||||
|
ModernFixResourceFinder.init();
|
||||||
Field servicesHandlerField = Launcher.class.getDeclaredField("transformationServicesHandler");
|
Field servicesHandlerField = Launcher.class.getDeclaredField("transformationServicesHandler");
|
||||||
servicesHandlerField.setAccessible(true);
|
servicesHandlerField.setAccessible(true);
|
||||||
Object servicesHandler = servicesHandlerField.get(Launcher.INSTANCE);
|
Object servicesHandler = servicesHandlerField.get(Launcher.INSTANCE);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user