aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-08-08 12:44:50 +0200
committerLinnea Gräf <nea@nea.moe>2024-08-08 12:44:50 +0200
commitc1dabe37d8b43d90a682edde797df9b278ec4a47 (patch)
tree08b712083aa77affee15da3aeaca38d268311eb7
parentb96ba8a968bffc99f8749d13d8b5fc38b0f3f565 (diff)
downloadForge1.8.9Template-c1dabe37d8b43d90a682edde797df9b278ec4a47.tar.gz
Forge1.8.9Template-c1dabe37d8b43d90a682edde797df9b278ec4a47.tar.bz2
Forge1.8.9Template-c1dabe37d8b43d90a682edde797df9b278ec4a47.zip
Add access transformersHEADmaster
-rw-r--r--README.md4
-rw-r--r--build.gradle.kts9
-rw-r--r--src/main/java/com/example/ExampleMod.java3
-rw-r--r--src/main/resources/accesstransformer.cfg2
4 files changed, 17 insertions, 1 deletions
diff --git a/README.md b/README.md
index 79b81ca..8566930 100644
--- a/README.md
+++ b/README.md
@@ -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
[![Youtube Tutorial](https://i.ytimg.com/vi/nWzHlomdCgc/maxresdefault.jpg)](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/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