Skip to content

Commit

Permalink
Add enum extensions rework to 1.21 blog post (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
XFactHD committed Jun 22, 2024
1 parent 9c7da29 commit 9ec56d1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions content/news/21.0release.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,23 @@ FML also had its deprecated members removed:
- `FMLJavaModLoadingContext#get` was removed. The direct replacement is `ModLoadingContext#get`, however use of it is discouraged. You should use direct references to your container where possible, and consider that the mod's event bus is provided as a mod class constructor argument.
- `DistExecutor` was removed without replacement. You should either use `if (FMLLoader.dist == <dist>)` checks, or separate entrypoints for client and common code.

### Enum extensions rework (introduced in NeoForge 21.0.10-beta)
Enum extensions were reworked to solve several shortcomings of the previous approach. Instead of adding new entries at an arbitrary time by calling a static method on the target enum, the values are now added by specifying them in an enum extensions JSON file which is used to add the new values when the enum is class-loaded. The JSON file is specified through the `enumExtensions` key in a `[[mods]]` block of the `neoforge.mods.toml`.
The entries specified in the file consist of the target enum, the field name, the constructor to be used and the parameters (specified as an array of constants, as a reference to a field of type `EnumProxy` or as a reference to a method):
```json5
{
"entries": [
{
"enum": "net/minecraft/world/item/ItemDisplayContext",
"name": "EXAMPLEMOD_STANDING",
"constructor": "(ILjava/lang/String;Ljava/lang/String;)V",
"parameters": [ -1, "examplemod:standing", null ]
}
]
}
```
See the [documentation](https://docs.neoforged.net/docs/advanced/extensibleenums) for further information on how to use the new system and the [FML PR](https://github.com/neoforged/FancyModLoader/pull/148) for further details on the motivations of this change.

## Experimental Gradle Plugin
We're currently developing a new experimental Gradle Plugin, focused on simpler buildscripts and improved caching. You can find information on its usage [here](https://github.com/NeoForged/ModDevGradle), and support is provided in the [thread](https://discord.com/channels/313125603924639766/1239579489617580072) on our [Discord server](https://discord.neoforged.net).

Expand Down

0 comments on commit 9ec56d1

Please sign in to comment.