SMAPI - Stardew Modding API

SMAPI - Stardew Modding API

971k Downloads

World.ObjectListChanged event should track furniture but doesn't

DiscipleOfEris opened this issue ยท 2 comments

commented

Describe the bug
The Events documentation states the World.ObjectListChanged event is: "Raised after objects are added/removed in any location (including machines, furniture, fences, etc)." (emphasis mine). However, furniture changes are not actually tracked by this event or any other event.

To Reproduce

  1. Install a mod with nothing but:
public override void Entry(IModHelper helper)
{
    this.Helper.Events.World.ObjectListChanged += delegate (object sender, ObjectListChangedEventArgs e)
    {
        Monitor.Log("ObjectListChanged", LogLevel.Debug);
    };
}
  1. Load a new or any save.
  2. Pick up or set down any furniture.
  3. Nothing appears in log.

Log file
https://smapi.io/log/dcaaad354e4f42d48d7d69dcf9b64ecf

commented

So this is probably a pretty quick fix. ObjectListChanged is tracking changes to GameLocation::netObjects but furniture are stored in GameLocation::furniture which is a NetCollection.

I think the proper fix would be to add a new event: World.FurnitureListChanged that tracks changes to the GameLocation::furniture field. So in https://github.com/Pathoschild/SMAPI/blob/develop/src/SMAPI/Framework/StateTracking/LocationTracker.cs we would just add a ICollectionWatcher<Furniture> created with WatcherFactory.ForNetCollection(location.furniture).

Then raise the new event in

var location = locState.Location;
.

commented

Thanks! Added via #779 for the upcoming SMAPI 3.11.