WackyMole-Multiple_RecipeItem_BugFix icon

Multiple RecipeItem BugFix

A partial fix for a bug in **ItemManager** related to recipes with more than 4 items.

Last updated 8 hours ago
Total downloads 19
Total rating 0 
Categories Crafting Client-side
Dependency string WackyMole-Multiple_RecipeItem_BugFix-1.0.0
Dependants 0 other packages depend on this package

This mod requires the following mods to function

denikson-BepInExPack_Valheim-5.4.2202 icon
denikson-BepInExPack_Valheim

BepInEx pack for Valheim. Preconfigured and includes unstripped Unity DLLs.

Preferred version: 5.4.2202

README

WackyZ Multiple Item Recipe BugFix

Description: A partial fix for a bug in ItemManager related to recipes with more than 4 items.


Overview

This mod addresses a specific bug in ItemManager where recipes with more than 4 items (but not multiples of 4) fail to cycle through their items correctly. For example, recipes with 5, 6, or 7 items do not display properly. This issue is particularly noticeable in recipes like fish, which often have more than 4 ingredients.

This mod serves as a compromising bandaid rather than a complete fix. It removes a low-priority transpiler patch in ItemManager that ensures Valheim distinguishes between active and inactive requirements when displaying up to 4 items. While this patch is not critical, its removal resolves the display issue for recipes with more than 4 items.


The Bug

The bug occurs in ItemManager when handling recipes with more than 4 items. Specifically:

  • Recipes with 5, 6, or 7 items do not cycle through their items correctly.
  • The issue stems from how ItemManager handles the cutoff for displaying up to 4 items, particularly when distinguishing between active and inactive requirements (e.g., items belonging to another upgrade level).

The problematic code in ItemManager can be found here:
ItemManager.cs Line 1095


The Fix

This mod works by unpatching a transpiler patch in ItemManager. The patch being removed is responsible for ensuring Valheim distinguishes between active and inactive requirements when displaying up to 4 items. While this patch is not critical, its removal resolves the display issue for recipes with more than 4 items.

Technical Details

  • The mod uses Harmony to unpatch the following method:
    harmony.Unpatch(
        AccessTools.DeclaredMethod(typeof(InventoryGui), nameof(InventoryGui.SetupRequirementList)),
        HarmonyPatchType.Transpiler,
        harmony.Id
    );
    
  • This removes the transpiler patch applied by ItemManager, allowing recipes with more than 4 items to display correctly.

Limitations

This mod is a partial fix and not a complete solution. It works around the issue by removing a low-priority patch in ItemManager, but it does not address the root cause of the bug. A proper fix would require deeper changes to ItemManager's code.


Future Improvements

This mod is intended as a temporary solution until a proper fix is implemented in ItemManager. If you have the knowledge and skills to address the root cause of the bug, contributions are welcome! Please refer to the ItemManager GitHub repository for more details.


Credits

  • WackyMole: Mod creator and author of this fix.
  • blaxxun-boop: Original author of ItemManager.
  • HarmonyX: For providing the patching and unpatching functionality.

Support

Disclaimer: This mod is provided as-is. Use at your own risk. The author is not responsible for any issues caused by this mod.


Enjoy your Valheim adventures with properly displayed recipes! 🛠️🐟