Tractor Mod

Tractor Mod

130k Downloads

[Content Patcher] create mod

Pathoschild opened this issue ยท 3 comments

commented

Create a SMAPI mod which lets modders create content packs to edit XNB files, no code required.

commented

Proposed implementation

Modders would create standard content packs (see Pathoschild/SMAPI#436) with a content.json file which lets them edit data files, patch textures, replace files, etc.

Goals

  • For players:
    • Install XNB mods directly in Mods as content packs.
    • Install multiple mods which edit the same XNB file (as long as they don't conflict).
    • Easily mix conflicting mods by editing their content.json.
    • Get automatic compatibility checks (using ID + version in SMAPI compatibility list).
  • For modders:
    • Make low-level edits to all XNB files.
    • Avoid most compatibility issues with game updates (by patching XNB files instead of replacing them).

Limitations

  • Will not handle ID conflicts. If two mods use the same ID, it's up to the user to edit them to use different ones.
  • Will not provide high-level APIs (e.g. shop inventory, flower color variants, etc); that's the domain of higher-level mods like Json Assets.

Example content.json

[
   // edit data records
   {
      "File": "Data/Crops",
      "EditData": {
         300: {
            "Seasons": "spring summer fall winter" // can specify field key or index
         }
      }
   },

   // add/replace data records
   {
      "File": "Data/Crops",
      "EditData": {
         300: "1 2 1 1 2/fall/21/282/5/0/true 2 6 5 .1/false/false"
      }
   },

   // patch textures
   // (including support for patching past the bottom to add new hats, etc)
   {
      "File": "Maps/springobjects",
      "EditImage": {
         "FromFile": "assets/custom-objects.png",
         "FromArea": { "x": 0, "y": 0, "width": 16, "height": 16 }, // optional
         "ToArea": { "x": 0, "y": 0, "width": 16, "height": 16 }, // optional
         "PatchMode": "Overlay" // optional
      }
   },

   // replace entire files
   {
      "File": "Maps/stadium_tiles",
      "LoadFrom": "assets/custom-stadium-tiles.png"
   }
]
commented

Slightly more structure schema:

[
   // edit data
   {
      "Type": "EditData",
      "Asset": "Data/Crops",
      "Records": {
         300: "1 2 1 1 2/fall/21/282/5/0/true 2 6 5 .1/false/false"
      },
      "Fields": {
         300: {
            "Seasons": "spring summer fall winter" // can specify field key or index
         }
      }
   },

   // patch textures
   // (including support for patching past the bottom to add new hats, etc)
   {
      "Type": "EditImage",
      "Asset": "Maps/springobjects",
      "FromFile": "assets/custom-objects.png",
      "FromArea": { "x": 0, "y": 0, "width": 16, "height": 16 }, // optional
      "ToArea": { "x": 0, "y": 0, "width": 16, "height": 16 }, // optional
      "PatchMode": "Overlay" // optional
   },

   // replace entire files
   {
      "Type": "ReplaceFile",
      "Asset": "Maps/stadium_tiles",
      "ReplaceWith": "assets/custom-stadium-tiles.png"
   }
]
commented

Done and released a few days ago.