From a53ddaf880cd89c51401b1ea42df34351e069361 Mon Sep 17 00:00:00 2001 From: XFactHD Date: Sun, 16 Jun 2024 01:46:39 +0200 Subject: [PATCH] Add enum extensions rework to 1.21 blog post --- content/news/21.0release.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/content/news/21.0release.md b/content/news/21.0release.md index ed67528..52742d8 100644 --- a/content/news/21.0release.md +++ b/content/news/21.0release.md @@ -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 == )` 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).