From 0a1e2953f8271df9cf77b6dcae89ee067544f324 Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Wed, 4 Dec 2024 20:16:13 +0100 Subject: [PATCH 1/2] Add Mixin docs and fix target build directory --- LEGACY.md | 35 +++++++++++++++++++ .../legacyforge/dsl/Obfuscation.java | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/LEGACY.md b/LEGACY.md index 92a0e70e..19ad0858 100644 --- a/LEGACY.md +++ b/LEGACY.md @@ -91,6 +91,41 @@ obfuscation { } ``` +## Mixins + +You need to create so-called "refmaps" for Mixin, which convert the names you used to declare injection points and reference other parts of Minecraft code to the names used at runtime (SRG). + +This is usually done by including the Mixin annotation processor in your build: + +```groovy +dependencies { + annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' + // If you have additional source sets that contain Mixins, you also need to apply the AP to those + // For example if you have a "client" source set: + clientAnnotationProcessor 'org.spongepowered:mixin:0.8.5:processor' +} +``` + +You need to let the AP know about your Mixin configuration files, and how you'd like your refmap to be named for each +of the source sets that contain mixins: + +```groovy +mixin { + add sourceSets.main, 'mixins.mymod.refmap.json' + config 'mixins.mymod.json' // This can be done for multiple configs +} +``` + +Please note, you also have to add the `MixinConfigs` attribute to your Jar manifest for your Mixins to load in production. Such as this way: + +```groovy +jar { + manifest.attributes([ + "MixinConfigs": "mixinextras.init.mixins.json" + ]) +} +``` + ## Effects of applying the legacy plugin When applied, the legacy plugin will change the base NeoForm and NeoForge artifact coordinates of the `neoForge` extension to `de.oceanlabs.mcp:mcp_config` and `net.minecraftforge:forge`. diff --git a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/Obfuscation.java b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/Obfuscation.java index d417b2de..c76335b3 100644 --- a/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/Obfuscation.java +++ b/src/legacy/java/net/neoforged/moddevgradle/legacyforge/dsl/Obfuscation.java @@ -70,7 +70,7 @@ public TaskProvider reobfuscate(TaskProvider { task.getInput().set(jar.flatMap(AbstractArchiveTask::getArchiveFile)); - task.getDestinationDirectory().convention(task.getProject().getLayout().getBuildDirectory()); + task.getDestinationDirectory().convention(task.getProject().getLayout().getBuildDirectory().dir("libs")); task.getArchiveBaseName().convention(jar.flatMap(AbstractArchiveTask::getArchiveBaseName)); task.getArchiveVersion().convention(jar.flatMap(AbstractArchiveTask::getArchiveVersion)); task.getArchiveClassifier().convention(jar.flatMap(AbstractArchiveTask::getArchiveClassifier)); From f4901c6144471c931852155c340cc134add691a8 Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Thu, 5 Dec 2024 20:03:23 +0100 Subject: [PATCH 2/2] Review comments --- LEGACY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LEGACY.md b/LEGACY.md index 19ad0858..9d4d92a2 100644 --- a/LEGACY.md +++ b/LEGACY.md @@ -121,7 +121,7 @@ Please note, you also have to add the `MixinConfigs` attribute to your Jar manif ```groovy jar { manifest.attributes([ - "MixinConfigs": "mixinextras.init.mixins.json" + "MixinConfigs": "mixins.mymod.json" ]) } ```