blushiemagic / MagicStorage

A tModLoader mod for Terraria
MIT License
178 stars 101 forks source link

When Recipe Recursion Depth is greater than 0 or set to -1, the OnCraftHook event for items will be unconditionally triggered. #275

Closed hocha113 closed 1 month ago

hocha113 commented 3 months ago

If the value of MagicStorageConfig.RecipeRecursionDepth is not 0, issues may occur. For example, if it is set to 1, clicking on any item in the CraftingAccess UI will cause all crafting events to be triggered once. If MagicStorageConfig.RecipeRecursionDepth is -1, a callback event will be triggered once. I suspect this is related to OnCraftHooks. Perhaps the problem lies in the lack of proper conditional checks in RecursiveRecipe.ModifyCraftingTree?

absoluteAquarian commented 2 months ago

The current public implementation of the recursion crafting logic calls RecipeLoader.OnCraft() during the simulations in order to catch items "dropped" by crafting recipes. This, however, leads to what you've observed where any OnCraft logic ends up running just from opening the UI. It has since been changed to use a separate opt-in system for "recipe craft drops" and only calling OnCraft during the actual crafts.

hocha113 commented 1 month ago

The current public implementation of the recursion crafting logic calls RecipeLoader.OnCraft() during the simulations in order to catch items "dropped" by crafting recipes. This, however, leads to what you've observed where any OnCraft logic ends up running just from opening the UI. It has since been changed to use a separate opt-in system for "recipe craft drops" and only calling OnCraft during the actual crafts.

Okay, great fix! Additionally, I submitted a pull request for a localization translation. If you don't have a better Chinese translation for now, you can take a look at this submission