Skip to content

Commit

Permalink
Add mixins to forge 1206 test
Browse files Browse the repository at this point in the history
  • Loading branch information
shedaniel committed Jul 26, 2024
1 parent 642d2a1 commit 366b74a
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)

Expand All @@ -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()' | ''
}
}
11 changes: 11 additions & 0 deletions src/test/resources/projects/forge/1206/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"required": true,
"minVersion": "0.8",
"package": "com.example.examplemod.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
],
"client": [
"ExampleModMixin"
],
"injectors": {
"defaultRequire": 1
}
}

0 comments on commit 366b74a

Please sign in to comment.