Skip to content

Commit

Permalink
feat(docs): Add MDG examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ChampionAsh5357 committed Mar 7, 2025
1 parent 6be20f4 commit e0a28af
Show file tree
Hide file tree
Showing 3 changed files with 88 additions and 25 deletions.
43 changes: 41 additions & 2 deletions docs/advanced/accesstransformers.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Access Transformers

Access Transformers (ATs for short) allow for widening the visibility and modifying the `final` flags of classes, methods, and fields. They allow modders to access and modify otherwise inaccessible members in classes outside their control.
Expand All @@ -10,7 +13,21 @@ Adding an Access Transformer to your mod project is as simple as adding a single

Access Transformers need to be declared in `build.gradle`. AT files can be specified anywhere as long as they are copied to the `resources` output directory on compilation.

```groovy
<Tabs groupId="build-system">
<TabItem value="moddevgradle" label="ModDevGradle" default>

```gradle
// In build.gradle:
// This block is where your mappings version is also specified
neoForge {
accessTransformers = project.files('src/main/resources/META-INF/accesstransformer.cfg')
}
```

</TabItem>
<TabItem value="neogradle" label="NeoGradle">

```gradle
// In build.gradle:
// This block is where your mappings version is also specified
minecraft {
Expand All @@ -20,6 +37,9 @@ minecraft {
}
```

</TabItem>
</Tabs>

By default, NeoForge will search for `META-INF/accesstransformer.cfg`. If the `build.gradle` specifies access transformers in any other location, then their location needs to be defined within `neoforge.mods.toml`:

```toml
Expand All @@ -32,7 +52,23 @@ file="META-INF/accesstransformer.cfg"

Additionally, multiple AT files can be specified and will be applied in order. This can be useful for larger mods with multiple packages.

```groovy
<Tabs groupId="build-system">
<TabItem value="moddevgradle" label="ModDevGradle" default>

```gradle
// In build.gradle:
neoForge {
accessTransformers = project.files(
'src/main/resources/accesstransformer_main.cfg',
'src/additions/resources/accesstransformer_additions.cfg'
)
}
```

</TabItem>
<TabItem value="neogradle" label="NeoGradle">

```gradle
// In build.gradle:
minecraft {
accessTransformers {
Expand All @@ -42,6 +78,9 @@ minecraft {
}
```

</TabItem>
</Tabs>

```toml
# In neoforge.mods.toml
[[accessTransformers]]
Expand Down
23 changes: 2 additions & 21 deletions docs/misc/gametest.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ If the buildscript was [setup as recommended][buildscript], then only Game Tests

```gradle
// Inside a run configuration
property 'neoforge.enabledGameTestNamespaces', 'modid1,modid2,modid3'
systemProperty 'neoforge.enabledGameTestNamespaces', 'modid1,modid2,modid3'
```

:::caution
Expand All @@ -248,32 +248,13 @@ There must be no spaces in-between namespaces; otherwise, the namespace will not

The Game Test Server is a special configuration which runs a build server. The build server returns an exit code of the number of required, failed Game Tests. All failed tests, whether required or optional, are logged. This server can be run using `gradlew runGameTestServer`.

<details>
<summary>Important information on NeoGradle</summary>

:::caution
Due to a quirk in how Gradle works, by default, if a task forces a system exit, the Gradle daemon will be killed, causing the Gradle runner to report a build failure. NeoGradle sets by default a force exit on run tasks such that any subprojects are not executed in sequence. However, as such, the Game Test Server will always fail.

This can be fixed by disabling the force exit on the run configuration using the `#setForceExit` method:

```gradle
// Game Test Server run configuration
gameTestServer {
// ...
setForceExit false
}
```
:::
</details>


### Enabling Game Tests in Other Run Configurations

By default, only the `client`, `server`, and `gameTestServer` run configurations have Game Tests enabled. If another run configuration should run Game Tests, then the `neoforge.enableGameTest` property must be set to `true`.

```gradle
// Inside a run configuration
property 'neoforge.enableGameTest', 'true'
systemProperty 'neoforge.enableGameTest', 'true'
```

[test]: #running-game-tests
Expand Down
47 changes: 45 additions & 2 deletions docs/resources/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# Resources

Resources are external files that are used by the game, but are not code. The most prominent kinds of resources are textures, however, many other types of resources exist in the Minecraft ecosystem. Of course, all these resources require a consumer on the code side, so the consuming systems are grouped in this section as well.
Expand Down Expand Up @@ -176,7 +179,10 @@ The data generator can accept several command line arguments:

All arguments can be added to the run configurations by adding the following to your `build.gradle`:

```groovy
<Tabs groupId="build-system">
<TabItem value="moddevgradle" label="ModDevGradle" default>

```gradle
runs {
// other run configurations here

Expand All @@ -186,9 +192,28 @@ runs {
}
```

</TabItem>
<TabItem value="neogradle" label="NeoGradle">

```gradle
runs {
// other run configurations here

clientData {
arguments.addAll '--arg1', 'value1', '--arg2', 'value2', '--all' // boolean args have no value
}
}
```

</TabItem>
</Tabs>

For example, to replicate the default arguments, you could specify the following:

```groovy
<Tabs groupId="build-system">
<TabItem value="moddevgradle" label="ModDevGradle" default>

```gradle
runs {
// other run configurations here

Expand All @@ -200,6 +225,24 @@ runs {
}
```

</TabItem>
<TabItem value="neogradle" label="NeoGradle">

```gradle
runs {
// other run configurations here

clientData {
arguments.addAll '--mod', 'examplemod', // insert your own mod id
'--output', file('src/generated/resources').getAbsolutePath(),
'--all'
}
}
```

</TabItem>
</Tabs>

[advancementprovider]: server/advancements.md#data-generation
[advancements]: server/advancements.md
[bsfile]: client/models/index.md#blockstate-files
Expand Down

1 comment on commit e0a28af

@neoforged-pages-deployments
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploying with Cloudflare Pages

Name Result
Last commit: e0a28afd5cfa18c32eb85676ab2fc13df805f5fa
Status: ✅ Deploy successful!
Preview URL: https://3a7ee1d1.neoforged-docs-previews.pages.dev
PR Preview URL: https://pr-234.neoforged-docs-previews.pages.dev

Please sign in to comment.