AccessTransformers and AccessWideners now apply if the file is present

AccessWideners are shared on common and fabric, since you will most likely need them in common anyway, and they are faster to apply than AccessTransformers
This commit is contained in:
Jared 2023-06-11 03:27:39 +02:00
parent 2baa2d2ba4
commit 531f251168
4 changed files with 11 additions and 6 deletions

View File

@ -9,6 +9,9 @@ archivesBaseName = "${mod_name}-common-${minecraft_version}"
minecraft {
version(minecraft_version)
if(file("src/main/resources/${mod_id}.accesswidener").exists()){
accessWideners(file("src/main/resources/${mod_id}.accesswidener"))
}
}
dependencies {

View File

@ -17,6 +17,9 @@ dependencies {
}
loom {
if(project(":common").file("src/main/resources/${mod_id}.accesswidener").exists()){
accessWidenerPath.set(project(":common").file("src/main/resources/${mod_id}.accesswidener"))
}
mixin {
defaultRefmapName.set("${mod_id}.refmap.json")
}

View File

@ -16,12 +16,12 @@ mixin {
minecraft {
mappings channel: 'official', version: minecraft_version
if (project.hasProperty('forge_ats_enabled') && project.findProperty('forge_ats_enabled').toBoolean()) {
// This location is hardcoded in Forge and can not be changed.
// https://github.com/MinecraftForge/MinecraftForge/blob/be1698bb1554f9c8fa2f58e32b9ab70bc4385e60/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java#L123
// Automatically enable forge AccessTransformers if the file exists
// This location is hardcoded in Forge and can not be changed.
// https://github.com/MinecraftForge/MinecraftForge/blob/be1698bb1554f9c8fa2f58e32b9ab70bc4385e60/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java#L123
if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) {
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
project.logger.debug('Forge Access Transformers are enabled for this project.')
}
runs {

View File

@ -7,7 +7,6 @@ minecraft_version=1.19.3
# Forge
forge_version=44.0.1
//forge_ats_enabled=true
# Fabric
fabric_version=0.68.1+1.19.3