-
Notifications
You must be signed in to change notification settings - Fork 22
Testing
In the process of making your mod, you're going to have to test it many times, so it's important to make that process as easy and helpful as possible.
To do so, you'll first learn how it's done in general, and then how to make it easier.
At the top right of your IDE, there should be a tab labeled Maven
(New IntelliJ UI: A button at the top of the right sidebar with an m
symbol). If it isn't there, click on View
->Tool Windows
->Maven
(New IntelliJ UI: Click top left 4 horizontal lines button to show the File/View/etc. toolbar first).
Open it.
Under Lifecycle
, you should see many options. There are only two that you should need to use. First, is package
. This is the process of compiling all your code and resource files and turning it into a .jar
file. Second is clean
. For efficiency, not all files get re-packaged every time you package. It tries to track which files have/haven't been changed. This can rarely result in your changes not going through even though they should. In cases like this, using clean
before package
will cause ALL files to be packaged.
Double-click package
to package
your mod. An area should appear at the bottom of the IDE displaying a text log of the process.
Now, you can test your mod. If you've played Slay the Spire modded before, that's all you have to do. Click Play from the Steam library page of Slay the Spire, which should give you the option of playing with mods. When ModTheSpire opens, find your new mod in the mod list and enable it, and launch the game. You'll also have to enable BaseMod and stslib. For testing, I recommend disabling everything else. You can make a new profile in ModTheSpire using the +
button underneath the folder button.
If you've done everything correctly, Slay the Spire should launch, and from the Mods
option of the in-game main menu, you should be able to see your mod.
While this process isn't difficult, it is a bit cumbersome. Setting up IntelliJ debugging will make this process faster, in addition to allowing you to use some useful debugging features.
First, click the Add Configuration...
button at the top right of IntelliJ.
This will open the Run/Debug Configurations
window. Click the +
button to add a new configuration and choose
JAR Application
.
You'll want to set it up as follows (for Windows, continue reading for Mac):
The name can be anything, I recommend mts
or ModTheSpire
or some variation of such.
Path to JAR
should be pointing to ModTheSpire.jar
. If you're using Steam, it'll be something along the lines of C:\Program Files (x86)\Steam\steamapps\workshop\content\646570\1605060445\ModTheSpire.jar
. You'll need to adjust the first part appropriately, as you did for the pom.xml
. If you are not using Steam, it will just be wherever you have ModTheSpire.jar
downloaded.
Working Directory
should be wherever you have Slay the Spire installed. Specifically, the folder containing desktop-1.0.jar
and files such as SlayTheSpire.exe
.
Windows example: C:\Program Files (x86)\Steam\steamapps\common\SlayTheSpire
Mac example: Users/username/Library/Application Support/Steam/steamapps/common/SlayTheSpire/SlayTheSpire.app/Contents/Resources/
Last is JRE
, which is the Java Runtime Environment, the version of java that will be used to run the game. Slay the Spire comes with the version of java intended to run it, so this will be exactly the same as your Working Directory
with the addition of \jre
.
Steam example: C:\Program Files (x86)\Steam\steamapps\common\SlayTheSpire\jre
Mac example: Users/username/Library/Application Support/Steam/steamapps/common/SlayTheSpire/SlayTheSpire.app/Contents/Resources/jre
At this point, you have a functional debug setup, which will run ModTheSpire
from inside IntelliJ. The next step will cause your mod to be packaged every time you launch ModTheSpire, which you may not want. If you're confident that you won't forget to package, you can skip this step.
Scroll down in the setup window. There should be a section labeled Before launch
. Click the +
button to add and choose Run Maven Goal
.
In the window that pops up, you should not need to edit the Working Directory
. Simply enter package
in the Command line
box. It should offer you an autocomplete which you can click if you want.
Click Ok. If you've set it up correctly, you should have the following.
You could also add a clean
goal if you want, though this is optional. If you do, make sure it goes above the package
goal so that it is performed first.
Click Ok to finish setting up the configuration. Now at the top right, your configuration should be visible.
The buttons next to it are Run
and Debug
respectively. Generally, you'll want to use Debug
for testing. This will allow you to navigate directly to the problematic line when errors occur, in addition to the use of breakpoints, which will pause the code and allow you to run it line-by-line to make sure everything is working as intended. You can test it now to ensure you've set it up correctly.
The BaseMod console is also extremely helpful for testing. You may have to enable it in BaseMod's config from the in-game Mods menu.
Now that your mod and testing are setup, all that's left is to make your mod.
First you should learn (at least roughly) how it works.