Tetra

Tetra

25M Downloads

[1.20.1] Tetra bricks datagen due to the way client setup is handled.

Fealtous opened this issue ยท 2 comments

commented

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.safeRunWhenOn(Dist.CLIENT, () -> ClientSetup::init);

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.

public static void init() {
FMLJavaModLoadingContext.get().getModEventBus().register(ClientSetup.class);
MinecraftForge.EVENT_BUS.register(ClientSetup.class);
ReloadableResourceManager resourceManager = (ReloadableResourceManager) Minecraft.getInstance().getResourceManager();
StatRegistry.init();
resourceManager.registerReloadListener(new StatIndicatorStore());
resourceManager.registerReloadListener(new StatBarStore());
resourceManager.registerReloadListener(new StatSorterStore());
resourceManager.registerReloadListener(new HolosphereEntryStore());
// todo: seems to cause issues during datagen
resourceManager.registerReloadListener(new ToolActionIconStore());

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.

commented

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!

commented

Ah, that works too. I had tested the changes locally with FMLClientSetupEvent and it didn't seem to stop working, but glad to know there's a proper event for it.