fix crash when player has duplicate item references

This commit is contained in:
Jesse Plamondon-Willard 2018-04-11 15:41:32 -04:00
parent 83969b5789
commit fa335f80be
2 changed files with 3 additions and 2 deletions

View File

@ -4,7 +4,6 @@
* For players:
* Added support for Stardew Valley 1.3+; no longer compatible with earlier versions.
* Added `Context.IsMultiplayer` and `Context.IsMainPlayer` flags.
* Fixed SMAPI update alerts linking to the GitHub repository instead of [smapi.io](https://smapi.io).
* Fixed SMAPI update checks not showing newer beta versions when using a beta version.
* For modders:
@ -21,6 +20,8 @@
## 2.5.5
* For players:
* Fixed mods not being loaded if an optional dependency is installed but skipped.
* Fixed rare crash when the game duplicates an item.
* Fixed SMAPI update alerts linking to the GitHub repository instead of [smapi.io](https://smapi.io).
* For the [log parser][]:
* Tweaked UI.

View File

@ -569,7 +569,7 @@ namespace StardewModdingAPI.Framework
this.PreviousForagingLevel = Game1.player.foragingLevel;
this.PreviousMiningLevel = Game1.player.miningLevel;
this.PreviousLuckLevel = Game1.player.luckLevel;
this.PreviousItems = Game1.player.items.Where(n => n != null).ToDictionary(n => n, n => n.Stack);
this.PreviousItems = Game1.player.items.Where(n => n != null).Distinct().ToDictionary(n => n, n => n.Stack);
this.PreviousLocationObjects = this.GetHash(Game1.currentLocation.objects);
this.PreviousTime = Game1.timeOfDay;
this.PreviousMineLevel = Game1.mine?.mineLevel ?? 0;