Skip to content

ArgumentException: duplicate key in SetupTextureOverrides when multiple animated content packs are loaded #580

Description

@GREED014

Bug Description

When multiple animated content packs (such as Animated Fish,
AnimatedGemstones, Animated Food and Drinks, Animated Mining Pack)
are loaded together, SpaceCore throws an ArgumentException in
SetupTextureOverrides.

Error

ArgumentException: An item with the same key has already been added.
Key: {X:208 Y:352 Width:16 Height:16}
at System.Collections.Generic.Dictionary`2.TryInsert
at SpaceCore.VanillaAssetExpansion.VanillaAssetExpansion.SetupTextureOverrides()
at VanillaAssetExpansion.cs:line 316

Steps to Reproduce

  1. Install multiple animated content packs that use SpaceCore texture overrides
  2. Launch the game
  3. Error appears in SMAPI log

Workaround

I created a Harmony patch that suppresses the error as a temporary fix:
https://www.nexusmods.com/stardewvalley/mods/46515

The patch catches the ArgumentException in a Harmony Finalizer,
preventing the crash. However, this does not fix the root cause.

A proper fix would be to check if the key already exists before
calling Dictionary.Add in SetupTextureOverrides (line 316).

SMAPI Version

4.5.2

Game Version

Stardew Valley 1.6.15

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingmod - SpaceCoreAffects SpaceCore

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions