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. Pathoschild

    Pathoschild Tiy's Beard

    Content Patcher loads content packs that change the game's images and data without replacing XNB files. Unlike XNB mods, these content packs get automatic update checks and compatibility checks, are easy to install and uninstall, and are less likely to break due to game updates.

    See Nexus page for details.
     
      Last edited: Feb 25, 2018
    • MouseyPounds

      MouseyPounds Cosmic Narwhal

      This looks interesting. How are conflicts handled; i.e. if two different content packs want to mod the same file?

      I also have a second question, which might be more of a content pack meta-question. Sometimes on xnb mods I will choose only to install part of it (e.g. replace the character portrait for dialogue but not the actual character sprite). How easy is it to enable only part of a content pack?
       
      • Pathoschild

        Pathoschild Tiy's Beard

        Hi @MouseyPounds.

        Content packs are much less likely to conflict than XNB mods because they can edit only the part they need. A conflict only happens if two content packs try to replace the entire file (like pet replacement mods), or edit the same part of a file. In those cases you can either choose one, or edit the content packs to work together. Editing content packs is also really easy by design.

        For example, Yoseiri's Some Scarecrow Replacement currently replaces four scarecrows. The XNB mod approach would be to replace the entire file:
        upload_2018-2-25_19-30-52.png

        As a content pack, Yoseiri only needs to provide the four sprites:
        upload_2018-2-25_19-31-35.png

        The content pack's content.json tells Content Patcher how to apply those to the game. If you want to disable parts of a content pack, you can just edit that JSON file to do it.
         
          anothersarah and MouseyPounds like this.
        • MysticTempest

          MysticTempest Spaceman Spiff

          Nice work, Pathoschild! I like how you kept everything nice & compact; with supporting tilesheets & localization all neatly together.
          I still need to see about converting my larger mod and test how that goes, but my small Tea crop mod converted nicely.


          Heads up for other modders though, when editing/adding recipes to the 'CookingRecipes' files.
          The recipe names at the beginning of each line requires quotation marks around them; or for you to remove the spaces in their names.
          Contrary to how it's done in XNB editing. Content Patcher will throw out errors when it sees spaces before the colon that aren't enclosed.

          Broken Entries Example:
          Code:
          White Tea: "797 1/1 5/798/f Jodi 2/White Tea",
          Dandelion White Tea: "797 1 22 1/1 5/799/f Harvey 3/Dandelion White Tea",
          
          Working Entries Example:
          Code:
          "White Tea": "797 1/1 5/798/f Jodi 2/White Tea",
          "Dandelion White Tea": "797 1 22 1/1 5/799/f Harvey 3/Dandelion White Tea",
          

          Of the few files my mod touches; everything else seemed to be a straightforward conversion of XNB data.
          But yea, heads up as it'll likely affect other data sections that use a similar naming format.
           
            Pathoschild likes this.
          • MouseyPounds

            MouseyPounds Cosmic Narwhal

            Now that I've learned more about content packs, I'd like to transition the handful of XNB mods that I use to this format (although I hope the mod authors themselves will eventually offer official content pack versions.) Looking at the documentation, I notice that the "Load" example references a PNG replacement file. Should all XNBs be extracted to original formats like PNG & TBIN for use with the full file replace directive, or could I reference an XNB with the Load action?
             
            • Pathoschild

              Pathoschild Tiy's Beard

              @MouseyPounds You can use .png, .tbin, and .xnb files. I clarified the accepted file types in the docs.
               
              • MouseyPounds

                MouseyPounds Cosmic Narwhal

                Alrighty, can anyone see what I am doing wrong here?

                I created a content pack with the following file structure in the Mods directory:
                Code:
                C:\PROGRAM FILES\STEAM\STEAMAPPS\COMMON\STARDEW VALLEY\MODS\CP_MARU
                │  content.json
                │  manifest.json
                │
                ├───Characters
                │      Maru.xnb
                │      Maru_Hospital.xnb
                │
                └───Portraits
                       Maru.xnb
                       Maru_Hospital.xnb
                
                And put the following in content.json:
                Code:
                {
                  "Format": "1.0",
                  "Changes": [
                       {
                          "Action": "Load",
                          "Target": "Characters/Maru",
                          "FromFile": "Characters/Maru.xnb"
                       },
                       {
                          "Action": "Load",
                          "Target": "Characters/Maru_Hospital",
                          "FromFile": "Characters/Maru_Hospital.xnb"
                       },
                       {
                          "Action": "Load",
                          "Target": "Portraits/Maru",
                          "FromFile": "Portraits/Maru.xnb"
                       },
                       {
                          "Action": "Load",
                          "Target": "Portraits/Maru_Hospital",
                          "FromFile": "Portraits/Maru_Hospital.xnb"
                       }
                    ]
                }
                And when starting the game I get the following errors (full log link)
                Code:
                [12:13:05 INFO  SMAPI] Loaded 1 content packs:
                [12:13:05 INFO  SMAPI]  CP_Maru 1.2 by Unknown | for ContentPatcher | ContentPatcher wrapper for Nexus Mod.
                [12:13:05 WARN  ContentPatcher] Ignored CP_Maru > entry #1: the FromFile field specifies a file that doesn't exist: Characters\Maru.
                [12:13:05 WARN  ContentPatcher] Ignored CP_Maru > entry #2: the FromFile field specifies a file that doesn't exist: Characters\Maru_Hospital.
                [12:13:05 WARN  ContentPatcher] Ignored CP_Maru > entry #3: the FromFile field specifies a file that doesn't exist: Portraits\Maru.
                [12:13:05 WARN  ContentPatcher] Ignored CP_Maru > entry #4: the FromFile field specifies a file that doesn't exist: Portraits\Maru_Hospital.
                
                 
                • MysticTempest

                  MysticTempest Spaceman Spiff

                  Hey MouseyPounds, I just tested on my end(though using copies of the game's files).

                  It seems to read the modder's files like it does the game files. Without the extension.
                  So, delete the extension; ".xnb" from both the content.json (in the "FromFile" fields), & your own included files.
                   
                    MouseyPounds likes this.
                  • Pathoschild

                    Pathoschild Tiy's Beard

                    I'll fix that in the next Content Patcher release, so it'll allow .xnb extensions without that workaround. :)
                     
                      MouseyPounds and MysticTempest like this.
                    • Pathoschild

                      Pathoschild Tiy's Beard

                      Content Patcher 1.1 is now available!

                      Release notes:
                      • Added Enabled field to disable individual patches (thanks to f4iTh!).
                      • Added support for XNB files in FromFile.
                      • Added support for maps in FromFile which reference unpacked PNG tilesheets.
                       
                        Last edited: Mar 2, 2018
                      • MouseyPounds

                        MouseyPounds Cosmic Narwhal

                        This mod is just too good. It's so easy now to add little data file adjustments like dialogue fixes or minor object changes without worrying about introducing compatibility issues. Every time I play I find something new that I want to tweak and Content Patcher lets me do it. :)
                         
                          Pathoschild likes this.
                        • FieryChaos

                          FieryChaos Cosmic Narwhal

                          This is great, but oh my, it's going to take me forever to remember every little thing and every single mod I've edited together in every tilesheet and convert it. Also, I'm not really a fan of just putting Content Packs straight into the Mods folder (having to figure out what is a SMAPI mod and what is a Content Pack with a large list like mine), but I suppose I could just rename every Content Pack folder with "!CP(PackNameHere)" or something. Guess I'll get around to remembering every mod and edit I've combined and converting them, slowly and eventually. Also, I was worried (when you were initially talking about it) about extending tilesheets to add things rather than replace them, but it seems you took that into consideration regardless (and if tilesheets are edited to add more to them in the next game update, it should be real easy to update them with this mod).
                           
                          • ShneekeyTheLost

                            ShneekeyTheLost Master Astronaut

                            You can set up a single content patcher folder which has a subfolder of all of your edits.

                            So Mods/Assets has your manifest.json and content.json that references all of your assets, then you can put various edits in their various folders, so for example you could have Mods/Assets/PastelValley which is where your tilesheet for pastel colors for your farm, Mods/Assets/Greenhouse where you change the look of your greenhouse, and so forth.
                             
                            • FieryChaos

                              FieryChaos Cosmic Narwhal

                              Specifically referring to converting each mod into it's own content.json. Yes, I can do that, but most users who will use this won't and will have multiple content packs under the Mods folder. That, and I'd rather have each (major) edit within separate content.json files, so it's far easier to quickly remove something (the whole folder) rather than finding specific edits in a single, rather large, content.json file.
                               
                              • Pathoschild

                                Pathoschild Tiy's Beard

                                @FieryChaos I like to keep my mods folder organised too, so I prefix content packs with the mod that reads it. For example:
                                upload_2018-3-6_12-46-5.png
                                 
                                • Suppeedi

                                  Suppeedi Scruffy Nerf-Herder

                                  So I've been rebuilding an old xnb mod of mine into one that works with SMAPI and Content Patcher.. (I never released it publicly, it was for a friend. >3>;;..)

                                  And.. it seems.. that my edits to farmer_base and farmer_girl_base don't go through.

                                  Also, Shirts does seem to give an 'out of range' error, (which is correct, the targeted range IS outside of the space) and while it does add the space for new shirts, it doesn't actually add my shirts.

                                  My edits to accessories, hats, hairstyles and skinColors all work fine.. Which, for hairstyles and skinColors, also add new items out of range.

                                  So I'm not entirely sure what I'm doing wrong? I do have a bunch of "Action": "EditImage" lines that repeat from and to the same file, (both farmer bases) but with different To and From areas, obviously.
                                   
                                  • Pathoschild

                                    Pathoschild Tiy's Beard

                                    Hi @Suppeedi. Oops, not being able to edit the farmer base files is a limitation that's fixed in the upcoming SMAPI 2.6 and Stardew Valley 1.3. Sorry about that!

                                    For the out of range error, can you send me a zip of your content pack? I'll take a look and release a fix if needed.
                                     
                                    • Suppeedi

                                      Suppeedi Scruffy Nerf-Herder

                                      Aw, dang. I had hoped to get this working BEFORE the multiplayer patch. Back to xnb it is, temporarily, then. ^^;

                                      Err.. No need. I actually already figured it out. Turns out my png file was wider than it should be.

                                      I kept some whitespace open for additional shirts later on, and it was 256px wide instead of 224px. My content file had 224px assigned, as it should be. (No FromArea, since I wanted the entire image.)


                                      That's some mighty fast reply, by the way! Good service, hehe.. If I had re-checked the forum faster after my post, I wouldn't have taken another hour to discover this oversight, probably.. ^^;

                                      (I admit it, I'm the kind of the guy who drops a problem in someone's lap and then checks back hours later if there's a reply.. Sorry!)
                                       
                                      • Pathoschild

                                        Pathoschild Tiy's Beard

                                        Thanks! I'll see if I can provide a clearer error in those cases. :)
                                         
                                        • Pathoschild

                                          Pathoschild Tiy's Beard

                                          Content Patcher 1.2 is now available!

                                          Release notes:
                                          • Added support for overlaying images.
                                          • Added optional debug mode for modders.
                                          • FromFile, Target, and map tilesheets are now case-insensitive.
                                          • Fixed null fields not being ignored after warning.
                                           
                                          Thread Status:
                                          Not open for further replies.

                                          Share This Page