Add access transformers
This commit is contained in:
parent
b96ba8a968
commit
c1dabe37d8
4 changed files with 17 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
2
src/main/resources/accesstransformer.cfg
Normal file
2
src/main/resources/accesstransformer.cfg
Normal file
|
@ -0,0 +1,2 @@
|
|||
|
||||
public net.minecraft.client.renderer.GlStateManager$Color
|
Loading…
Add table
Reference in a new issue