Modding: Stardew Valley SMAPI Guide
Sometimes, many of us get tired of built-in functions and standard circumstances. Sometimes we want to change the game a little bit, customize it. And the better player you are, the more you know the game, the stronger may be your wish to create and install modifications. There are a lot of mods in the internet, but we decided to tell you how to create your own mod, and take advantages of new events and APIs.
First of all, what is SMAPI? It’s a modding API that extends the game logic. Code runs every time you make some action, like clicking buttons or opening menus. Other elements of code may rune once per game. To write SMAPI mod, you need to use C#, namely, .NET Framework. For Linux and Mac, you must use MonoGame, and for Windows – XNA.
If you’re a little disappointed of these strange words, you may be new to programming. However, many mod writers start with probably no experience. It’s still not an easy thing for beginners, but you can start doing little steps towards mod developing, the main thing is to be not too confident about it. Try to make an easy, small Stardew Valley mod. We suggest you to join one of many modding forums and ask all questions you need. Start learning C#, you will surely need to master basics, as well as to get used to event-driven programming.
If you are a programmer, or at least have some programming experience, this task won’t be a big problem for you. All you need is knowledge of C# fundamentals and Java.
Before you start, you have to install Stardew Valley game. Then install SMAPI and IDE, which stands for Integrated Development Environment. Use Visual Studio 2017 for Windows and Mac, MonoDevelop for Linux.
Create Your Mod
Open MonoDevelop or Visual Studio 2017. Create a C# class library project and solution. Check the compatibility of your framework with Linux (it must be .NET Framework 4.5). Reference the package with necessary configurations, using Visual Studio. You need to make correct dependencies for modding, as well as provide support for debugging. Don’t forget to copy your mod into the Mods folder.
Then you have to write your code and manifest. You must delete MyClass.cs and Class1.cs files, and add new ModEnry.cs class to the project. Write your code, and then create a file called manifest.json. Here you can describe such details, as your name, features of the mod, and so on.
When your project is built, run the game, using SMAPI. Every time you press a key, new mod will send messages to the console window. If it doesn’t work, or something is going wrong, make sure that you followed all the steps above and didn’t miss a thing. If you see an error which starts with the words “The mod build package”, just simply follow all the instructions on the screen.
If you still cannot fix a problem, we suggest you to visit forums. You can always count on other mod developers, since there is a strong and friendly community of enthusiasts.
If you look at the best Stardew Valley mods, you may notice that they all are cross-platform, so you need to consider such an issue too. Usually SMAPI adapts your mod to different platforms automatically. You can also set up all necessary references with the crossplatform build config. It will allow your code to run on any platform. We also suggest you to specify mod path manually, in the helper.DirectoryPath.
To make sure that your mod works correctly on different platforms, test it both on Windows, and Linux/Mac. Players often ask how to install mods on several platforms. Well, you don’t have to do it on different computers, nor install two OS on your PC. Just install VirtualBox, which allows you to run any program on a virtual PC with chosen operational system. Choose virtual Linux machine, and install Stardew Valley game on it. Now you can test your mod with Linux. You can also try other platforms as well.
If you’re proud of your work and you want to share it with others, you have to upload it on one of the popular sources, such as Nexus Mods, or some modding forums. This will also help you if you want to receive feedback and keep working on your mod. To share it, find a .zip file in your project’s bin/Debug folder. It may be also called bin/Release, depending on how you have built the project.
When you feel confident enough to start creating your own Stardew Valley best mods, we suggest you to study the game code and understand how it works. You can use dotPeek, to get the decompiled code, which can be opened in Visual Studio 2017. However, you cannot run this code, but at least you will be able to read it. We also suggest you to unpack the XNB files, using one of XNB toolkits.