Skip to content

Commit

Permalink
fix discover and add arg
Browse files Browse the repository at this point in the history
  • Loading branch information
Ecdcaeb committed Mar 10, 2024
1 parent d6ff382 commit 729ba10
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 17 deletions.
28 changes: 19 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ 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'

sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.

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')
Expand All @@ -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 {
Expand All @@ -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'
}
}
}
Expand All @@ -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")
])
}
}
Expand Down
5 changes: 5 additions & 0 deletions docs/en_us/launch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### Launch

#### Launch Arguments

Boolean `rml.printClasses` save the classes we transformed.
5 changes: 5 additions & 0 deletions docs/zh_cn/launch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
### 启动

#### 启动参数

布尔 `rml.printClasses` 将修改的类保存,便于debug分析。
2 changes: 1 addition & 1 deletion src/main/java/mods/Hileb/rml/ResourceModLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<ContainerHolder> enabledModContainers=new HashSet<>();

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mods/Hileb/rml/api/file/FileHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Path, Boolean> preprocessor, BiFunction<Path, Path, Boolean> processor, boolean defaultUnfoundRoot, boolean visitAllFiles)
{
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mods/Hileb/rml/core/ASMUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/mods/Hileb/rml/core/RMLFMLLoadingPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -64,8 +65,9 @@ public String getSetupClass() {
}
@Override
public void injectData(Map<String, Object> 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() {
Expand Down Expand Up @@ -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());
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/mods/Hileb/rml/core/RMLModDiscover.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -46,10 +47,10 @@ public class RMLModDiscover {
public static void inject(List<ModContainer> 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
Expand All @@ -64,7 +65,7 @@ public static void inject(List<ModContainer> 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 {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Manifest-Version: 1.0
FMLCorePlugin: mods.Hileb.rml.core.RMLFMLLoadingPlugin
FMLAT: rml-at.cfg
FMLAT: rml_at.cfg

0 comments on commit 729ba10

Please sign in to comment.