Add mixins to forge 1206 test

This commit is contained in:
shedaniel
2024-07-27 00:04:27 +09:00
parent 642d2a1e95
commit 366b74ac9e
4 changed files with 43 additions and 3 deletions

View File

@@ -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()' | ''
}
}

View File

@@ -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

View File

@@ -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 = "<clinit>", at = @At("HEAD"))
private static void initInject(CallbackInfo info) {
System.out.println("Hello from the example mod mixin!");
}
}

View File

@@ -0,0 +1,14 @@
{
"required": true,
"minVersion": "0.8",
"package": "com.example.examplemod.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
"ExampleModMixin"
],
"injectors": {
"defaultRequire": 1
}
}