Skip to content

Pathoschild/StardewXnbHack

Repository files navigation

StardewXnbHack is a one-way XNB unpacker for Stardew Valley. It supports every Stardew Valley asset type, is very easy to update for game changes, and is quick at unpacking many files at once.

Usage

To install it:

  1. Install Stardew Valley and SMAPI.
  2. From the releases page, download the StardewXnbHack *.zip file for your operating system under 'assets'.
  3. Unzip it into your Stardew Valley folder, so StardewXnbHack.exe (Windows) or StardewXnbHack (Linux/macOS) is in the same folder as Stardew Valley.dll.

To unpack the entire Content folder into Content (unpacked), just double-click on StardewXnbHack.exe (Windows) or StardewXnbHack (Linux/macOS).

FAQs

How does this compare to other XNB unpackers?

StardewXnbHack reads files through a temporary game instance, unlike other unpackers which read them directly. That lets it support custom Stardew Valley formats, but it can't repack files (which is rarely needed anyway) or support other games.

The main differences at a glance:

  StardewXnbHack xnbcli XNBExtract
Supported asset types ✓ images
✓ maps
✓ dictionary data
✓ font texture
✓ font XML data
✓ structured data
✓ images
✓ maps
✓ dictionary data
✓ font textures
✓ font XML data
❑ structured data
✓ images
✓ maps
✓ dictionary data
✓ font textures
❑ font XML data
❑ structured data
Export formats .png for images
.tmx for maps
.json for data (CP-compatible)
.png for images
.tbin for maps¹
.json for data (custom format)
.png for images
.tbin for maps¹
.yaml for data
Supported platforms ✓ Windows
✓ Linux
✓ Mac
✓ Windows
✓ Linux
✓ Mac
✓ Windows
❑ Linux
❑ Mac
Supported operations ✓ unpack
❑ pack
✓ unpack
✓ pack (uncompressed)
✓ unpack
✓ pack
Maintainable ✓ easy to update ❑ complex ❑ complex, closed-source
Sample unpack time
(full Content folder)
≈0m 43s ≈6m 5s ≈2m 20s
License MIT GPL n/a

¹ .tmx is the preferred map format, but you can open the .tbin file in Tiled and export it as .tmx.

When I run StardewXnbHack, nothing happens or it quickly exits?

That means it crashed for some reason.

First, make sure you have the latest versions of SMAPI and Stardew Valley.

If it still happens, here's how to see what the error is:

  1. Find your game folder.
  2. Open a terminal in the game folder.
  3. Type this command:
    • Windows: StardewXnbHack.exe (for Command Prompt) or ./StardewXnbHack.exe (for PowerShell or Windows Terminal)
    • Linux or macOS: ./StardewXnbHack
  4. Press enter to run the command.

That should run StardewXnbHack in the same terminal, and the window will stay open if it crashes.

You can ask for help in #making-mods on the Stardew Valley Discord. If you're sure it's a StardewXnbHack bug (and not a usage error), you can report it on the issues page.

Can I simplify the data files?

By default, unpacked data files include all of the fields. This can be very noisy, and doesn't really match how the data assets are formatted in the original code.

You can omit the default fields instead:

  1. Open a terminal in your game folder.
  2. Run StardewXnbHack.exe --clean to omit the default fields.

This is still experimental, but it may become the default behavior in future versions.

For StardewXnbHack developers

This section explains how to edit or compile StardewXnbHack from the source code. Most users should use the release version instead.

Compile from source

  1. Install Stardew Valley and SMAPI.
  2. Open the .sln solution file in Visual Studio.
  3. Click Build > Build Solution. (If it doesn't find the Stardew Valley folder automatically, see custom game path in the mod build package readme.)

Debug a local build

Just launch the project via Debug > Start Debugging. It will run from your bin folder, but should auto-detect your game folder and unpack its Content folder.

Prepare a compiled release

To prepare a crossplatform SMAPI release:

  1. Update the semantic version in StardewXnbHack.csproj.
  2. Run the build-scripts/prepare-release-packages.sh on Linux or macOS.
    See the equivalent documentation for SMAPI for the first-time setup (including using WSL on Windows).
  3. Release the zip files created in the root bin folder.

See also