diff options
-rw-r--r-- | docs/release-notes.md | 1 | ||||
-rw-r--r-- | src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs | 59 |
2 files changed, 41 insertions, 19 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md index 304423fc..666dc8e4 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -10,6 +10,7 @@ ## Upcoming release * For players: * Fixed error when running the Windows installer as administrator (thanks to LostLogic!). + * Fixed `player_add` and `list_items` console commands not including some shirts _(in Console Commands)_. * For mod authors: * Added validation for the manifest `Dependencies` field. diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs index 34149209..69194f75 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs @@ -62,25 +62,8 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework yield return this.TryCreate(ItemType.Tool, this.CustomIDOffset + 3, _ => new Wand()); // clothing - { - // items - HashSet<int> clothingIds = new HashSet<int>(); - foreach (int id in Game1.clothingInformation.Keys) - { - if (id < 0) - continue; // placeholder data for character customization clothing below - - clothingIds.Add(id); - yield return this.TryCreate(ItemType.Clothing, id, p => new Clothing(p.ID)); - } - - // character customization shirts (some shirts in this range have no data, but game has special logic to handle them) - for (int id = 1000; id <= 1111; id++) - { - if (!clothingIds.Contains(id)) - yield return this.TryCreate(ItemType.Clothing, id, p => new Clothing(p.ID)); - } - } + foreach (int id in this.GetShirtIds()) + yield return this.TryCreate(ItemType.Clothing, id, p => new Clothing(p.ID)); // wallpapers for (int id = 0; id < 112; id++) @@ -333,5 +316,43 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework ? new Color(61, 55, 42) : (TailoringMenu.GetDyeColor(fish) ?? Color.Orange); } + + /// <summary>Get valid shirt IDs.</summary> + /// <remarks> + /// Shirts have a possible range of 1000–1999, but not all of those IDs are valid. There are two sets of IDs: + /// + /// <list type="number"> + /// <item> + /// Shirts which exist in <see cref="Game1.clothingInformation"/>. + /// </item> + /// <item> + /// Shirts with a dynamic ID and no entry in <see cref="Game1.clothingInformation"/>. These automatically + /// use the generic shirt entry with ID <c>-1</c> and are mapped to a calculated position in the + /// <c>Characters/Farmer/shirts</c> spritesheet. There's no constant we can use, but some known valid + /// ranges are 1000–1111 (used in <see cref="Farmer.changeShirt"/> for the customization screen and + /// 1000–1127 (used in <see cref="Utility.getShopStock"/> and <see cref="GameLocation.sandyShopStock"/>). + /// Based on the spritesheet, the max valid ID is 1299. + /// </item> + /// </list> + /// </remarks> + private IEnumerable<int> GetShirtIds() + { + // defined shirt items + foreach (int id in Game1.clothingInformation.Keys) + { + if (id < 0) + continue; // placeholder data for character customization clothing below + + yield return id; + } + + // dynamic shirts + HashSet<int> clothingIds = new HashSet<int>(Game1.clothingInformation.Keys); + for (int id = 1000; id <= 1299; id++) + { + if (!clothingIds.Contains(id)) + yield return id; + } + } } } |