From 6d11d25254e5a97ce23911cdb843d207b928328e Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 14 Sep 2024 17:19:23 -0400 Subject: [PATCH] fix fishing spawn rules not shown for non-fish catches like River Jelly --- LookupAnything/DataParser.cs | 41 ++++++++----------- .../Framework/Lookups/Items/ItemSubject.cs | 3 +- LookupAnything/docs/release-notes.md | 1 + 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/LookupAnything/DataParser.cs b/LookupAnything/DataParser.cs index f3397b8b0..6234cc771 100644 --- a/LookupAnything/DataParser.cs +++ b/LookupAnything/DataParser.cs @@ -140,7 +140,7 @@ public IEnumerable GetFishPondPopulationGates(FishPo public IEnumerable GetFishPondDrops(FishPondData data) { foreach (FishPondReward drop in data.ProducedItems) - yield return new FishPondDropData(drop.RequiredPopulation, drop.ItemId, drop.MinQuantity, drop.MaxQuantity, drop.Chance); + yield return new FishPondDropData(drop.RequiredPopulation, drop.ItemId, drop.MinStack, drop.MaxStack, drop.Chance); } /// Read parsed data about the spawn rules for a specific fish. @@ -149,16 +149,6 @@ public IEnumerable GetFishPondDrops(FishPondData data) /// Derived from . public FishSpawnData? GetFishSpawnRules(string fishID, Metadata metadata) { - // get raw fish data - string[] fishFields; - { - if (!DataLoader.Fish(Game1.content).TryGetValue(fishID, out string? rawData)) - return null; - fishFields = rawData.Split('/'); - if (fishFields.Length < 13) - return null; - } - // parse location data var locations = new List(); foreach ((string locationId, LocationData data) in DataLoader.Locations(Game1.content)) @@ -217,21 +207,26 @@ from areaGroup in curLocations.GroupBy(p => p.Area) bool isUnique = false; if (locations.Any()) // ignore default spawn criteria if the fish doesn't spawn naturally; in that case it should be specified explicitly in custom data below (if any) { - // times of day - string[] timeFields = fishFields[5].Split(' '); - for (int i = 0, last = timeFields.Length + 1; i + 1 < last; i += 2) + if (DataLoader.Fish(Game1.content).TryGetValue(fishID, out string? rawData)) { - if (int.TryParse(timeFields[i], out int minTime) && int.TryParse(timeFields[i + 1], out int maxTime)) - timesOfDay.Add(new FishSpawnTimeOfDayData(minTime, maxTime)); - } + string[] fishFields = rawData.Split('/'); - // weather - if (!Enum.TryParse(fishFields[7], true, out weather)) - weather = FishSpawnWeather.Both; + // times of day + string[] timeFields = ArgUtility.Get(fishFields, 5)?.Split(' ') ?? Array.Empty(); + for (int i = 0, last = timeFields.Length + 1; i + 1 < last; i += 2) + { + if (int.TryParse(timeFields[i], out int minTime) && int.TryParse(timeFields[i + 1], out int maxTime)) + timesOfDay.Add(new FishSpawnTimeOfDayData(minTime, maxTime)); + } - // min fishing level - if (!int.TryParse(fishFields[12], out minFishingLevel)) - minFishingLevel = 0; + // weather + if (!Enum.TryParse(ArgUtility.Get(fishFields, 7), true, out weather)) + weather = FishSpawnWeather.Both; + + // min fishing level + if (!int.TryParse(ArgUtility.Get(fishFields, 12), out minFishingLevel)) + minFishingLevel = 0; + } } // read custom data diff --git a/LookupAnything/Framework/Lookups/Items/ItemSubject.cs b/LookupAnything/Framework/Lookups/Items/ItemSubject.cs index 31c49d910..3b2ca06f3 100644 --- a/LookupAnything/Framework/Lookups/Items/ItemSubject.cs +++ b/LookupAnything/Framework/Lookups/Items/ItemSubject.cs @@ -309,8 +309,7 @@ select name } // fish spawn rules - if (item.Category == SObject.FishCategory) - yield return new FishSpawnRulesField(this.GameHelper, I18n.Item_FishSpawnRules(), item.ItemId); + yield return new FishSpawnRulesField(this.GameHelper, I18n.Item_FishSpawnRules(), item.ItemId); // fish pond data // derived from FishPond::doAction diff --git a/LookupAnything/docs/release-notes.md b/LookupAnything/docs/release-notes.md index 03d08803f..26bf64b4a 100644 --- a/LookupAnything/docs/release-notes.md +++ b/LookupAnything/docs/release-notes.md @@ -8,6 +8,7 @@ * Added monoculture achievement to item 'needed for' field (thanks to Mushymato!). * Building recipes in item lookups now show the build gold price. * Building lookups now show their build cost/materials. +* Fixed fishing spawn rules not shown for non-fish catches like River Jelly. * Fixed support for custom machine rules using `ITEM_ID` and `ITEM_CONTEXT_TAG` game state queries. * Fixed support for custom polyculture crops in 'needed for' field (thanks to Mushymato!). * Fixed error getting recipes if a mod adds invalid machine data.