RELEASED Content Patcher *

Loads content packs that change the game's images and data without replacing XNB files.

Thread Status:
Not open for further replies.
  1. Suppeedi

    Suppeedi Scruffy Nerf-Herder

    Ohh, "Patchmode": "Overlay" seems reaaaally useful :eek:

    I can replace my 22 EditImages with only 2 that way.. Well, if editing the farmer base was supported. :rofl:
     
    • MouseyPounds

      MouseyPounds Cosmic Narwhal

      Today I learned that Content Patcher can even modify things that are "hardcoded" into a mod. Recently the Happy Birthday mod was updated to use the SMAPI Content API so that it no longer needed a handful of XNB files (and had better compatibility with changes to mail.) As I had previously had success changing the XNBs to customize the gifts, I had resisted updating because I feared I would be stuck with the defaults. But when I looked into how the changes were implemented into the mod, I saw the following in the file where the gifts were compiled:
      Code:
      public bool CanLoad<T>(IAssetInfo asset)
              {
                  return asset.AssetNameEquals(@"Data\PossibleBirthdayGifts");
      }
      And when I created a new little Content Patcher mod that performed an EditData with a target of "Data/PossibleBirthdayGifts," my changes worked! This really is an amazing tool.
       
        anothersarah and Pathoschild like this.
      • farmerjack

        farmerjack Void-Bound Voyager

        How can I go about editing the text of the dialogue in an event? I saw @MysticTempest 's comment about Content Patcher being sad about spaces that aren't enclosed in quotes, but yikes, the event XNBs are fraught with spaces and quotes of their own.

        For instance:


        Code:
        3910975/f Shane 1500/e 3910674/t 900 2000/w rainy: "echos/-2000 -2000/farmer 83 92 2 shane -3000 -3000 2 Harvey -3000 -3000 2/skippable/specificTemporarySprite shaneCliffs/viewport 83 99 clamp true/pause 1000/move farmer 0 5 2/pause 500/speak Shane \"...$7#$b#@...$7\"/pause 1000/showFrame farmer 4/pause 1000/speak Shane
        
        ...etc
        That's from line 32 in Forest.xnb in Data/Events.
         
        • Pathoschild

          Pathoschild Cosmos Killer

          Hi @farmerjack. That line you quoted has two parts:
          • key: 3910975/f Shane 1500/e 3910674/t 900 2000/w rainy
          • value: "[...]/speak Shane \"...$7#$b#@...$7\"/pause 1000/[...]"
          Content Patcher uses JSON, which needs quotes around the key too. Otherwise the format is identical. So here's how you'd replace that line in Content Patcher:
          Code:
          {
              "Action": "EditData",
              "Target": "Data/Events/Forest",
              "Entries": {
                  "3910975/f Shane 1500/e 3910674/t 900 2000/w rainy": "[...]/speak Shane \"...$7#$b#@...$7\"/pause 1000/[...]"
              }
          }
          
           
          • thingwithwings

            thingwithwings Subatomic Cosmonaut

            In the "To Area" part of content.json, are the x, y, and width values by pixel or...? Sorry haha
            Also, if I were to edit the spring_outdoors xnbs, would I have to write it separately for each different iteration of the file? (like, the file is in maps and the same one is again in the main content folder)
             
            • Pathoschild

              Pathoschild Cosmos Killer

              Yep, FromArea and ToArea are in pixels; I updated the guide to specify. And yes, you currently need to specify your changes for both files in that case; I'll look into improving that in a future version. :)
               
                thingwithwings likes this.
              • Pathoschild

                Pathoschild Cosmos Killer

                Content Patcher 1.3 is now available!

                This is a big release. Here are the highlights:
                • added patch conditions (changes can now depend on the season, day, weather, or language);
                • added player settings (content packs can now have a config.json);
                • added condition/config tokens;
                • added a patch summary console command (shows a summary of patches, whether they're applied, and if not the reason why);
                • added a patch update console command (immediately refreshes the conditions, mainly useful if you change the season/date through the console);
                • patches now have an optional unique name (shown in errors, logs, and patch summary);
                • and more changes (see release notes).
                See the modder documentation for help using the new features. Note that you must change "Format": "1.0" to "Format": "1.3" in your content.json to use the new features.
                 
                  anothersarah and HopeWasHere like this.
                • Suppeedi

                  Suppeedi Scruffy Nerf-Herder

                  ..Does this new update of SMAPI and Content Patcher include editing the farmer textures? :eek:
                   
                  • Pathoschild

                    Pathoschild Cosmos Killer

                    @Suppeedi I haven't tested those specifically, but some of the farmer textures should work. Some might need Stardew Valley 1.3, which gives SMAPI more access to the content logic.
                     
                    • Suppeedi

                      Suppeedi Scruffy Nerf-Herder

                      ..Doesn't look like it does. I'll have to wait for the game release, huh.
                       
                      • jhunichi

                        jhunichi Void-Bound Voyager

                        I wasn't sure which thread to post this in but I hope this is the right one, I'm sorry if it's not! I've been having trouble with the replacing babies with birds mod that was updated to a CPP (which was posted here, the original is here) and I can't figure out how to fix it. The babies-to-birds part works perfectly, but it's not fully replacing the baby crib with a birdcage like it should. The birdcage is supposed to completely replace the crib, but on my end it's more like it's just laid on top of it for the most part so the crib shows through between the cage bars, and there's a section at the top (I think 10 pixels tall) where it's just the crib and not the bird cage at all. Here's a screenshot of it.

                        As far as I can tell all the X,Y coordinates for the replacement are correct, it's just not.. fully replacing the crib like it should :< I'm wondering if it's because the replacement image is in two parts, but the crib itself (minus the rail) is just in one part? I really just don't know at this point, because everything in the content.json file looks correct as far as I can tell @-@

                        Edit: oh my goodness url tag problems EVERYWHERE
                         
                        • Pathoschild

                          Pathoschild Cosmos Killer

                        • jhunichi

                          jhunichi Void-Bound Voyager

                          Thank you, I'll go do that now!
                           
                          • blue_starkiller

                            blue_starkiller Void-Bound Voyager

                            I already posted it on nexusmods but I thought I'd include it here as well. The Weather conditional is not working for me.
                            Whenever I try to include:
                            "When" : {
                            "Weather" : "sun"
                            }
                            or any other weather conditionals on my content.json file the console drops an error message and the patch isn't loaded. This only happens when I use a weather conditional, all other conditionals seem to work fine.

                            This is the error I'm getting:
                            [ContentPatcher] Error loading content pack 'HarveyPortraitReplacement'. Technical details:
                            Newtonsoft.Json.JsonReaderException: Can't parse JSON file at C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Mods\HarveyPortraitReplacement\content.json. This doesn't seem to be valid JSON.
                            Technical details: After parsing a value an unexpected character was encountered: ". Path 'Changes[1].When.Season', line 30, position 4.
                            at StardewModdingAPI.Framework.Serialisation.JsonHelper.ReadJsonFile[TModel](String fullPath) in C:\source\_Stardew\SMAPI\src\SMAPI\Framework\Serialisation\JsonHelper.cs:line 82
                            at StardewModdingAPI.Framework.ContentPack.ReadJsonFile[TModel](String path) in C:\source\_Stardew\SMAPI\src\SMAPI\Framework\ContentPack.cs:line 57
                            at ContentPatcher.ModEntry.LoadContentPacks() in C:\source\_Stardew\Mods.Pathoschild\ContentPatcher\ModEntry.cs:line 169

                            This is the conditional I'm using, it works fine without the weather part, but as soon as I use "Weather" the entire thing fails.

                            "Action": "Load",
                            "Target": "Portraits/Harvey",
                            "FromFile": "assets/Harvey_winter.png",
                            "When": {
                            "Season": "winter"
                            "Weather": "sun"
                            },

                            EDIT: I've actually found that it works only if Weather is the only conditional. If you add any custom conditional or even season, day or dayofweek the whole thing fails.
                             
                              Last edited: Mar 29, 2018
                            • Pathoschild

                              Pathoschild Cosmos Killer

                              Hi @blue_starkiller. Make sure you have a comma after each field (except the last one). This should work:
                              Code:
                              "Action": "Load",
                              "Target": "Portraits/Harvey",
                              "FromFile": "assets/Harvey_winter.png",
                              "When": {
                                 "Season": "winter",
                                 "Weather": "sun"
                              }
                              
                               
                              • tenthousandcats

                                tenthousandcats Subatomic Cosmonaut

                                Hi! I was wondering if I can use CP to add entirely new maps to the game. The maps work fine when I manually add the xnb files to the game folder, but I was hoping to find a way to add them in using CP so that it isn't so clunky.
                                Since doing this doesn't work:
                                Code:
                                        {
                                            "Action": "Load",
                                            "Target": "Maps/JasParty",
                                            "FromFile": "assets/Maps/JasParty.xnb"
                                        },
                                        {
                                            "Action": "Load",
                                            "Target": "JasPartyTiles",
                                            "FromFile": "assets/JasPartyTiles.xnb"
                                        },
                                Am I right in assuming that the "Load" action only works if it has something to replace? Thank you!
                                 
                                • Pathoschild

                                  Pathoschild Cosmos Killer

                                  @tenthousandcats That's equivalent to adding the XNB files to the Content folder; the target doesn't need to already exist for Load. When the game asks for Content/Maps/JasParty.xnb, it'll transparently receive the file from Content Patcher instead. In either case, the map won't be loaded unless you add an in-game location that loads it; how are you doing that part?
                                   
                                  • tenthousandcats

                                    tenthousandcats Subatomic Cosmonaut

                                    Oh, it's a temporary map for an event!
                                     
                                    • Pathoschild

                                      Pathoschild Cosmos Killer

                                      @tenthousandcats Content Patcher should work fine for that then. If it's not working, I'll need more info:
                                      1. enable verbose logging in Content Patcher's config.json;
                                      2. load the game and trigger your event;
                                      3. run patch summary in the SMAPI console after the map should be loaded;
                                      4. share your SMAPI log here.
                                       
                                      • tenthousandcats

                                        tenthousandcats Subatomic Cosmonaut

                                      Thread Status:
                                      Not open for further replies.

                                      Share This Page