NeoForge 21.4 for Minecraft 1.21.4

The first beta release of NeoForge 21.4 for Minecraft 1.21.4 is now available: 21.4.0-beta.

Data Generation Splitting

A notable change in Minecraft 1.21.4 is that there are now two data generation entrypoints: one for client assets, and one for server data. To reflect this, the GatherDataEvent has been split into GatherDataEvent.Client and GatherDataEvent.Server. To reflect this, the data run type in Gradle has been replaced by clientData and serverData run types.

While split data generation is possible and fully supported, we do not encourage it:

  • Data generation would require two separate runs, one for client data and one for server data.
  • Data generation would produce two folders with generated resources.

Our recommendation is instead to generate all assets and data in a single clientData run.

Here is how to update a Gradle build script (using ModDevGradle) to change the run type to use for datagen:

  neoForge {
      runs {
          data { // Keep the name as `data` so that the command remains `gradlew runData`
-             data()
+             clientData() // Update run type from `data` to `clientData`
              // Other configuration
          }
      }
  }

And here is how to update a Gradle build script using NeoGradle:

  runs {
-     data {
+     clientData { // The run type is inferred from the run name. The new command will be `gradlew runClientData`
          // Other configuration
      }
  }

And here is an example showing how to update the data provider registration code:

- public void onGatherData(GatherDataEvent event) {
+ public void onGatherData(GatherDataEvent.Client event) {
-     event.addProvider(event.includeClient(), new Provider(...));
+     event.addProvider(new Provider(...));
      // And so on...
  }

Naturally, the event listener should only be registered on the client dist.

Note that event.includeClient() and event.includeServer() have been removed: modders are already in full control of their datagen runs and can configure which providers they want to run through other means.

Porting Primer

A porting primer covering Minecraft’s changes is available here: https://github.com/ChampionAsh5357/neoforged-github/blob/port/1214/primers/1.21.4/index.md, courtesy of @ChampionAsh5357.

We might update this blog post later with more NeoForge-specific changes.

Stay tuned, and happy porting!