模组:編輯 XNB 文件

於 2021年4月12日 (一) 08:46 由 1059 Studio對話 | 貢獻 所做的修訂

目錄

本頁描述了如何編輯遊戲文件以更改遊戲中的數據、圖像和地圖。

介紹

什麼是 XNB 文件?

遊戲將數據、地圖和紋理 存儲在 .xnb 這種壓縮數據文件中,它們在遊戲的 Content 文件夾中。 例如,對話期間顯示的阿比蓋爾的頭像來自這個文件: Content\Portraits\Abigail.xnb。解包這個文件,你會得到 Abigail.png 這個圖片文件,內容如下:
 

(如果你使用 xnbcli 來解包,你通常會得到 Abigail.json 文件。 那只是用來打包回 .xnb 所需的文件,通常不需要更改它。)

如何將更改應用到遊戲中?

有3個方法可以使你的修改應用到遊戲中:

  1. 創建一個 Content Patcher 內容包。這不需要編程,僅編輯 JSON 文件就可以更改遊戲的 XNB 數據,也無需替換實際的遊戲文件。
  2. 製作一個 SMAPI 模組 並使用 內容 API。不過,這需要編程。
  3. 通過替換原始遊戲文件來創建 XNB 模組。不再建議使用,本頁面沒有講解; 訪問 使用 XNB 模組 獲取更多信息。

在哪裏可以得到幫助?

歡迎訪問星露谷模組社區。Feel free to ask the community for help.

解包遊戲文件

你無法編輯 .xnb 文件其本身,你需要編輯其中的文件
將文件從中取出叫做 解包
把文件放入其中叫做 打包
有兩個主要的 XNB 解包工具可用:

StardewXnbHack

StardewXnbHack 是用於解包 XNB 文件的開源且跨平台的工具
它不能打包回 .xnb 不過你會需要 創建內容包

on Linux/Mac

You should also back up your game's Content folder, so you can recover the original files if you make a mistake.

Unpack & pack 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. Here's how to do it:

  1. Download XNB Extract (see #First-time setup).
  2. Unpack the file for editing:
    1. Find the file you want to edit in the Contents folder.
    2. Copy it into XNB Extract's Packed folder.
    3. Double-click UnpackFiles.bat (Windows) or UnpackFiles.sh (Linux/Mac).
  3. Edit the unpacked file (see below).
  4. Repack the file for the game:
    1. Double-click PackFiles.bat (Windows) or PackFiles.sh (Linux/Mac).
    2. Move the repacked .xnb file back to the original location.

Making changes

Spritesheets, tilesheets, or portraits

 
An example tilesheet, which consists of a grid of tiles like this:  

Definitions:

  • A spritesheet is a PNG file containing small images 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:

  1. Unpack the file you want to change.
  2. Open the unpacked .png file in an image editor (see #Getting started).
  3. Make changes directly to the image.
  4. Repack the file and copy it back to the original location.

That's it! You can launch the game to see your changes.

地圖

請見:使用模組:地圖