From 366b74ac9efbefc9ca1543d1387c90c79eb44634 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 27 Jul 2024 00:04:27 +0900 Subject: [PATCH] Add mixins to forge 1206 test --- .../test/integration/forge/Forge1206Test.groovy | 6 +++--- .../resources/projects/forge/1206/build.gradle | 11 +++++++++++ .../example/examplemod/mixin/ExampleModMixin.java | 15 +++++++++++++++ .../src/main/resources/examplemod.mixins.json | 14 ++++++++++++++ 4 files changed, 43 insertions(+), 3 deletions(-) create mode 100644 src/test/resources/projects/forge/1206/src/main/java/com/example/examplemod/mixin/ExampleModMixin.java create mode 100644 src/test/resources/projects/forge/1206/src/main/resources/examplemod.mixins.json diff --git a/src/test/groovy/net/fabricmc/loom/test/integration/forge/Forge1206Test.groovy b/src/test/groovy/net/fabricmc/loom/test/integration/forge/Forge1206Test.groovy index f19cd9cc8..5c9f1e81d 100644 --- a/src/test/groovy/net/fabricmc/loom/test/integration/forge/Forge1206Test.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/integration/forge/Forge1206Test.groovy @@ -34,7 +34,7 @@ import static org.gradle.testkit.runner.TaskOutcome.SUCCESS class Forge1206Test extends Specification implements GradleProjectTestTrait { @Unroll - def "build #mcVersion #neoforgeVersion #mappings #patches"() { + def "build #mcVersion #forgeVersion #mappings #patches"() { if (Integer.valueOf(System.getProperty("java.version").split("\\.")[0]) < 21) { println("This test requires Java 21. Currently you have Java ${System.getProperty("java.version")}.") return @@ -43,7 +43,7 @@ class Forge1206Test extends Specification implements GradleProjectTestTrait { setup: def gradle = gradleProject(project: "forge/1206", version: DEFAULT_GRADLE) gradle.buildGradle.text = gradle.buildGradle.text.replace('@MCVERSION@', mcVersion) - .replace('@FORGEVERSION@', neoforgeVersion) + .replace('@FORGEVERSION@', forgeVersion) .replace('MAPPINGS', mappings) // Spotless doesn't like the @'s .replace('PATCHES', patches) @@ -54,7 +54,7 @@ class Forge1206Test extends Specification implements GradleProjectTestTrait { result.task(":build").outcome == SUCCESS where: - mcVersion | neoforgeVersion | mappings | patches + mcVersion | forgeVersion | mappings | patches '1.20.6' | '1.20.6-50.1.3' | 'loom.officialMojangMappings()' | '' } } diff --git a/src/test/resources/projects/forge/1206/build.gradle b/src/test/resources/projects/forge/1206/build.gradle index 36bc2f7ba..e398cfbf6 100644 --- a/src/test/resources/projects/forge/1206/build.gradle +++ b/src/test/resources/projects/forge/1206/build.gradle @@ -18,6 +18,17 @@ group = project.maven_group def mcVersion = "@MCVERSION@" def forgeVersion = "@FORGEVERSION@" + +loom { + forge { + mixinConfig "examplemod.mixins.json" + } + + afterEvaluate { + assert mixin.useLegacyMixinAp.get() == false + } +} + repositories { // Add repositories to retrieve artifacts from in here. // You should only use this when depending on other mods because diff --git a/src/test/resources/projects/forge/1206/src/main/java/com/example/examplemod/mixin/ExampleModMixin.java b/src/test/resources/projects/forge/1206/src/main/java/com/example/examplemod/mixin/ExampleModMixin.java new file mode 100644 index 000000000..d4cda6cd2 --- /dev/null +++ b/src/test/resources/projects/forge/1206/src/main/java/com/example/examplemod/mixin/ExampleModMixin.java @@ -0,0 +1,15 @@ +package com.example.examplemod.mixin; + +import net.minecraft.client.Minecraft; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(Minecraft.class) +public class ExampleModMixin { + @Inject(method = "", at = @At("HEAD")) + private static void initInject(CallbackInfo info) { + System.out.println("Hello from the example mod mixin!"); + } +} diff --git a/src/test/resources/projects/forge/1206/src/main/resources/examplemod.mixins.json b/src/test/resources/projects/forge/1206/src/main/resources/examplemod.mixins.json new file mode 100644 index 000000000..d55eec7ac --- /dev/null +++ b/src/test/resources/projects/forge/1206/src/main/resources/examplemod.mixins.json @@ -0,0 +1,14 @@ +{ + "required": true, + "minVersion": "0.8", + "package": "com.example.examplemod.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [ + ], + "client": [ + "ExampleModMixin" + ], + "injectors": { + "defaultRequire": 1 + } +} \ No newline at end of file