[Guide] API Changes to SMAPI (from .36 to .37)

Discussion in 'Mods' started by hairlessOrphan, Mar 5, 2016.

  1. hairlessOrphan

    hairlessOrphan Void-Bound Voyager

    Heads up, looks like SMAPI .37 reorganized all the events and delegate signatures.

    For users, it means .36 mods won't work with .37, and vice versa.

    For modders
    , almost everything can be fixed by:

    1) updating your Entry signature
    From:
    public override void Entry()
    To:
    public override void Entry(params object[] objects)

    2) adding the new events namespace
    using StardewModdingAPI.Events;

    3) finding the new location of the events you want to use:
    From:
    Events.SomeEvent += your_handler
    To:
    WhateverEventCategoryYouNeed.SomeEvent += your_handler
    ex: TimeEvents.TimeOfDayChanged += your_handler
    ex: GameEvents.UpdateTick += your_handler

    4) updating your event handler signatures
    From:
    void your_handler(and maybe there used to be some params here?)
    To:
    void your_handler(object sender, EventArgs e)

    Fun Note: EventArgs is the base event args class. For some events, it looks like .37 wants to pass proper event args (ex: TimeOfDayChanged passes in EventArgsIntChanged), but it doesn't actually populate the EventArgs (i.e. NewInt and PriorInt both seem to always be 0). So maybe you can't use those, yet.

    These are the breaking changes I found. Any others?
     
    • DatYandereGirl

      DatYandereGirl Big Damn Hero

      Bumped for visibility and thanking for the info on this.
       
      • cantorsdust

        cantorsdust Existential Complex

        Very helpful for when I updated my mods, thank you!
         
          DatYandereGirl likes this.
        • sanademonangel

          sanademonangel Poptop Tamer

          where can i find .37 version of smapi?
           
          • cantorsdust

            cantorsdust Existential Complex

          Share This Page