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

    MouseyPounds Cosmic Narwhal

    Two things immediately come to mind:
    1. Whatever changes you made to Maps/DesertTiles should also be made to just DesertTiles as well. The game has duplicate copies of the tilesheets in both the main Content and Content\Maps directories and it's unclear when it uses each.
    2. Try turning on Content Patcher's debug mode and then browsing the textures in-game.
     
    • Sabs like "labs"

      Sabs like "labs" Void-Bound Voyager

      Ah, okay. With this information I was able to get it working. Strange that it's set up this way.
       
      • Sabs like "labs"

        Sabs like "labs" Void-Bound Voyager

        @Pathoschild I have a suggestion. Why not make it possible to nest multiple changes to an XNB file inside a single branch of JSON?
         
        • Pathoschild

          Pathoschild Cosmos Killer

        • Sabs like "labs"

          Sabs like "labs" Void-Bound Voyager

          @Pathoschild Certainly!

          Here's example code from a content pack I've just completed:
          Code:
          // townInterior.xnb
              {
                "Action": "EditImage",
                "Target": "townInterior.xnb",
                "FromFile": "assets/townInterior01.png",
                "ToArea": { "X": 144, "Y": 433, "Width": 14, "Height": 15 },
                "When": {
                  "Language": "de, en, ja, ru, zh"
                }
              },
              {
                "Action": "EditImage",
                "Target": "townInterior.xnb",
                "FromFile": "assets/townInterior01es.png",
                "ToArea": { "X": 144, "Y": 433, "Width": 14, "Height": 15 },
                "When": {
                  "Language": "es, pt"
                }
              },
              {
                "Action": "EditImage",
                "Target": "townInterior.xnb",
                "FromFile": "assets/townInterior02.png",
                "ToArea": { "X": 182, "Y": 624, "Width": 20, "Height": 32 },
              },
          And here's what it would look like nested, as proposed:
          Code:
              {
                // townInterior.xnb
                "Target": "townInterior.xnb",
                "Actions: [
                  {
                    "Action": "EditImage",
                    "FromFile": "assets/townInterior01.png",
                    "ToArea": { "X": 144, "Y": 433, "Width": 14, "Height": 15 },
                    "When": { "Language": "de, en, ja, ru, zh" }
                  },
                  {
                    "Action": "EditImage",
                    "FromFile": "assets/townInterior01es.png",
                    "ToArea": { "X": 144, "Y": 433, "Width": 14, "Height": 15 },
                    "When": { "Language": "es, pt" }
                  },
                  {
                    "Action": "EditImage",
                    "FromFile": "assets/townInterior02.png",
                    "ToArea": { "X": 182, "Y": 624, "Width": 20, "Height": 32 },
                  }
                ]
              },
           
            GeneralTeddyMayhem likes this.
          • Allayna

            Allayna Pangalactic Porcupine

            That would be nice! Would really slim down the content files
             
            • Allayna

              Allayna Pangalactic Porcupine

              What could also be useful in the content files -
              instead of
              Code:
              {
                 "Action": "Load",
                 "Target": "Maps/Beach",
                 "FromFile": "assets/Beach.tbin",
                 "When": {
                   "No Warp": "false"
                   }
                 },
                 {
                 "Action": "Load",
                 "Target": "Maps/Beach",
                 "FromFile": "assets/Beach-alt.tbin",
                 "When": {
                   "No Warp": "true"
                   }
                 },
                 {
                 "Action": "Load",
                 "Target": "Maps/Beach-NightMarket.xnb",
                 "FromFile": "assets/Beach-NightMarket.tbin",
                 "When": {
                   "No Warp": "false"
                   }
                 },
                 {
                 "Action": "Load",
                 "Target": "Maps/Beach-NightMarket.xnb",
                 "FromFile": "assets/Beach-NightMarket-alt.tbin",
                 "When": {
                   "No Warp": "true"
                   }
                 },
              
              it could be
              Code:
              "When" {
                 "No Warp" : "false" {
                   {
                   "Action": "Load",
                   "Target": "Maps/Beach",
                   "FromFile": "assets/Beach.tbin",
                   },
                   {
                   "Action": "Load",
                   "Target": "Maps/Beach-NightMarket.xnb",
                   "FromFile": "assets/Beach-NightMarket.tbin",
                   },
                 },
                 "No Warp" : "true" {
                   {  
                   "Action": "Load",
                   "Target": "Maps/Beach",
                   "FromFile": "assets/Beach-alt.tbin",
                   },
                   {
                   "Action": "Load",
                   "Target": "Maps/Beach-NightMarket.xnb",
                   "FromFile": "assets/Beach-NightMarket-alt.tbin",
                   },
                 },
              },
               
                Sabs like "labs" likes this.
              • Saint-in-Chief

                Saint-in-Chief Void-Bound Voyager

                Could a condition for weddings days, and possibly one that checks if the Community Center/JoJa Mart renovations form has been completed be added?
                 
                • tenthousandcats

                  tenthousandcats Subatomic Cosmonaut

                  Hi! Would adding a condition for friendship levels be doable?
                   
                  • Pathoschild

                    Pathoschild Cosmos Killer

                    Thanks for the suggestions!

                    @Sabs like "labs" @Allayna I want to keep the format simple and easy to learn, which means keeping the possible variations down. One option I've considered is letting you do that for any field (see example below). My main concern is that this complicates the format, which means harder to learn + harder to read + easier to make mistakes.
                    Code:
                    {
                        "Format": "1.3",
                        "Changes": [
                            {
                                "Repeat": {
                                    "Action": "Load",
                                    "When": {
                                        "No Warp": false
                                    }
                                },
                                "ForChanges": [
                                    {
                                        "Target": "Maps/Beach",
                                        "FromFile": "assets/Beach.tbin"
                                    },
                                    {
                                        "Target": "Maps/Beach-NightMarket",
                                        "FromFile": "assets/Beach-NightMarket.tbin"
                                    }
                                ]
                            }
                        ]
                    }
                    
                    @Saint-in-Chief A condition for wedding days is already planned. Adding support for flags (e.g. community center completed) is a bit more complicated, since I'll need to rewrite Content Patcher to support conditions with more than one value; that rewrite is planned too though.

                    @tenthousandcats Potentially. I'll need to look into how to do that one; I'll see if I can support that kind of condition with the upcoming rewrite too. :)
                     
                      tenthousandcats likes this.
                    • Allayna

                      Allayna Pangalactic Porcupine

                      I can understand that. This method of creating mods IS very easy to read and understand! I just can't help the bit of coder in me that sees repeated code and goes 'ewwwwww' :rofl:
                       
                      • Sabs like "labs"

                        Sabs like "labs" Void-Bound Voyager

                        It would be okay if both options existed. Repeated makes for the ease-of-entry @Pathoschild is looking for, and recursive makes for the simplicity of code that appeals to some of us.
                         
                        • staarfruit

                          staarfruit Big Damn Hero

                          Hello, I'm trying to convert a mod that adds hats instead of replacing them, but when I try to go in game to see if it works I keep getting this error and I'm not sure what I did wrong? Because it's saying I'm trying to make the image wider than the original but I'm not trying to make it wider I'm only taller than the original image size.

                          I even unpacked the original hats.xnb to make sure and the width for that is 240px. Also, in the error message the Y: and 3 are together but if I post it like that it turns into an emoji.

                          [ContentPatcher] Can't apply image patch "Unoffical Long Elf Ears Recolors > EditImage Characters/Farmer/Hats": target area (X:240, Y: 399, Width:240, Height:160) extends past the right edge of the image (Width:240), which isn't allowed. Patches can only extend the tilesheet downwards.

                          I'm not sure if it'll help or not, but here's what I have in the content.json as of right now.

                          {
                          "Format": "1.3",
                          "Changes": [
                          //Ears Image
                          {
                          "Action": "EditImage",
                          "Target": "Characters/Farmer/Hats",
                          "FromFile": "assets/ears.png",
                          "FromArea": { "X": 0, "Y": 240, "Width": 240,"Height": 160 },
                          "ToArea": {"X": 240, "Y": 399, "Width": 240, "Height": 160 }
                          },
                          }
                          ]
                          }
                           
                          • MouseyPounds

                            MouseyPounds Cosmic Narwhal

                            @staarfruit : The ToArea declaration gives a starting point (X,Y) and the width & height so the one you posted would extend from (240,399) to (479, 558).
                             
                              staarfruit likes this.
                            • staarfruit

                              staarfruit Big Damn Hero

                              Oh! I didn't realize that was the starting point! Whoops! Alrighty then, time to try again. Thank you!
                               
                              • Seyph

                                Seyph Title Not Found

                                Hi, I'm using Content Patcher to replace the names and descriptions of the default hats, and it works fine when i go to check the Hat Mouse store or when/after I spawn the hats in using CJB Item Spawner.

                                When I load up a save with the hats already existing in the world, however, the item tooltip with custom name and description doesn't load in. This only seems to be an issue when I rename the hat, and only on hats that previously existed in the world. When I keep the default name, the custom description works fine. Issue exists whether I use "EditData" with "Fields" or "Entries".

                                Is there a way to fix this, or it something that just has to be dealt with?

                                EDIT: Custom names with descriptions still don't show even if I load a XNB file to replace it.


                                These hats previously existed inside a chest upon loading.

                                [​IMG]
                                [​IMG]
                                [​IMG]
                                [​IMG]
                                [​IMG]

                                Default description: "Celebrate the magical season."

                                [​IMG]
                                 
                                  Last edited: Jun 11, 2018
                                • Pathoschild

                                  Pathoschild Cosmos Killer

                                  @Seyph That seems to be a quirk of the game's hat logic. When loading the text for an existing hat, it searches through Data\Hats.xnb by name instead of ID. Since you changed the name, existing hats with the old name no longer match.
                                   
                                  • andiluxe

                                    andiluxe Big Damn Hero

                                    Is there a way to config a mod so that if no option is selected it just won't load/edit anything? So you'd have the option of using one of the assets or vanilla? I have a mod I'm piecing together for personal use (several coop animal reskins), and I did something rather asinine last night without really thinking about it. I uploaded all the vanilla chicken pngs to my assets folder and then made "vanilla" a config setting that points to those. That just seems redundant to me when the vanilla already exists. Why patch it with itself?

                                    I mean, this whole question sounds asinine now that I'm typing it out. If I want vanilla, why am I making a content pack?! But I am a fickle woman, and I just want to have the choice of switching up my chickens from any of these skins or going back to vanilla without having to delete the mod or do what I've done above.

                                    Is this where
                                    "Enabled" comes into play? Or would "AllowBlank": "true" allow me to still use vanilla if no option is set?

                                    Tangentially related:
                                    There is no BabyDuck.png. Baby ducks use BabyWhite Chicken.png. I am 99% sure that I can't have my baby ducks look like X.png and my baby white chickens look like Y.png. But in case I'm wrong, is there a way to patch BabyWhite Chicken.xnb only when that's being used for a baby duck? I think this might be outside the realm of possibility with Content Patcher alone, but it doesn't hurt to ask.


                                     
                                    • Pathoschild

                                      Pathoschild Cosmos Killer

                                      @andiluxe You can use conditions to only apply a patch when an option is selected. The example below only applies the patch if the 'variant' config field is set to either 'OptionA' or 'OptionB'. You can also remove AllowBlank and add vanilla as an option; the condition will work the same way.
                                      Code:
                                      {
                                         "Format": "1.3",
                                         "ConfigSchema": {
                                            "Variant": {
                                               "AllowBlank": true,
                                               "AllowValues": "OptionA, OptionB"
                                            }
                                         },
                                         "Changes": [
                                            {
                                               "Action": "Load",
                                               "Target": "Animals/Dinosaur",
                                               "FromFile": "assets/{{variant}}/dinosaur.png",
                                               "When": {
                                                  "Variant": "OptionA, OptionB"
                                               }
                                            }
                                         ]
                                      }
                                      
                                      And nope, you can't patch just baby ducks with Content Patcher since they use the same texture as baby chickens. You'd need to create a SMAPI mod to do that.
                                       
                                      • andiluxe

                                        andiluxe Big Damn Hero

                                        Ohhhh that's so simple and obvious now that you've typed it out. :facepalm: Thank you!
                                         
                                        Thread Status:
                                        Not open for further replies.

                                        Share This Page