spacechase0 / StardewValleyMods

New home for my stardew valley mod source code
Other
120 stars 142 forks source link

Custom NPC error Day started loop #58

Open nl1213 opened 3 years ago

nl1213 commented 3 years ago

Randomly the mod will throw an error that will cause the game to crash on a new day.

[22:35:39 ERROR Custom NPC Fixes] This mod failed in the GameLoop.DayStarted event. Technical details: NullReferenceException: Object reference not set to an instance of an object. at StardewValley.Utility.getAllCharacters(List1 list) in stardewvalley\Farmer\Farmer\Utility.cs:line 7637 at CustomNPCFixes.Mod.SpawnNpcs() in C:\source\_Stardew\Mods.spacechase0\CustomNPCFixes\Mod.cs:line 54 at CustomNPCFixes.Mod.<OnUpdate>b__2_0(Object s, DayStartedEventArgs a) in C:\source\_Stardew\Mods.spacechase0\CustomNPCFixes\Mod.cs:line 32 at StardewModdingAPI.Framework.Events.ManagedEvent1.Raise(TEventArgs args, Func`2 match) in SMAPI\Framework\Events\ManagedEvent.cs:line 126

Seems like sometimes either Utility.getAllCharacters(allCharacters); Or List allCharacters = Utility.getPooledList();

won't return the correct values. Or it could be a bug in smapi itself I don't really know for sure.

Modlist Mod list attached

jackharvest commented 2 years ago

I have the same issue randomly.

[Custom NPC Fixes] This mod failed in the GameLoop.DayStarted event. Technical details: NullReferenceException: Object reference not set to an instance of an object. at StardewValley.Utility.getAllCharacters(List1 list) in stardewvalley\Farmer\Farmer\Utility.cs:line 7670 at CustomNPCFixes.Mod.SpawnNpcs() in E:\source\_Stardew\Mods.spacechase0\CustomNPCFixes\Mod.cs:line 54 at CustomNPCFixes.Mod.<OnUpdate>b__2_0(Object s, DayStartedEventArgs a) in E:\source\_Stardew\Mods.spacechase0\CustomNPCFixes\Mod.cs:line 32 at StardewModdingAPI.Framework.Events.ManagedEvent1.Raise(TEventArgs args, Func`2 match) in SMAPI\Framework\Events\ManagedEvent.cs:line 126


Worthy of note: I store my games on my G: drive. I use powershell to robocopy all my mods over to my family's computers so that they don't have to download and update the mods themselves. My family doesn't put their games on a G: drive. This error is from someone that stores it on the C: drive.

But... maybe the "E:\source_stardew" portion at the beginning is just an unimportant reference that is pushd'd or pseudo mapped during the game, since that is definitely not a legit path on either machine prior to launch. 🤷

Also worthy of note: My wife's game (where this error happens sometimes) lags like beastly amount. Sometimes by over 1.5 in-game hours at the end of the day. We wait on a black screen while saving for a hot while for her clock to catch up and tick us into the next day. D: