[1.20.1] Tetra bricks datagen due to the way client setup is handled.
Only noticed due to a modder making an addon to tetra and them wanting to use datagen, here's a few things to address. [Relevant userdev log](https://mclo.gs/8wB78vU)
https://github.com/mickelus/tetra/blob/541631bf06afd1c3db3d417569488f14171e9f60/src/main/java/se/mickelus/tetra/TetraMod.java#L81
DistExecutor is deprecated and no longer necessary with Java 17 in the picture, this can be replaced with:
`if (FMLEnvironment.dist == Dist.CLIENT) {
ClientSetup.init();
}`
Modern java classloading rules lets this just work, the DistExecutor system is a holdover from java 8 where the above wasn't a thing. Technically this isn't a bug nor the cause of the issue, but it's best to avoid using deprecated features (of forge) when possible.
Next, due to the fact that the `runData` task does not actually instantiate Minecraft, the `Minecraft#getInstance` call at line 62 crashes the task because of a NPE. Moving the client setup into the client setup event listener resolves this issue as FMLClientSetupEvent does not fire during datagen.
https://github.com/mickelus/tetra/blob/541631bf06afd1c3db3d417569488f14171e9f60/src/main/java/se/mickelus/tetra/ClientSetup.java#L58-L72
Finally, consider updating your environment to at least 47.4.0. Neo themselves do not recommend using neo for 1.20.1, and you're missing out on ~2 years of development. Forge continues to support 1.20.1 with new features, optimizations, and improvements. If you'd like, I can write up a PR which addresses the two above issues and optionally also migrating to a modern forge version. If you're satisfied with just fixing the datagen issue, that's fine too.
2 条评论