Difference between revisions of "Modding:Editing XNB files"
Margotbean (talk | contribs) m (Text replacement - "tt>" to "samp>") |
m |
||
(9 intermediate revisions by 6 users not shown) | |||
Line 6: | Line 6: | ||
===What are XNB files?=== | ===What are XNB files?=== | ||
The game stores data, maps, and textures in a compressed format with the <samp>.xnb</samp> file extension inside its <samp>Content</samp> folder. For example, Abigail's portrait shown during dialogue is from <samp>Content\Portraits\Abigail.xnb</samp>. Unpacking that file gives you an <samp>Abigail.png</samp> like this:<br />[[File:Modding - creating an XNB mod - example portraits.png]] | The game stores data, maps, and textures in a compressed format with the <samp>.xnb</samp> file extension inside its <samp>Content</samp> folder. For example, Abigail's portrait shown during dialogue is from <samp>Content\Portraits\Abigail.xnb</samp>. Unpacking that file gives you an <samp>Abigail.png</samp> like this:<br />[[File:Modding - creating an XNB mod - example portraits.png]] | ||
− | |||
− | |||
===How do I get my changes in the game?=== | ===How do I get my changes in the game?=== | ||
Line 25: | Line 23: | ||
{{github|Pathoschild/StardewXnbHack#readme|StardewXnbHack}} is an open-source and crossplatform tool for unpacking XNB files. It can't pack files back into <samp>.xnb</samp>, but you [[Modding:Content Patcher|rarely need to]]. | {{github|Pathoschild/StardewXnbHack#readme|StardewXnbHack}} is an open-source and crossplatform tool for unpacking XNB files. It can't pack files back into <samp>.xnb</samp>, but you [[Modding:Content Patcher|rarely need to]]. | ||
− | + | To unpack files: | |
# [[Modding:Player Guide/Getting Started|Install SMAPI]]. | # [[Modding:Player Guide/Getting Started|Install SMAPI]]. | ||
# {{github|Pathoschild/StardewXnbHack/releases|Download StardewXnbHack}}. (Make sure you download the file for your OS, such as <samp>StardewXnbHack-*-for-windows.zip</samp>, not the source code!) | # {{github|Pathoschild/StardewXnbHack/releases|Download StardewXnbHack}}. (Make sure you download the file for your OS, such as <samp>StardewXnbHack-*-for-windows.zip</samp>, not the source code!) | ||
− | # Unzip the download into [[Modding: | + | # Unzip the download into [[Modding:Player Guide/Getting Started#Find your game folder|your game folder]], so {{executable name|StardewXnbHack}} is in the same folder as {{executable name|StardewValley}}. |
− | # Double-click | + | # Double-click {{executable name|StardewXnbHack}} (on Windows), <code>StardewXnbHack.sh</code> (on Linux), or <code>StardewXnbHack.command</code> (on MacOS) to unpack your game's entire <samp>Content</samp> folder. |
That's it! It'll unpack the files into a <samp>Content (unpacked)</samp> folder. The unpacked files will already be compatible with [[Modding:Content Patcher|Content Patcher]]. | That's it! It'll unpack the files into a <samp>Content (unpacked)</samp> folder. The unpacked files will already be compatible with [[Modding:Content Patcher|Content Patcher]]. | ||
===xnbcli=== | ===xnbcli=== | ||
− | {{github|LeonBlade/xnbcli#readme|xnbcli}} is an open-source and crossplatform tool for packing and unpacking XNB files. It can't unpack XNB files containing data models (like <samp>Data\FishPondData</samp> or <samp>Data\Movies</samp>) | + | {{github|LeonBlade/xnbcli#readme|xnbcli}} is an open-source and crossplatform tool for packing and unpacking XNB files. |
+ | |||
+ | This supports XNB files for other games too, but it can't handle some files specific to Stardew Valley. [[#StardewXnbHack|StardewXnbHack]] is recommended instead. | ||
+ | |||
+ | {{collapse|content= | ||
+ | Special notes: | ||
+ | * It can't unpack XNB files containing data models (like <samp>Data\FishPondData</samp> or <samp>Data\Movies</samp>); use [[#StardewXnbHack|StardewXnbHack]] if you need those. | ||
+ | * You'll need to edit unpacked data files manually to work with mods like Content Patcher. | ||
+ | * When unpacking an image with xnbcli, you'll get extra <samp>.json</samp> file next to the image. That's only used to convert it back into an <samp>.xnb</samp> later, and you generally don't need to change it. | ||
− | + | To unpack files: | |
<ol> | <ol> | ||
Line 93: | Line 99: | ||
* If you get unrecognized command on Windows: | * If you get unrecognized command on Windows: | ||
*# Make sure you didn't download the source code zip by mistake. If the folder path refers to "master", it's the wrong one! | *# Make sure you didn't download the source code zip by mistake. If the folder path refers to "master", it's the wrong one! | ||
+ | }} | ||
==Pack game files== | ==Pack game files== | ||
− | There's no need to repack game files if you're using [[Modding:Content Patcher|Content Patcher]]! Just use the <samp>.json</samp>, <samp>.png</samp>, or <samp>.tbin</samp> file directly in your <samp>content.json</samp>. | + | There's no need to repack game files if you're using [[Modding:Content Patcher|Content Patcher]]! Just use the <samp>.json</samp>, <samp>.png</samp>, <samp>.tmx</samp>, or <samp>.tbin</samp> file directly in your <samp>content.json</samp>. |
If you really want to repack the files, you'll need to use [[#xnbcli|xnbcli]]: | If you really want to repack the files, you'll need to use [[#xnbcli|xnbcli]]: | ||
Line 157: | Line 164: | ||
|- | |- | ||
| [https://krita.org/en/ Krita] | | [https://krita.org/en/ Krita] | ||
− | | Free | + | | Free and $9.99 on Steam |
| Windows, macOS, Linux | | Windows, macOS, Linux | ||
| | | | ||
Line 192: | Line 199: | ||
|- | |- | ||
| [https://code.visualstudio.com/ Visual Studio Code] | | [https://code.visualstudio.com/ Visual Studio Code] | ||
− | |||
− | |||
− | |||
− | |||
− | |||
| Free | | Free | ||
| Windows, macOS, Linux | | Windows, macOS, Linux | ||
Line 205: | Line 207: | ||
[[Category:Modding]] | [[Category:Modding]] | ||
+ | [[es:Modding:Edición de archivos XNB]] | ||
+ | [[pt:Modificações:Editando arquivos XNB]] | ||
[[ru:Модификации:Редактирование XNB файлов]] | [[ru:Модификации:Редактирование XNB файлов]] | ||
+ | [[tr:Modlama:XNB Dosyaları Düzenleme]] | ||
[[zh:模组:编辑 XNB 文件]] | [[zh:模组:编辑 XNB 文件]] |
Latest revision as of 09:04, 17 July 2024
← Index
This page explains how to edit the game files to change in-game data, images, and maps.
Intro
What are XNB files?
The game stores data, maps, and textures in a compressed format with the .xnb file extension inside its Content folder. For example, Abigail's portrait shown during dialogue is from Content\Portraits\Abigail.xnb. Unpacking that file gives you an Abigail.png like this:
How do I get my changes in the game?
There are three ways to get your changes in the game:
- Create a Content Patcher content pack. This lets you change the game's XNB data with zero programming (just editing a JSON file) and without replacing the actual game files.
- Create a SMAPI mod and use the Content API. This requires programming, though.
- Create an XNB mod by replacing the original game files. This is no longer recommended and not documented here; see using XNB mods for more info.
Where can I get help?
The Stardew Valley modding community is very welcoming. Feel free to ask the community for help.
Unpack game files
You can't edit an .xnb file itself, you need to edit the file that's inside it. Pulling out that inner file is called unpacking, and putting it back is called packing. There are two main XNB unpackers available.
StardewXnbHack
StardewXnbHack is an open-source and crossplatform tool for unpacking XNB files. It can't pack files back into .xnb, but you rarely need to.
To unpack files:
- Install SMAPI.
- Download StardewXnbHack. (Make sure you download the file for your OS, such as StardewXnbHack-*-for-windows.zip, not the source code!)
- Unzip the download into your game folder, so
StardewXnbHack.exe
is in the same folder as
.StardewValley.exe
- Double-click
StardewXnbHack.exe
(on Windows),StardewXnbHack.sh
(on Linux), orStardewXnbHack.command
(on MacOS) to unpack your game's entire Content folder.
That's it! It'll unpack the files into a Content (unpacked) folder. The unpacked files will already be compatible with Content Patcher.
xnbcli
xnbcli is an open-source and crossplatform tool for packing and unpacking XNB files.
This supports XNB files for other games too, but it can't handle some files specific to Stardew Valley. StardewXnbHack is recommended instead.
Details |
---|
Special notes:
To unpack files:
Troubleshooting:
|
Pack game files
There's no need to repack game files if you're using Content Patcher! Just use the .json, .png, .tmx, or .tbin file directly in your content.json.
If you really want to repack the files, you'll need to use xnbcli:
- Find the file you want to repack.
- Copy it into xnbcli's unpacked folder.
- Double-click pack.bat (Windows), pack.sh (Linux), or pack.command (Mac).
- Move the repacked .xnb file back to the original location.
Making changes
Data
Each data XNB has its own format. See the documentation at Modding:Index#Advanced topics.
Images
A few definitions:
- A spritesheet is a PNG file containing small images (usually in a regular grid pattern). Each square in the spritesheet's grid pattern is called a sprite. For example, each in-game item has a sprite in Content\Maps\spring_objects.xnb.
- A tilesheet is a synonym for spritesheet when used for map tiles. In a tilesheet, each square is called a tile and is 16×16 pixels.
- A portrait is a sprite from the Content\Characters\*.xnb spritesheets.
Spritesheets are easy to edit:
- Unpack the file you want to change.
- Open the unpacked .png file in an image editor (like Paint.NET on Windows, or GIMP on Windows/Linux/Mac). Note that it's important to use an image editor that can handle transparency (a.k.a. an alpha channel), unlike Microsoft Paint.
- Make changes directly to the image.
- Repack the file and copy it back to the original location.
That's it! You can launch the game to see your changes.
Maps
See Modding:Maps.
Content editing
Note that prices for software listed below are subject to change.
Pixel Art software
Software | Price (USD) | OS | Notes |
---|---|---|---|
Aseprite | $19.99 | Windows, macOS, Linux | Free if you compile yourself from the source code |
Photoshop | $9.99/mo | Windows, macOS | Subscription based service |
PAINT.NET | Free and $6.99 on Microsoft Store | Windows | |
GIMP | Free | Windows, macOS, Linux | |
Krita | Free and $9.99 on Steam | Windows, macOS, Linux | |
Pyxel Edit | $9.00 | Windows | Currently in beta, subject to a price increase upon full release |
Pixel Studio Android or Pixel Studio Steam | Free - In App Purchases on Android | Android, Windows |
Text editing software
Software | Price (USD) | OS | Notes |
---|---|---|---|
Sublime Text | $99.00 | Windows, macOS, Linux | Unlimited free trial |
Notepad++ | Free | Windows | |
Visual Studio Code | Free | Windows, macOS, Linux |