diff --git a/build.gradle b/build.gradle index 2791ff3..0e6a2e5 100644 --- a/build.gradle +++ b/build.gradle @@ -25,7 +25,7 @@ apply plugin: 'net.minecraftforge.gradle' apply plugin: 'eclipse' apply plugin: 'maven-publish' -version = '1.1.0' +version = '1.0.9' group = 'mods.Hileb.rml' // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = 'ResourceModLoader' @@ -33,7 +33,9 @@ sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = co minecraft { mappings channel: 'snapshot', version: '20171003-1.12' - // accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') + accessTransformer = file('src/main/resources/META-INF/rml_at.cfg') + + runs { client { workingDirectory project.file('run') @@ -43,6 +45,9 @@ minecraft { // Recommended logging level for the console property 'forge.logging.console.level', 'debug' + + //launch the IFMLLoadingPlugin + property 'fml.coreMods.loa', 'mods.Hileb.rml.core.RMLFMLLoadingPlugin' } server { @@ -52,6 +57,9 @@ minecraft { // Recommended logging level for the console property 'forge.logging.console.level', 'debug' + + //launch the IFMLLoadingPlugin + property 'fml.coreMods.loa', 'mods.Hileb.rml.core.RMLFMLLoadingPlugin' } } } @@ -69,13 +77,15 @@ dependencies { jar { manifest { attributes([ - "Specification-Title": "rml", - "Specification-Vendor": "Resource Mod Loader", - "Specification-Version": project.version, // We are version 1 of ourselves - "Implementation-Title": project.name, - "Implementation-Version": "${version}", - "Implementation-Vendor" :"Resource Mod Loader", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + "FMLCorePlugin": "mods.Hileb.rml.core.RMLFMLLoadingPlugin", + "FMLAT": "rml_at.cfg", + "Specification-Title": "rml", + "Specification-Vendor": "Resource Mod Loader", + "Specification-Version": project.version, // We are version 1 of ourselves + "Implementation-Title": project.name, + "Implementation-Version": "${version}", + "Implementation-Vendor" :"Resource Mod Loader", + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } } diff --git a/docs/en_us/launch/README.md b/docs/en_us/launch/README.md new file mode 100644 index 0000000..d5cda92 --- /dev/null +++ b/docs/en_us/launch/README.md @@ -0,0 +1,5 @@ +### Launch + +#### Launch Arguments + +Boolean `rml.printClasses` save the classes we transformed. \ No newline at end of file diff --git a/docs/zh_cn/launch/README.md b/docs/zh_cn/launch/README.md new file mode 100644 index 0000000..877bd5d --- /dev/null +++ b/docs/zh_cn/launch/README.md @@ -0,0 +1,5 @@ +### 启动 + +#### 启动参数 + +布尔 `rml.printClasses` 将修改的类保存,便于debug分析。 \ No newline at end of file diff --git a/src/main/java/mods/Hileb/rml/ResourceModLoader.java b/src/main/java/mods/Hileb/rml/ResourceModLoader.java index 0602891..53f42fb 100644 --- a/src/main/java/mods/Hileb/rml/ResourceModLoader.java +++ b/src/main/java/mods/Hileb/rml/ResourceModLoader.java @@ -18,7 +18,7 @@ @PublicAPI public class ResourceModLoader { @PublicAPI public static final String MODID="rml"; - @PublicAPI public static final String VERSION="1.1.0"; + @PublicAPI public static final String VERSION="1.0.9"; @PrivateAPI private static final BuffedModIDContainer buffedModIDContainer=new BuffedModIDContainer(); @PrivateAPI public static final HashSet enabledModContainers=new HashSet<>(); diff --git a/src/main/java/mods/Hileb/rml/api/file/FileHelper.java b/src/main/java/mods/Hileb/rml/api/file/FileHelper.java index f2f3092..1fef2af 100644 --- a/src/main/java/mods/Hileb/rml/api/file/FileHelper.java +++ b/src/main/java/mods/Hileb/rml/api/file/FileHelper.java @@ -34,7 +34,7 @@ public class FileHelper { @PublicAPI public static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); - + @PublicAPI public static boolean findFiles(ModContainer mod, String base, Function preprocessor, BiFunction processor, boolean defaultUnfoundRoot, boolean visitAllFiles) { diff --git a/src/main/java/mods/Hileb/rml/core/ASMUtil.java b/src/main/java/mods/Hileb/rml/core/ASMUtil.java index 4af4a47..bdf318a 100644 --- a/src/main/java/mods/Hileb/rml/core/ASMUtil.java +++ b/src/main/java/mods/Hileb/rml/core/ASMUtil.java @@ -26,7 +26,7 @@ @PrivateAPI public class ASMUtil { public static File gameDir; - public static final boolean saveTransformedClass= FMLLog.log.isDebugEnabled(); + public static boolean saveTransformedClass = false; public static final Method m_defineClass; static { try { diff --git a/src/main/java/mods/Hileb/rml/core/RMLFMLLoadingPlugin.java b/src/main/java/mods/Hileb/rml/core/RMLFMLLoadingPlugin.java index 58e83e5..d493ef3 100644 --- a/src/main/java/mods/Hileb/rml/core/RMLFMLLoadingPlugin.java +++ b/src/main/java/mods/Hileb/rml/core/RMLFMLLoadingPlugin.java @@ -16,6 +16,7 @@ import mods.Hileb.rml.deserialize.RMLDeserializeLoader; import mods.Hileb.rml.deserialize.RMLForgeEventHandler; import mods.Hileb.rml.deserialize.craft.recipe.SimpleAnvilRecipe; +import net.minecraft.launchwrapper.Launch; import net.minecraftforge.common.ForgeVersion; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.DummyModContainer; @@ -64,8 +65,9 @@ public String getSetupClass() { } @Override public void injectData(Map data) { - source=(File) data.get("coremodLocation"); + source = (File) data.get("coremodLocation"); ASMUtil.gameDir=(File)data.get("mcLocation"); + ASMUtil.saveTransformedClass = (Launch.blackboard.containsKey("rml.printClasses") && Launch.blackboard.get("rml.printClasses") instanceof Boolean ) ? (Boolean)Launch.blackboard.get("rml.printClasses") : false; } @Override public String getAccessTransformerClass() { @@ -129,6 +131,8 @@ public File getSource() { @Override @PrivateAPI public Class getCustomResourcePackClass() { + if(getSource() == null) return null; + try { return getSource().isDirectory() ? Class.forName("net.minecraftforge.fml.client.FMLFolderResourcePack", true, getClass().getClassLoader()) : Class.forName("net.minecraftforge.fml.client.FMLFileResourcePack", true, getClass().getClassLoader()); diff --git a/src/main/java/mods/Hileb/rml/core/RMLModDiscover.java b/src/main/java/mods/Hileb/rml/core/RMLModDiscover.java index adc222a..9910444 100644 --- a/src/main/java/mods/Hileb/rml/core/RMLModDiscover.java +++ b/src/main/java/mods/Hileb/rml/core/RMLModDiscover.java @@ -12,6 +12,7 @@ import mods.Hileb.rml.api.event.RMLAfterInjectEvent; import mods.Hileb.rml.api.file.JsonHelper; import mods.Hileb.rml.api.mods.ContainerHolder; +import net.minecraft.launchwrapper.Launch; import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.MetadataCollection; import net.minecraftforge.fml.common.ModContainer; @@ -46,10 +47,10 @@ public class RMLModDiscover { public static void inject(List modContainers){ RMLFMLLoadingPlugin.Container.LOGGER.info("rml inject ModContainer(s)"); - File modRoots=new File((File)ReflectionHelper.getPrivateValue(Loader.class,null,"minecraftDir"),"mods"); + File modRoots=new File(Launch.minecraftHome,"mods"); for (File modFile : Objects.requireNonNull(modRoots.listFiles(), "Directory `mods/` is not exist")) { - if(modFile.isDirectory()){ + if(modFile.isFile()){ try(ZipFile zipFile = new ZipFile(modFile)) { ZipEntry info = zipFile.getEntry("rml.info"); if (info!=null){//fix: https://mclo.gs/4yyaEH5 @@ -64,7 +65,7 @@ public static void inject(List modContainers){ RMLFMLLoadingPlugin.Container.LOGGER.error("could not read "+modFile.getAbsolutePath()); e.printStackTrace(); } - }else if (modFile.isFile()){ + }else if (modFile.isDirectory()){ File[] files = modFile.listFiles(pathname -> pathname.isFile() && "rml.info".equals(pathname.getName())); if (files!=null && files.length==1){ try { diff --git a/src/main/resources/META-INF/MANIFEST.MF b/src/main/resources/META-INF/MANIFEST.MF index 68db606..e0054f5 100644 --- a/src/main/resources/META-INF/MANIFEST.MF +++ b/src/main/resources/META-INF/MANIFEST.MF @@ -1,3 +1,3 @@ Manifest-Version: 1.0 FMLCorePlugin: mods.Hileb.rml.core.RMLFMLLoadingPlugin -FMLAT: rml-at.cfg +FMLAT: rml_at.cfg