JavidPack / RecipeBrowser

RecipeBrowser mod for tModLoader
https://forums.terraria.org/index.php?threads/recipe-browser.62462/
79 stars 50 forks source link

IndexOutOfRangeException after using Magic Storage #63

Open kubson3824 opened 3 years ago

kubson3824 commented 3 years ago

I'm using RecursiveCraft, Magic Storage Extra and Recipe Browser, after I exit the Magic Storage Crafting Interface and try to check a recipe in Recipe Browser, I get this: [14:16:27] [1/ERROR] [Terraria]: System.IndexOutOfRangeException: Index was outside the bounds of the array. at RecipeBrowser.RecipeCatalogueUI.SetRecipe(Int32 index) in RecipeBrowser\RecipeCatalogueUI.cs:line 747 at RecipeBrowser.UIElements.UIRecipeSlot.Click(UIMouseEvent evt) in RecipeBrowser\UIElements\UIRecipeSlot.cs:line 67 at Terraria.UI.UserInterface.Update(GameTime time) at Terraria.ModLoader.ModHooks.UpdateUI(GameTime gameTime) at Terraria.Main.DoUpdate(GameTime gameTime) at DMD<Terraria.Main::Update>(Main , GameTime )

Using mods: [ "AlchemistNPC", "AutoTrash", "Azercadmium", "CalamityMod", "CalValEX", "ElementsAwoken", "Fargowiltas", "FargowiltasSouls", "Luiafk", "MagicStorageExtra", "MaxStackExtra", "Polarities", "RecipeBrowser", "Redemption", "SacredTools", "SpiritMod", "Split", "StarsAbove", "SubworldLibrary", "VeinMiner", "WingSlot", "FKBossHealthBar", "BossChecklist", "imkSushisMod", "imkSushisModAddOn", "WMITF", "Laugicality", "WebmilioCommons", "SOTS", "FargowiltasSoulsDLC", "RecursiveCraft" ]

kubson3824 commented 3 years ago

Issue fixed, turns out it was a Magic Storage problem

ExterminatorX99 commented 3 years ago

This happens when a recursive recipe with more than Recipe.maxRequirements(default 15) ingredients is viewed, which in turn causes maxRequirements to be increased. Due to RecipeBrowser using maxRequirements, this causes an IndexOutOfRange Exception.

Ishigh1 commented 3 years ago

Actually there is an other way to solve this instead of changing all the maxRequirements to ingredient.Length, it's to make a break when an item.type == ItemID.None like vanilla does. But Recipe Browser continues instead, which is a bit inefficient and have unexpected consequences like this bug

ExterminatorX99 commented 3 years ago

Without ingredient.Length, the selected (compound) recipe's ingredients would get truncated to 15 items causing long compound recipes to not have all ingredients listed in the recipe browser UI