Skip to content

Commit aa80e99

Browse files
committed
Added updates to Access Transformer sections
1 parent 56569a0 commit aa80e99

File tree

2 files changed

+88
-5
lines changed

2 files changed

+88
-5
lines changed

docs/advanced/accesstransformers.md renamed to docs/advanced/accesstransformers.mdx

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import Tabs from '@theme/Tabs';
2+
import TabItem from '@theme/TabItem';
3+
14
Access Transformers
25
===================
36

@@ -10,16 +13,56 @@ Adding ATs
1013

1114
Adding an Access Transformer to your mod project is as simple as adding a single line into your `build.gradle`:
1215

16+
<Tabs defaultValue="latest">
17+
<TabItem value="latest" label="Latest">
18+
Access Transformers need to be declared in both `build.gradle` and `mods.toml`:
19+
1320
```groovy
21+
// In build.gradle:
1422
// This block is where your mappings version is also specified
1523
minecraft {
16-
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
24+
accessTransformers {
25+
file('src/main/resources/META-INF/accesstransformer.cfg')
26+
}
1727
}
1828
```
1929

20-
After adding or modifying the Access Transformer, the gradle project must be refreshed for the transformations to take effect.
30+
```toml
31+
# In mods.toml:
32+
[[accessTransformers]]
33+
file="META-INF/accesstransformer.at"
34+
```
35+
36+
AT files can be anywhere specified by the lines above, though NeoForge will default to searching for `META-INF/accesstransformer.cfg` if no other file is specified.
37+
38+
Additionally, multiple AT files can be specified and will be applied in order. This can be useful for larger mods with multiple packages.
39+
40+
```groovy
41+
// In build.gradle:
42+
minecraft {
43+
accessTransformers {
44+
file('src/main/resources/accesstransformer_main.cfg')
45+
file('src/additions/resources/accesstransformer_additions.cfg')
46+
}
47+
}
48+
```
49+
50+
```toml
51+
# In mods.toml
52+
[[accessTransformers]]
53+
file="accesstransformer_main.at"
54+
55+
[[accessTransformers]]
56+
file="accesstransformer_additions.at"
57+
```
58+
59+
After adding or modifying any Access Transformer, the Gradle project must be refreshed for the transformations to take effect.
60+
</TabItem>
61+
62+
<TabItem value="1.20.1" label="1.20.1-47.1 and older">
2163

22-
During development, the AT file can be anywhere specified by the line above. However, when loading in a non-development environment, Forge will only search for the exact path of `META-INF/accesstransformer.cfg` in your JAR file.
64+
</TabItem>
65+
</Tabs>
2366

2467
Comments
2568
--------

neogradle/docs/configuration/index.md renamed to neogradle/docs/configuration/index.mdx

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import Tabs from '@theme/Tabs';
2+
import TabItem from '@theme/TabItem';
3+
14
ForgeGradle Configurations
25
==========================
36

@@ -6,7 +9,42 @@ ForgeGradle has numerous configurations that can change how the development envi
69
Enabling Access Transformers
710
----------------------------
811

9-
[Access Transformers][at] can widen the visibility or modify the `final` flag of Minecraft classes, methods, and fields. To enable access transformers in the production environment, you can set `accessTransformer` to configuration file in question:
12+
13+
[Access Transformers][at] can widen the visibility or modify the `final` flag of Minecraft classes, methods, and fields.
14+
15+
<Tabs defaultValue="latest">
16+
<TabItem value="latest" label="Latest">
17+
To enable Access Transformers in the production environment, you can set `accessTransformers` to the configuration file in question:
18+
19+
```gradle
20+
minecraft {
21+
// ...
22+
23+
// Add an Access Transformer file relative to the project's directory
24+
accessTransformers {
25+
file('src/main/resources/META-INF/accesstransformer.cfg')
26+
27+
// Multiple files can be specified and are applied in order
28+
file('src/main/resources/accesstransformer_extras.cfg')
29+
}
30+
}
31+
```
32+
33+
In production, NeoForge will search for Access Transformer files as specified in `mods.toml`, or at `META-INF/accesstransformer.cfg` if none are specified:
34+
35+
```toml
36+
[[accessTransformers]]
37+
file="META-INF/accesstransformer.at"
38+
39+
[[accessTransformers]]
40+
file="accesstransformer_extras.at"
41+
```
42+
43+
</TabItem>
44+
45+
46+
<TabItem value="7.0.40" label="7.0.40 and older">
47+
To enable Access Transformers in the production environment, you can set `accessTransformer` to the configuration file in question:
1048

1149
```gradle
1250
minecraft {
@@ -18,8 +56,10 @@ minecraft {
1856
```
1957

2058
:::caution
21-
While the access transformer in the development environment can be read from anywhere the user specifies, in production, the file will only be read from `META-INF/accesstransformer.cfg`.
59+
While the Access Transformer in the development environment can be read from anywhere the user specifies, in production, the file will only be read from `META-INF/accesstransformer.cfg`.
2260
:::
61+
</TabItem>
62+
</Tabs>
2363

2464
Human-Readable Mappings
2565
-----------------------

0 commit comments

Comments
 (0)