diff options
-rw-r--r-- | .github/workflows/build.yml | 2 | ||||
-rw-r--r-- | .github/workflows/gradle-wrapper-validation.yml | 2 | ||||
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | build.gradle.kts | 9 | ||||
-rw-r--r-- | settings.gradle.kts | 2 | ||||
-rw-r--r-- | src/main/java/com/example/ExampleMod.java | 3 | ||||
-rw-r--r-- | src/main/resources/accesstransformer.cfg | 2 |
7 files changed, 20 insertions, 4 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e1e773f..538c14b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: java-version: 17 - name: Setup Gradle - uses: gradle/actions/setup-gradle@v3 + uses: gradle/actions/setup-gradle@v4 - name: Execute Gradle build run: ./gradlew build diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml index 12213d2..5a0d32d 100644 --- a/.github/workflows/gradle-wrapper-validation.yml +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -7,4 +7,4 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4.1.1 - - uses: gradle/wrapper-validation-action@v2.0.0
\ No newline at end of file + - uses: gradle/actions/wrapper-validation@v4 @@ -30,6 +30,10 @@ are used by the build system but *do not work* in a normal forge installation. If you don't want mixins (which allow for modifying vanilla code), then you can remove the references to mixins from the `build.gradle.kts` at the lines specified with comments and the `com.example.mixin` package. +If you don't want access transformers (which allow for making methods public/non-final) you can delete the +`accesstransformer.cfg` file. If you make a change to the `accesstransformers.cfg` you might need to rebuild your +project using `./gradlew build --refresh-dependencies`. + ### For those who have not an attention span [](https://www.youtube.com/watch?v=nWzHlomdCgc) diff --git a/build.gradle.kts b/build.gradle.kts index 93ce3eb..686fe0f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,6 +15,7 @@ val mcVersion: String by project val version: String by project val mixinGroup = "$baseGroup.mixin" val modid: String by project +val transformerFile = file("src/main/resources/accesstransformer.cfg") // Toolchains: java { @@ -44,6 +45,10 @@ loom { pack200Provider.set(dev.architectury.pack200.java.Pack200Adapter()) // If you don't want mixins, remove this lines mixinConfig("mixins.$modid.json") + if (transformerFile.exists()) { + println("Installing access transformer") + accessTransformer(transformerFile) + } } // If you don't want mixins, remove these lines mixin { @@ -99,6 +104,8 @@ tasks.withType(org.gradle.jvm.tasks.Jar::class) { // If you don't want mixins, remove these lines this["TweakClass"] = "org.spongepowered.asm.launch.MixinTweaker" this["MixinConfigs"] = "mixins.$modid.json" + if (transformerFile.exists()) + this["FMLAT"] = "${modid}_at.cfg" } } @@ -112,7 +119,7 @@ tasks.processResources { expand(inputs.properties) } - rename("(.+_at.cfg)", "META-INF/$1") + rename("accesstransformer.cfg", "META-INF/${modid}_at.cfg") } diff --git a/settings.gradle.kts b/settings.gradle.kts index 05f4f1e..717897f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -7,7 +7,7 @@ pluginManagement { maven("https://maven.fabricmc.net") maven("https://maven.minecraftforge.net/") maven("https://repo.spongepowered.org/maven/") - maven("https://repo.sk1er.club/repository/maven-releases/") + maven("https://repo.essential.gg/repository/maven-releases/") } resolutionStrategy { eachPlugin { diff --git a/src/main/java/com/example/ExampleMod.java b/src/main/java/com/example/ExampleMod.java index c18b591..2ce1671 100644 --- a/src/main/java/com/example/ExampleMod.java +++ b/src/main/java/com/example/ExampleMod.java @@ -1,5 +1,6 @@ package com.example; +import net.minecraft.client.renderer.GlStateManager; import net.minecraft.init.Blocks; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; @@ -9,5 +10,7 @@ public class ExampleMod { @Mod.EventHandler public void init(FMLInitializationEvent event) { System.out.println("Dirt: " + Blocks.dirt.getUnlocalizedName()); + // Below is a demonstration of an access-transformed class access. + System.out.println("Color State: " + new GlStateManager.Color()); } } diff --git a/src/main/resources/accesstransformer.cfg b/src/main/resources/accesstransformer.cfg new file mode 100644 index 0000000..1a7a2b3 --- /dev/null +++ b/src/main/resources/accesstransformer.cfg @@ -0,0 +1,2 @@ + +public net.minecraft.client.renderer.GlStateManager$Color |