模组:製作一個XNB模組
←目錄
不完整的翻譯 本文或部分尚未完全翻譯成中文。
歡迎您通過編輯幫助其建設。 |
本頁介紹如何創建一個替換遊戲原文件的MOD,以便更改遊戲數據,圖像和地圖。
介紹
XNB模組的工作原理
The game stores data 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. Each .xnb file contains two files: the data file (like an image), and a metadata file (information about the data file). For example, here's what's inside Content\Portraits\Abigail.xnb:
Abigail.xnb Abigail.png Abigail.yaml
In the above example:
- Abigail.png contains Abigail's portraits. This is the file you would edit if you wanted to change her portraits in the game:
- Abigail.yaml contains metadata about Abigail.png (like what type of file it is). You don't need to worry about this file, since you generally won't be changing it.
An XNB mod replaces some of the game's XNB data files, which lets you change images (like portraits, NPCs, or buildings), data (like crop information or dialogue), or maps (including map behaviour like warps and minigames). XNB mods can also add entirely new content (like new NPCs).
XNB vs SMAPI mods
SMAPI is a modding API that lets you change the game using code. SMAPI mods are more powerful, easier to install and remove, and allow multiple mods to change the same content. On the other hand, SMAPI requires you to write code which some modders aren't comfortable with. If you have programming experience, creating a SMAPI mod is recommended instead if feasible.
有關這兩種mod的更多信息,請看:使用模組:玩家常見問題。
在哪裡可以獲得幫助?
The Stardew Valley modding community is very welcoming. Feel free come chat on Discord or post in the forums.
入門
First-time setup
Before you start, you should install these:
- on Windows
- XNB Extract 0.2.2 to unpack and pack the game's XNB files. (See forum post.)
- Paint.NET to edit image files (or use your favourite image editor).
- on Linux/Mac
- Wine 1.7 or later to run Windows programs like XNB Extract.
- XNB Extract 0.2.2 for Linux/Mac to unpack and pack the game's XNB files.
- GIMP to edit image files (or use your favourite image editor).
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:
- Download XNB Extract (see #First-time setup).
- Unpack the file for editing:
- Find the file you want to edit in the Contents folder.
- Copy it into XNB Extract's Packed folder.
- Double-click UnpackFiles.bat (Windows) or UnpackFiles.sh (Linux/Mac).
- Edit the unpacked file (see below).
- Repack the file for the game:
- Double-click PackFiles.bat (Windows) or PackFiles.sh (Linux/Mac).
- Move the repacked .xnb file back to the original location.
Making changes
Spritesheets, tilesheets, or portraits
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:
- Unpack the file you want to change.
- Open the unpacked .png file in an image editor (see #Getting started).
- 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.
地圖
請見:使用模組:地圖