Forestry

Forestry

65M Downloads

[1.12.2] Late recipe registration

Exaxxion opened this issue ยท 3 comments

commented

We noticed while trying to fix an issue in Shadows of Greg that Forestry is registering at least some of its recipes during FMLPostInitializationEvent which causes problems in environments that use CraftTweaker. Namely, such recipes are registered after scripts are processed so they are out of reach of CraftTweaker scripts entirely. This complicates things for modpack developers wanting to customize recipes for pack balance.

Per the Forge documentation, recipes are expected (by convention) to be registered as a response to the FMLInitializationEvent:

Called after FMLPreInitializationEvent and before FMLPostInitializationEvent during mod startup. This is the second of three commonly called events during mod initialization. Recommended activities: Register your recipes and Ore Dictionary entries in the GameRegistry and OreDictionary Dispatch requests through FMLInterModComms to other mods, to tell them what you wish them to do.

If possible, it would be greatly appreciated if recipes currently registered in the post-initialization phase could instead be registered in the initialization phase to correct this problem.

commented

Our recipes are registered during the FMLInitializationEvent. I have no idea what you're referencing.

@Override
public void registerRecipes() {

RecipeManagers.centrifugeManager.addRecipe(20, items.beeComb.get(EnumHoneyComb.HONEY, 1), ImmutableMap.of(
coreItems.beeswax.getItemStack(), 1.0f,
items.honeyDrop.getItemStack(), 0.9f
));

@EventHandler
public void init(FMLInitializationEvent event) {
// Register gui handler
NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());
ModuleManager.getInternalHandler().runInit();

public void runInit() {
stage = Stage.INIT;
for (IForestryModule module : modules) {
Log.debug("Init Start: {}", module);
module.doInit();
module.registerRecipes();
Log.debug("Init Complete: {}", module);
}
}

commented

Recipes should be registered in the RegistryEvent.Register<IRecipe> SubscribeEvent instead of in one of the main EventHandler stages. Registering recipes in init will mean CraftTweaker is unable to modify them since the recipes are created after CraftTweaker runs its scripts.

commented

Thanks Dan, admittedly I may not be doing the best job of explaining the problem. @DStrand1 is the submitter of the PR to SoG and the opening comment on that PR details how CraftTweaker loading works.