diff --git a/.gitignore b/.gitignore index 965aa98c..a233ec2b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,34 +1,40 @@ # gradle + .gradle/ build/ out/ classes/ -./mods/ # eclipse + *.launch # idea + .idea/ *.iml *.ipr *.iws # vscode + .settings/ .vscode/ bin/ .classpath .project -# fabric -run/ - # macos + *.DS_Store -./ModLoader* -jars/ -remappedSrc/ +# fabric + +run/ + +# java -mods/ +hs_err_*.log +replay_*.log +*.hprof +*.jfr \ No newline at end of file diff --git a/build.gradle b/build.gradle index 56c28a63..f6fb4225 100644 --- a/build.gradle +++ b/build.gradle @@ -1,20 +1,15 @@ import com.diffplug.gradle.spotless.JavaExtension plugins { + id 'java-library' id 'com.diffplug.spotless' version "6.12.0" - id 'fabric-loom' version "1.1-SNAPSHOT" // To use chocoloom, change the version to a commit hash - id 'legacy-looming' version "1.1-SNAPSHOT" // Version must be the same as fabric-loom's + id 'fabric-loom' version "1.3-SNAPSHOT" apply false // To use chocoloom, change the version to a commit hash + id 'legacy-looming' version "1.3-SNAPSHOT" apply false // Version must be the same as fabric-loom's id 'maven-publish' id "com.modrinth.minotaur" version "2.+" } -sourceCompatibility = JavaVersion.VERSION_1_8 -targetCompatibility = JavaVersion.VERSION_1_8 - -archivesBaseName = project.archives_base_name + "-" + project.minecraft_version -version = project.mod_version -def displayVersion = version + "+" + project.minecraft_version -group = project.maven_group +def displayVersion = project.mod_version + "+" + project.minecraft_version def debug = true def branch = System.getenv("GITHUB_REF_NAME") == null ? "-forge" : System.getenv("GITHUB_REF_NAME") @@ -22,77 +17,117 @@ if (!branch.endsWith("-forge")) { debug = false } -repositories { - maven { - name = "Modrinth" - url = "https://api.modrinth.com/maven" - content { - includeGroup "maven.modrinth" +allprojects { + apply plugin: "maven-publish" + apply plugin: "java-library" + apply plugin: "fabric-loom" + apply plugin: "legacy-looming" + + version = project.mod_version + group = project.maven_group + + repositories { + maven { + name = "Modrinth" + url = "https://api.modrinth.com/maven" + content { + includeGroup "maven.modrinth" + } + } + flatDir { + dirs (rootProject.rootDir.toString() + "/lib", rootProject.rootDir.toString() + "/mods") + } + + maven { + name = "Jitpack" + url 'https://jitpack.io/' } } - flatDir { - dirs ("./lib", "./mods") - } - maven { - name = "Jitpack" - url 'https://jitpack.io/' + dependencies { + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings legacy.yarn(project.minecraft_version, project.yarn_mappings) + modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + + modApi("maven.modrinth:mod-remapping-api:${project.mod_remapping_api}") + // modApi(group: "local", name: "mod-remapping-api", version: "1.8.0") + + modApi("maven.modrinth:spasm:${project.spasm_version}") + modApi(annotationProcessor("com.github.LlamaLad7.MixinExtras:mixinextras-fabric:${project.mixin_extras_version}")) + + implementation(group: "local", name: "argo", version: "2.25") + implementation(group: "local", name: "guava", version: "12.0.1") + + modImplementation(legacy.apiModule("legacy-fabric-logger-api-v1", "1.9.0+1.8.9")) + + // modRuntimeOnly(files("./forge-${project.minecraft_version}-${project.forge_version}-universal-intermediary.jar")) } -} -loom { - setIntermediaryUrl('https://repo.legacyfabric.net/repository/legacyfabric/net/legacyfabric/intermediary/%1$s/intermediary-%1$s-v2.jar'); + base { + archivesName = project.archives_base_name + "-" + project.minecraft_version + } - accessWidenerPath = file("src/main/resources/fabricated-forge.accesswidener") -} + processResources { + inputs.property "version", project.version -dependencies { - minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.legacyfabric:yarn:${project.minecraft_version}+build.${project.yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" + filesMatching("fabric.mod.json") { + expand "version": project.version + } + } - modApi("maven.modrinth:mod-remapping-api:${project.mod_remapping_api}") -// modApi(group: "local", name: "mod-remapping-api", version: "1.8.0") + // ensure that the encoding is set to UTF-8, no matter what the system default is + // this fixes some edge cases with special characters not displaying correctly + // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html + tasks.withType(JavaCompile).configureEach { + it.options.encoding = "UTF-8" + if (JavaVersion.current().isJava9Compatible()) it.options.release = 8 - modImplementation(legacyFabricApi.module("legacy-fabric-logger-api-v1", "1.9.0+1.8.9")) + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } - implementation(include(group: "local", name: "argo", version: "2.25")) - implementation(include(group: "local", name: "guava", version: "12.0.1")) + java { + // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task + // if it is present. + // If you remove this line, sources will not be generated. + withSourcesJar() + } - modCompileOnly(group: "local", name: "CodeChickenCore", version: "0.6.5") - modCompileOnly(group: "local", name: "NotEnoughItems", version: "1.4.0.5") + jar { + from("LICENSE") { + rename { "${it}_${base.archivesName.get()}" } + } + } +} -// modRuntimeOnly(files("./forge-${project.minecraft_version}-${project.forge_version}-universal-intermediary.jar")) +loom { + accessWidenerPath = file("src/main/resources/fabricated-forge.accesswidener") } -processResources { - inputs.property "version", project.version +dependencies { + include(group: "local", name: "argo", version: "2.25") + include(group: "local", name: "guava", version: "12.0.1") - filesMatching("fabric.mod.json") { - expand "version": project.version - } + include("org.apache.commons:commons-lang3:3.12.0") } -// ensure that the encoding is set to UTF-8, no matter what the system default is -// this fixes some edge cases with special characters not displaying correctly -// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html -tasks.withType(JavaCompile).configureEach { - it.options.encoding = "UTF-8" - if (JavaVersion.current().isJava9Compatible()) it.options.release = 8 +subprojects { + dependencies { + api(project.dependencies.project(path: ":", configuration: 'namedElements')) + } } -java { - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. - withSourcesJar() +remapJar { + afterEvaluate { + subprojects.each { + // Include the jar from the sub project. + nestedJars.from project("${it.path}").tasks.getByName("remapJar") + } + } } jar { from("licensing.md") - from("LICENSE") { - rename { "${it}_${project.archivesBaseName}" } - } from("LICENSE-fml.txt") from("CREDITS-fml.txt") from("MinecraftForge-Credits.txt") @@ -130,7 +165,7 @@ modrinth { token = System.getenv("MODRINTH_TOKEN") == null ? "dev" : System.getenv("MODRINTH_TOKEN") // This is the default. Remember to have the MODRINTH_TOKEN environment variable set or else this will fail, or set it to whatever you want - just make sure it stays private! projectId = "JpHZ1Cyv" // This can be the project ID or the slug. Either will work! versionName = displayVersion - changelog = "Update to Mod-Remapping-API 1.8.0.\nClassTransformers are now applied!!\nMeaning Coremods are more likely to work.\nImplement special fixes to get CodeChickenCore and NEI working." + changelog = "Update to MRAPI 1.14.2.\nFix more compatibility issues with CodeChickenCore and NEI.\nNEI plugins still do not work for now." uploadFile = remapJar gameVersions = [project.minecraft_version] // Must be an array, even with only one version debugMode = debug @@ -138,6 +173,6 @@ modrinth { // scope.type // The scope can be `required`, `optional`, `incompatible`, or `embedded` // The type can either be `project` or `version` - required.version "eRGeQXjD", project.mod_remapping_api + required.version "mod-remapping-api", project.mod_remapping_api } } diff --git a/gradle.properties b/gradle.properties index a8921454..841c9953 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,13 +6,15 @@ org.gradle.jvmargs=-Xmx2G # Fabric Properties minecraft_version = 1.4.1 yarn_mappings = 451 - loader_version = 0.14.17 + loader_version = 0.14.22 # Legacy Fabric API - mod_remapping_api = 1.8.0 + mod_remapping_api = 1.14.2 forge_version = 6.0.0.329 + mixin_extras_version=0.2.0-beta.8 + spasm_version=0.1.2 # Mod Properties - mod_version = 2.5.0 + mod_version = 2.6.0 maven_group = fr.catcore archives_base_name = fabricated-forge diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 249e5832..033e24c4 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ae04661e..9f4197d5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index a69d9cb6..fcb6fca1 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # within the Gradle project. # # You can find Gradle at https://github.com/gradle/gradle/. @@ -80,13 +80,10 @@ do esac done -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -APP_NAME="Gradle" +# This is normally unused +# shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,22 +130,29 @@ location of your Java installation." fi else JAVACMD=java - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac case $MAX_FD in #( '' | soft) :;; #( *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -193,6 +197,10 @@ if "$cygwin" || "$msys" ; then done fi + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + # Collect all arguments for the java command; # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # shell script including quotes and variable substitutions, so put them in diff --git a/gradlew.bat b/gradlew.bat index 53a6b238..6689b85b 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% diff --git a/lib/CodeChickenCore-0.6.5.jar b/lib/CodeChickenCore-0.6.5.jar deleted file mode 100644 index 14b56815..00000000 Binary files a/lib/CodeChickenCore-0.6.5.jar and /dev/null differ diff --git a/lib/NotEnoughItems-1.4.0.5.jar b/lib/NotEnoughItems-1.4.0.5.jar deleted file mode 100644 index 85587675..00000000 Binary files a/lib/NotEnoughItems-1.4.0.5.jar and /dev/null differ diff --git a/mod-compat/build.gradle b/mod-compat/build.gradle new file mode 100644 index 00000000..82c86e9c --- /dev/null +++ b/mod-compat/build.gradle @@ -0,0 +1,6 @@ +dependencies { + // How to add a mod + // add the intermediary jar of the mod in rootfolder/lib with a dummy fabric.mod.json file in it + // if the file is named like "filename-fileversion.jar" then import it this way: + // modCompileOnly(group: "local", name: "filename", version: "fileversion") +} \ No newline at end of file diff --git a/mod-compat/src/main/java/fr/catcore/fabricatedforge/compat/Dummy.java b/mod-compat/src/main/java/fr/catcore/fabricatedforge/compat/Dummy.java new file mode 100644 index 00000000..9f148b0b --- /dev/null +++ b/mod-compat/src/main/java/fr/catcore/fabricatedforge/compat/Dummy.java @@ -0,0 +1,9 @@ +package fr.catcore.fabricatedforge.compat; + +import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; + +public class Dummy implements PreLaunchEntrypoint { + @Override + public void onPreLaunch() { + } +} diff --git a/mod-compat/src/main/java/fr/catcore/fabricatedforge/compat/ExtraRemapper.java b/mod-compat/src/main/java/fr/catcore/fabricatedforge/compat/ExtraRemapper.java new file mode 100644 index 00000000..8b6906f6 --- /dev/null +++ b/mod-compat/src/main/java/fr/catcore/fabricatedforge/compat/ExtraRemapper.java @@ -0,0 +1,38 @@ +package fr.catcore.fabricatedforge.compat; + +import fr.catcore.modremapperapi.api.ModRemapper; +import fr.catcore.modremapperapi.remapping.RemapUtil; +import fr.catcore.modremapperapi.remapping.VisitorInfos; +import org.spongepowered.asm.mixin.MixinEnvironment; +import org.spongepowered.asm.mixin.Mixins; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class ExtraRemapper implements ModRemapper { + @Override + public String[] getJarFolders() { + return new String[0]; + } + + @Override + public Map> getExclusions() { + return new HashMap<>(); + } + + @Override + public void getMappingList(RemapUtil.MappingList mappingList) { + + } + + @Override + public void registerVisitors(VisitorInfos visitorInfos) { + + } + + @Override + public void afterRemap() { + Mixins.addConfiguration("fabricated-forge.mods.mixins.json"); + } +} diff --git a/src/main/java/fr/catcore/fabricatedforge/mixin/ModsMixinPlugin.java b/mod-compat/src/main/java/fr/catcore/fabricatedforge/compat/ModsMixinPlugin.java similarity index 74% rename from src/main/java/fr/catcore/fabricatedforge/mixin/ModsMixinPlugin.java rename to mod-compat/src/main/java/fr/catcore/fabricatedforge/compat/ModsMixinPlugin.java index a6fe36c1..35293df1 100644 --- a/src/main/java/fr/catcore/fabricatedforge/mixin/ModsMixinPlugin.java +++ b/mod-compat/src/main/java/fr/catcore/fabricatedforge/compat/ModsMixinPlugin.java @@ -1,4 +1,4 @@ -package fr.catcore.fabricatedforge.mixin; +package fr.catcore.fabricatedforge.compat; import org.objectweb.asm.tree.ClassNode; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; @@ -10,7 +10,6 @@ public class ModsMixinPlugin implements IMixinConfigPlugin { @Override public void onLoad(String mixinPackage) { - } @Override @@ -20,14 +19,6 @@ public String getRefMapperConfig() { @Override public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { - if (mixinClassName.contains(".nei.")) { - try { - this.getClass().getClassLoader().loadClass("codechicken.nei.forge.IContainerClientSide"); - return true; - } catch (ClassNotFoundException e) { - return false; - } - } return true; } @@ -43,11 +34,9 @@ public List getMixins() { @Override public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - } @Override public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - } } diff --git a/mod-compat/src/main/resources/fabric.mod.json b/mod-compat/src/main/resources/fabric.mod.json new file mode 100644 index 00000000..80239dfc --- /dev/null +++ b/mod-compat/src/main/resources/fabric.mod.json @@ -0,0 +1,33 @@ +{ + "schemaVersion": 1, + "id": "fabricated-forge-compat", + "version": "${version}", + "name": "Fabricated Forge Mod Compatibility Module", + "description": "", + "authors": [ + "CatCore" + ], + "contributors": [], + "contact": { + "homepage": "https://modrinth.com/mod/fabricated-forge", + "sources": "https://github.com/thecatcore/Fabricated-Legacy-Forge", + "issues": "https://github.com/thecatcore/Fabricated-Legacy-Forge/issues" + }, + "license": "CC0-1.0", + "icon": "assets/fabricated-forge/icon.png", + "environment": "*", + "entrypoints": { + "mod-remapper-api:modremapper": [ + "fr.catcore.fabricatedforge.compat.ExtraRemapper" + ], + "preLaunch": [ + "fr.catcore.fabricatedforge.compat.Dummy" + ] + }, + "mixins": [ + ], + "depends": { + "fabricloader": ">0.14.3", + "mod-remapping-api": ">=1.14.2" + } +} diff --git a/mod-compat/src/main/resources/fabricated-forge.mods.mixins.json b/mod-compat/src/main/resources/fabricated-forge.mods.mixins.json new file mode 100644 index 00000000..d7bc4790 --- /dev/null +++ b/mod-compat/src/main/resources/fabricated-forge.mods.mixins.json @@ -0,0 +1,15 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "fr.catcore.fabricatedforge.compat.mixin", + "compatibilityLevel": "JAVA_8", + "server": [], + "mixins": [ + ], + "client": [ + ], + "injectors": { + "defaultRequire": 1 + }, + "plugin": "fr.catcore.fabricatedforge.compat.ModsMixinPlugin" +} diff --git a/settings.gradle b/settings.gradle index 53818d89..e6b54afa 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,8 +6,10 @@ pluginManagement { } maven { name = "legacy-fabric" - url = "https://repo.legacyfabric.net/repository/legacyfabric" + url = "https://maven.legacyfabric.net/" } gradlePluginPortal() } } + +include 'mod-compat' \ No newline at end of file diff --git a/src/main/java/cpw/mods/fml/relauncher/IClassTransformer.java b/src/main/java/cpw/mods/fml/relauncher/IClassTransformer.java index cb04a14d..ab7f46ba 100644 --- a/src/main/java/cpw/mods/fml/relauncher/IClassTransformer.java +++ b/src/main/java/cpw/mods/fml/relauncher/IClassTransformer.java @@ -13,7 +13,18 @@ */ package cpw.mods.fml.relauncher; +import fr.catcore.fabricatedforge.util.Utils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + public interface IClassTransformer extends fr.catcore.modremapperapi.api.IClassTransformer { + static final List CLASS_NAMES = new ArrayList<>(); + + Map> transformed = new HashMap<>(); + byte[] transform(String string, byte[] bs); @Override @@ -24,6 +35,24 @@ default byte[] transformClass(String name, String transformedName, byte[] origin @Override default boolean handlesClass(String s, String s1) { + String className = this.getClass().getName(); + + if (!CLASS_NAMES.contains(className)) { + CLASS_NAMES.add(className); + transformed.put(this, new ArrayList<>()); + } + + if (CLASS_NAMES.contains(s)) return false; + + for (String toExclude : Utils.TRANSFORMER_EXCLUSIONS) { + if (s.startsWith(toExclude)) return false; + } + + if (transformed.get(this).contains(s)) { + throw new RuntimeException("Detected transformation loop for class " + s + " in ClassTransformer " + className); + } + + transformed.get(this).add(s); if (s.equals("net.minecraft.class_415") && this.getClass().getName().equals("codechicken.nei.asm.NEITransformer")) return false; return true; } diff --git a/src/main/java/cpw/mods/fml/relauncher/ReflectionHelper.java b/src/main/java/cpw/mods/fml/relauncher/ReflectionHelper.java index a0c04bd4..8c2ba809 100644 --- a/src/main/java/cpw/mods/fml/relauncher/ReflectionHelper.java +++ b/src/main/java/cpw/mods/fml/relauncher/ReflectionHelper.java @@ -82,7 +82,7 @@ public static Class getClass(ClassLoader loader, String... class { try { - return (Class) Class.forName(className, false, loader); + return (Class) Class.forName(className, false, ReflectionHelper.class.getClassLoader()); } catch (Exception e) { diff --git a/src/main/java/cpw/mods/fml/relauncher/RelaunchClassLoader.java b/src/main/java/cpw/mods/fml/relauncher/RelaunchClassLoader.java index 79a6ed0f..2798154f 100644 --- a/src/main/java/cpw/mods/fml/relauncher/RelaunchClassLoader.java +++ b/src/main/java/cpw/mods/fml/relauncher/RelaunchClassLoader.java @@ -14,8 +14,17 @@ package cpw.mods.fml.relauncher; import java.net.*; +import java.security.CodeSigner; +import java.security.CodeSource; +import java.util.jar.Attributes; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.jar.Manifest; + +import fr.catcore.fabricatedforge.util.Utils; import fr.catcore.modremapperapi.ClassTransformer; import net.fabricmc.loader.impl.launch.FabricLauncherBase; +import net.fabricmc.loader.impl.util.UrlUtil; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -53,7 +62,7 @@ public RelaunchClassLoader() { public void registerTransformer(String transformerClassName) { try { - IClassTransformer classTransformer = (IClassTransformer)this.loadClass(transformerClassName).newInstance(); + IClassTransformer classTransformer = (IClassTransformer)Class.forName(transformerClassName).newInstance(); ClassTransformer.registerTransformer(classTransformer); System.out.println("Registered ClassTransformer: " + transformerClassName); this.transformers.add(classTransformer); @@ -145,6 +154,9 @@ private byte[] runTransformers(String name, byte[] basicClass) { public void addURL(URL url) { super.addURL(url); + + FabricLauncherBase.getLauncher().addToClassPath(UrlUtil.asPath(url)); + this.sources.add(url); } @@ -173,9 +185,11 @@ public List getTransformers() { private void addClassLoaderExclusion(String toExclude) { this.classLoaderExceptions.add(toExclude); + Utils.TRANSFORMER_EXCLUSIONS.add(toExclude); } void addTransformerExclusion(String toExclude) { this.transformerExceptions.add(toExclude); + Utils.TRANSFORMER_EXCLUSIONS.add(toExclude); } } diff --git a/src/main/java/cpw/mods/fml/relauncher/RelaunchLibraryManager.java b/src/main/java/cpw/mods/fml/relauncher/RelaunchLibraryManager.java index 819e90f1..4909a48f 100644 --- a/src/main/java/cpw/mods/fml/relauncher/RelaunchLibraryManager.java +++ b/src/main/java/cpw/mods/fml/relauncher/RelaunchLibraryManager.java @@ -51,11 +51,11 @@ public static void handleLaunch(File mcDir, RelaunchClassLoader actualClassLoade for(String s : rootPlugins) { try { - IFMLLoadingPlugin plugin = (IFMLLoadingPlugin)Class.forName(s, true, actualClassLoader).newInstance(); + IFMLLoadingPlugin plugin = (IFMLLoadingPlugin)Class.forName(s, true, RelaunchLibraryManager.class.getClassLoader()).newInstance(); loadPlugins.add(plugin); for(String libName : plugin.getLibraryRequestClass()) { - libraries.add((ILibrarySet)Class.forName(libName, true, actualClassLoader).newInstance()); + libraries.add((ILibrarySet)Class.forName(libName, true, RelaunchLibraryManager.class.getClassLoader()).newInstance()); } } catch (Exception var42) { } @@ -73,7 +73,7 @@ public static void handleLaunch(File mcDir, RelaunchClassLoader actualClassLoade try { actualClassLoader.addTransformerExclusion(s); - Class coreModClass = Class.forName(s, true, actualClassLoader); + Class coreModClass = Class.forName(s, true, RelaunchLibraryManager.class.getClassLoader()); IFMLLoadingPlugin.TransformerExclusions trExclusions = (IFMLLoadingPlugin.TransformerExclusions)coreModClass.getAnnotation(IFMLLoadingPlugin.TransformerExclusions.class); if (trExclusions != null) { for(String st : trExclusions.value()) { @@ -85,7 +85,7 @@ public static void handleLaunch(File mcDir, RelaunchClassLoader actualClassLoade loadPlugins.add(plugin); if (plugin.getLibraryRequestClass() != null) { for(String libName : plugin.getLibraryRequestClass()) { - libraries.add((ILibrarySet)Class.forName(libName, true, actualClassLoader).newInstance()); + libraries.add((ILibrarySet)Class.forName(libName, true, RelaunchLibraryManager.class.getClassLoader()).newInstance()); } } } catch (Throwable var41) { @@ -330,7 +330,7 @@ public static void handleLaunch(File mcDir, RelaunchClassLoader actualClassLoade String setupClass = plugin.getSetupClass(); if (setupClass != null) { try { - IFMLCallHook call = (IFMLCallHook)Class.forName(setupClass, true, actualClassLoader).newInstance(); + IFMLCallHook call = (IFMLCallHook)Class.forName(setupClass, true, RelaunchLibraryManager.class.getClassLoader()).newInstance(); Map callData = new HashMap(); callData.put("classLoader", actualClassLoader); call.injectData(callData); @@ -349,7 +349,7 @@ public static void handleLaunch(File mcDir, RelaunchClassLoader actualClassLoade try { downloadMonitor.updateProgressString("Validating minecraft", new Object[0]); - Class loaderClazz = Class.forName("cpw.mods.fml.common.Loader", true, actualClassLoader); + Class loaderClazz = Class.forName("cpw.mods.fml.common.Loader", true, RelaunchLibraryManager.class.getClassLoader()); Method m = loaderClazz.getMethod("injectData", Object[].class); m.invoke(null, (Object)FMLInjectionData.data()); m = loaderClazz.getMethod("instance"); @@ -402,7 +402,7 @@ public boolean accept(File dir, String name) { try { downloadMonitor.updateProgressString("Loading coremod %s", new Object[]{coreMod.getName()}); classLoader.addTransformerExclusion(fmlCorePlugin); - Class coreModClass = Class.forName(fmlCorePlugin, true, classLoader); + Class coreModClass = Class.forName(fmlCorePlugin, true, RelaunchLibraryManager.class.getClassLoader()); IFMLLoadingPlugin.TransformerExclusions trExclusions = (IFMLLoadingPlugin.TransformerExclusions)coreModClass.getAnnotation(IFMLLoadingPlugin.TransformerExclusions.class); if (trExclusions != null) { for(String st : trExclusions.value()) { @@ -415,7 +415,7 @@ public boolean accept(File dir, String name) { pluginLocations.put(plugin, coreMod); if (plugin.getLibraryRequestClass() != null) { for(String libName : plugin.getLibraryRequestClass()) { - libraries.add((ILibrarySet)Class.forName(libName, true, classLoader).newInstance()); + libraries.add((ILibrarySet)Class.forName(libName, true, RelaunchLibraryManager.class.getClassLoader()).newInstance()); } } diff --git a/src/main/java/fr/catcore/fabricatedforge/ForgeModRemapper.java b/src/main/java/fr/catcore/fabricatedforge/ForgeModRemapper.java index e2f9c7ba..c365d684 100644 --- a/src/main/java/fr/catcore/fabricatedforge/ForgeModRemapper.java +++ b/src/main/java/fr/catcore/fabricatedforge/ForgeModRemapper.java @@ -70,49 +70,49 @@ public void registerVisitors(VisitorInfos infos) { new VisitorInfos.MethodNamed("fr/catcore/fabricatedforge/compat/MystcraftCompat", "registeredDims") ); - // CodeChickenCore - infos.registerMethodMethodIns( - new VisitorInfos.MethodNamed("codechicken/core/asm/ClassOverrider", "overrideBytes"), - new VisitorInfos.MethodNamed("fr/catcore/fabricatedforge/compat/CodeChickenCoreCompat", "overrideBytes") - ); - - // NEI - infos.registerMethodLdcIns( - new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "aqh"), - new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "net.minecraft.class_409") - ); - infos.registerMethodLdcIns( - new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "apn"), - new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "net.minecraft.class_388") - ); - infos.registerMethodLdcIns( - new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "agu"), - new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "net.minecraft.class_159") - ); - infos.registerMethodLdcIns( - new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "aig"), - new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "net.minecraft.class_197") - ); - infos.registerMethodLdcIns( - new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "c"), - new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "method_1033") - ); - infos.registerMethodLdcIns( - new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "a"), - new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "method_419") - ); - infos.registerMethodLdcIns( - new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "(Lup;IIILjw;)V"), - new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "(Lnet/minecraft/class_1150;IIILnet/minecraft/class_871;)V") - ); - infos.registerMethodMethodIns( - new VisitorInfos.MethodNamed("codechicken/nei/TMIUninstaller", "getJarFile"), - new VisitorInfos.MethodNamed("fr/catcore/fabricatedforge/compat/CodeChickenCoreCompat", "getJarFile") - ); - infos.registerMethodLdcIns( - new VisitorInfos.MethodValue("codechicken/nei/recipe/FurnaceRecipeHandler", "getItemBurnTime"), - new VisitorInfos.MethodValue("codechicken/nei/recipe/FurnaceRecipeHandler", "method_519") - ); +// // CodeChickenCore +// infos.registerMethodMethodIns( +// new VisitorInfos.MethodNamed("codechicken/core/asm/ClassOverrider", "overrideBytes"), +// new VisitorInfos.MethodNamed("fr/catcore/fabricatedforge/compat/CodeChickenCoreCompat", "overrideBytes") +// ); +// +// // NEI +// infos.registerMethodLdcIns( +// new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "aqh"), +// new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "net.minecraft.class_409") +// ); +// infos.registerMethodLdcIns( +// new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "apn"), +// new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "net.minecraft.class_388") +// ); +// infos.registerMethodLdcIns( +// new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "agu"), +// new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "net.minecraft.class_159") +// ); +// infos.registerMethodLdcIns( +// new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "aig"), +// new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "net.minecraft.class_197") +// ); +// infos.registerMethodLdcIns( +// new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "c"), +// new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "method_1033") +// ); +// infos.registerMethodLdcIns( +// new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "a"), +// new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "method_419") +// ); +// infos.registerMethodLdcIns( +// new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "(Lup;IIILjw;)V"), +// new VisitorInfos.MethodValue("codechicken/nei/asm/NEITransformer", "(Lnet/minecraft/class_1150;IIILnet/minecraft/class_871;)V") +// ); +// infos.registerMethodMethodIns( +// new VisitorInfos.MethodNamed("codechicken/nei/TMIUninstaller", "getJarFile"), +// new VisitorInfos.MethodNamed("fr/catcore/fabricatedforge/compat/CodeChickenCoreCompat", "getJarFile") +// ); +// infos.registerMethodLdcIns( +// new VisitorInfos.MethodValue("codechicken/nei/recipe/FurnaceRecipeHandler", "getItemBurnTime"), +// new VisitorInfos.MethodValue("codechicken/nei/recipe/FurnaceRecipeHandler", "method_519") +// ); } @Override @@ -122,7 +122,7 @@ public Optional getDefaultPackage() { @Override public void afterRemap() { - Mixins.addConfiguration("fabricated-forge.mods.mixins.json"); + } static { diff --git a/src/main/java/fr/catcore/fabricatedforge/compat/CodeChickenCoreCompat.java b/src/main/java/fr/catcore/fabricatedforge/compat/CodeChickenCoreCompat.java index 510ffd2d..7981d31a 100644 --- a/src/main/java/fr/catcore/fabricatedforge/compat/CodeChickenCoreCompat.java +++ b/src/main/java/fr/catcore/fabricatedforge/compat/CodeChickenCoreCompat.java @@ -1,21 +1,4 @@ package fr.catcore.fabricatedforge.compat; -import codechicken.core.asm.ObfuscationManager; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.ModClassLoader; - -import java.io.File; - public class CodeChickenCoreCompat { - public static byte[] overrideBytes(String name, byte[] bytes, ObfuscationManager.ClassMapping classMapping, File location) { - if (classMapping.classname.equals(name)) { - System.out.println("[ClassOverrider] Canceled class overwrite of " + name); - } - - return bytes; - } - - public static File getJarFile() { - return ((ModClassLoader) Loader.instance().getModClassLoader()).getParentSources()[0]; - } } diff --git a/src/main/java/fr/catcore/fabricatedforge/util/Utils.java b/src/main/java/fr/catcore/fabricatedforge/util/Utils.java new file mode 100644 index 00000000..59307a93 --- /dev/null +++ b/src/main/java/fr/catcore/fabricatedforge/util/Utils.java @@ -0,0 +1,8 @@ +package fr.catcore.fabricatedforge.util; + +import java.util.ArrayList; +import java.util.List; + +public class Utils { + public static final List TRANSFORMER_EXCLUSIONS = new ArrayList<>(); +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 90a45dd3..1f9f15e6 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -5,7 +5,7 @@ "name": "Fabricated Forge", "description": "A compatibility layer to load Forge mods on FabricLoader.", "authors": [ - "CatCore/arthurbambou" + "CatCore" ], "contributors": [ "MinecraftForge:\n- Eloraam\n- FlowerChild\n- Hawkye\n- MALfunction84\n- Scokeev9\n- SpaceToad\n- LexManos", @@ -16,8 +16,8 @@ ], "contact": { "homepage": "https://modrinth.com/mod/fabricated-forge", - "sources": "https://github.com/arthurbambou/Fabricated-Legacy-Forge", - "issues": "https://github.com/arthurbambou/Fabricated-Legacy-Forge/issues" + "sources": "https://github.com/thecatcore/Fabricated-Legacy-Forge", + "issues": "https://github.com/thecatcore/Fabricated-Legacy-Forge/issues" }, "license": "CC0-1.0", "icon": "assets/fabricated-forge/icon.png", @@ -34,7 +34,7 @@ "depends": { "fabricloader": ">0.14.3", "minecraft": "1.4.1", - "mod-remapping-api": ">=1.8.0" + "mod-remapping-api": ">=1.14.2" }, "custom": { "loom:injected_interfaces": { diff --git a/src/main/resources/fabricated-forge.mods.mixins.json b/src/main/resources/fabricated-forge.mods.mixins.json index a47535c9..e69de29b 100644 --- a/src/main/resources/fabricated-forge.mods.mixins.json +++ b/src/main/resources/fabricated-forge.mods.mixins.json @@ -1,13 +0,0 @@ -{ - "required": true, - "minVersion": "0.8", - "package": "fr.catcore.fabricatedforge.mixin.mods", - "compatibilityLevel": "JAVA_8", - "server": [], - "mixins": [], - "client": [], - "injectors": { - "defaultRequire": 1 - }, - "plugin": "fr.catcore.fabricatedforge.mixin.ModsMixinPlugin" -}