From 07049acc76fdb2cda654a25c80a675a4ad7f9277 Mon Sep 17 00:00:00 2001 From: ktiedt Date: Sat, 11 Jul 2026 17:40:50 -0500 Subject: [PATCH] Fix crop count inflation on non-farm locations --- .../HarmonyPatch_FarmComputerLocations.cs | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/Stardew Valley Expanded/StardewValleyExpanded/HarmonyPatch_FarmComputerLocations.cs b/Stardew Valley Expanded/StardewValleyExpanded/HarmonyPatch_FarmComputerLocations.cs index f74b721..8aaf2e9 100644 --- a/Stardew Valley Expanded/StardewValleyExpanded/HarmonyPatch_FarmComputerLocations.cs +++ b/Stardew Valley Expanded/StardewValleyExpanded/HarmonyPatch_FarmComputerLocations.cs @@ -80,9 +80,13 @@ public static void ApplyPatch(Harmony harmony, IMonitor monitor) public static List GreenhouseLocations = ["Custom_GrandpasShedGreenhouse"]; /// Adds any extra farm locations' crops to this method's total. + /// The calling location instance. /// The result of the original method. - private static void Farm_getTotalCrops(ref int __result) + private static void Farm_getTotalCrops(GameLocation __instance, ref int __result) { + if (__instance is not Farm) + return; + try { foreach (string name in FarmLocations) // for each extra farm location @@ -114,9 +118,13 @@ private static void Farm_getTotalCrops(ref int __result) } /// Adds any extra farm locations' crops to this method's total. + /// The calling location instance. /// The result of the original method. - private static void Farm_getTotalCropsReadyForHarvest(ref int __result) + private static void Farm_getTotalCropsReadyForHarvest(GameLocation __instance, ref int __result) { + if (__instance is not Farm) + return; + try { foreach (string name in FarmLocations) // for each extra farm location @@ -148,9 +156,13 @@ private static void Farm_getTotalCropsReadyForHarvest(ref int __result) } /// Adds any extra farm locations' crops to this method's total. + /// The calling location instance. /// The result of the original method. - private static void Farm_getTotalUnwateredCrops(ref int __result) + private static void Farm_getTotalUnwateredCrops(GameLocation __instance, ref int __result) { + if (__instance is not Farm) + return; + try { foreach (string name in FarmLocations) // for each extra farm location @@ -182,9 +194,13 @@ private static void Farm_getTotalUnwateredCrops(ref int __result) } /// Adds any extra farm locations' crops to this method's total. + /// The calling location instance. /// The result of the original method. - private static void Farm_getTotalOpenHoeDirt(ref int __result) + private static void Farm_getTotalOpenHoeDirt(GameLocation __instance, ref int __result) { + if (__instance is not Farm) + return; + try { foreach (string name in FarmLocations) // for each extra farm location @@ -216,9 +232,13 @@ private static void Farm_getTotalOpenHoeDirt(ref int __result) } /// Adds any extra greenhouse locations' crops to this method's total. + /// The calling location instance. /// The result of the original method. - private static void Farm_getTotalGreenhouseCropsReadyForHarvest(ref int? __result) + private static void Farm_getTotalGreenhouseCropsReadyForHarvest(GameLocation __instance, ref int? __result) { + if (__instance is not Farm) + return; + try { foreach (string name in GreenhouseLocations) // for each extra greenhouse location