
[1.20.1] Tetra bricks datagen due to the way client setup is handled.
Fealtous opened this issue ยท 2 comments
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
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.
tetra/src/main/java/se/mickelus/tetra/ClientSetup.java
Lines 58 to 72 in 541631b
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.
Ow, wrote a reply but I never pressed send. Registering the reload listeners in FMLClientSetupEvent seemed to be too late, but RegisterClientReloadListenersEvent seems to be made for this and that works great!