Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add enum extensions rework to 1.21 blog post #40

Merged
merged 1 commit into from
Jun 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading