tModLoader, a Terraria modding API
About
tModLoader is an API for Terraria that provides a way to load your own mods without having to work directly with Terraria's source code. This means you can easily make mods that are compatible with other people's mods and save yourself the trouble of having to decompile then recompile Terraria.exe. It is made to work for Terraria version 1.3 and above.
Our goal for tModLoader is to make it simple as possible to mod while giving the modder powerful control over the game. It is designed in a way as to minimize the effort required for us to update to future Terraria versions. If you either don't want to commit to this project or are not able to decompile Terraria, we are open to suggestions for hooks and/or modifications.
Download and installation instructions are on the forums thread.
Note: this repository will be ahead of the current released version.
Contributing
Huge thanks to ChickenBones for creating the code patcher!
Brief introduction
tModLoader uses its own code patcher. If you want to contribute to tModLoader, you will have to use this tool. We need to use a patches system, because we are not allowed to upload vanilla source code publicly. It also allows for relatively easy code maintenance. Here's what the tool looks like: url
Before you're about to make a contribution, please check this article. Thanks in advance.
Getting the tModLoader code for the first time
- Clone this repository
- Open setup.bat in the root folder
- If setup.bat won't open, you must unblock all the files in the cloned repository
- Select your vanilla terraria.exe (must be vanilla) (img)
- Click on 'Setup' (top left button)
- Warning: decompilation can take several hours to complete depending on your hardware. It's also likely that your computer completely freezes during the process, mainly once it hits NPC.cs It is recommended that you enable the 'Single Decompile Thread' option (img) if you don't have very high end hardware. It's unwise to even attempt a decompile if you have less than 8 GB RAM. Having an SSD, powerful CPU and a high amount of RAM will significantly speed up the decompilation process.
- When decompilation is complete, verify that you have these folders:
- src/decompiled/
- src/merged/
- src/Terraria/
- src/tModLoader/
- To open up the tModLoader workspace, navigate to solutions/ and open tModLoader.sln
- ???
- Profit
Keeping your code up-to-date
Warning: it is wise that you backup your edits before pulling latest patches, if you have any that you haven't committed yet. Applying the latest patches will delete any of your work not included in them.
- Pull all newer commits from this repository
- You should verify that you now have the latest patches, located in patches/
- Open setup.bat in the root folder
- Click on 'Regenerate Source' (bottom right corner)
- After this process you can open solutions/tModLoader.sln as usual with the updated code
- ???
- Profit
Committing your changes
- Open setup.bat in the root folder
- Click on 'Diff x' where x is your workspace
- Your workspace is tModLoader 99% of the time. If it isn't, we imply you know what you're doing.
- Create a new commit to commit the patches/ folder
- Before you push your commit, please check our contribution article. Thanks.
- ???
- Profit