• Journey's End on PC - Find info here and here. Please report bugs and issues for PC 1.4 and 1.4.1 to Re-Logic here.
  • Journey's End on Mobile - Find info here. Report bugs for Mobile 1.4 to DR Studios at this link and give as much detail as possible.
  • 1.4 will bring many changes to the PC version. We strongly advise making plans to back up your worlds and players prior to updating your game. More details here.
  • Console and Switch - The latest news can be found here. To report a bug, please use this link.

Standalone [1.3] tModLoader - A Modding API

Mod Development Guide for OSX/Linux
(or How to Build Your Mod Without Using tModLoader)
Introduction
Building a mod in a non-Windows operating system can be a bit difficult, since there is a lack of access to Visual Studio (on Linux; VS is now available for OSX, though none of the instructions below have changed) and tModLoader is unable to build the mod files itself. However, it is possible, and it's actually not all that hard. I will be using the Xamarin IDE (now replaced by VS on OSX, and MonoDevelop on Linux). Here's the steps:

1. Install Visual Studio (if on OSX) or Monodevelop (on Linux).
2. You're going to need a .csproj file. Copy the one from ExampleMod into your mod's root directory.
NOTE: All steps from 3 to 7 can be ignored if you use one of the pre-made .csproj XMLs in the attachments. Instructions on how to use them are included below.
3. Open the .csproj file in any text editor. You're gonna need to change a couple things. Specifically:
3a. Find the AssemblyName tag and change the value from "ExampleMod" to whatever your mod's name is (this is the name of the root folder).
3b. Go down to the end of the file and delete the line within the last PropertyGroup (the one that says "PostBuild" or whatever).
4. For convenience, rename this .csproj "Windows". Duplicate it and make another called "Mono".
5. Open the Windows.csproj in Xamarin, and expand the References "folder". Several Microsoft.Xna.* references and a Terraria reference should be missing.
6. Remove these references. Right-click on References and click Edit References. Go over to the .NET Assembly tab and click Browse. Now select all the .dll files and the .exe that came in the ModCompile folder of your non-Windows tModLoader download. Make sure the boxes of these new references are checked in the Edit References window, and click OK.
6b. If you aren't building ExampleMod, you'll probably notice many ExampleMod files that don't exist in your project. Go ahead and remove them at this time.
7. Do the same thing in the Mono .csproj file. However, this time, you're targeting different files: FNA.dll and a non-Windows tModLoader Terraria.exe. You can get these from either a non-Windows tModLoader Terraria installation or from the ModCompile folder in a Windows tModLoader download (the Terraria reference is tModLoaderMac.exe).
8. Build both .csproj files (click the 'Play' looking button on the top-left of the Xamarin window). I don't know if there's much of a difference between making a Debug and a Release build - for convenience, I just have Windows build as one type and Mono build as another.
9. If you've set everything up correctly, your mod builds should have succeeded. Go into the obj/release folder and the obj/debug folder. Take the ModName.dll files from each and rename them according to what built them (if you had Windows build to Debug, then rename the obj/debug file Windows.dll). Place these .dlls in the mod's root directory.
10. Open build.txt and add the line "noCompile = true" to the end of it.
11. Open Terraria and have tModLoader build your mod!
I hope this helps!

How to use the included .csproj files:
These files are pre-made .csproj files that have gone through the steps above and then some. TCF doesn't allow uploading files with the .csproj extension, so the .txt extension must be removed before use.
They should already have working sources, provided the .csproj is inside a folder in the Mod Sources directory. Sources are also set up to switch to the correct one depending on how you're building the project, so there's no need to have two separate projects for Mono and Windows builds.
The missing ReLogic dependencies ReLogic.dll and ReLogicLinux.dll can be downloaded from the tModLoader GitHub (found in the "references" folder) and placed into the ModCompile folder in your Terraria installation.

Additionally, they're already set up to automatically copy the built .dll files to the proper place when building, so you'll never have to manually move them yourself.
Build with both Mono and Windows settings to build both Mono.dll and Windows.dll!

_Blank files: These .csproj files don't contain any references to ExampleMod files and are perfect for starting a mod from scratch. They still contain build.txt and description.txt, which every mod should have anyway.
OSX/Linux files: Each version gets the sources from a slightly different location for the indicated operating system. Get the one that matches yours!

Don't forget that these files are still named ExampleMod both outside and inside, so be sure to change the assembly and root namespace name as you see fit!

A few notes:
-The mod's root folder must be located in Terraria/ModLoader/Mod Sources. You can access this folder from the Mod Sources option on the tModLoader main menu.
-If your mod is not referencing Microsoft.Xna.* in any way, then you don't need to do the double build: instead, just build one file and name it All.dll.
-tModLoader cannot build your mod if the AssemblyName does not match the name of the root folder.
-It's best to practice these steps by applying them to ExampleMod first, so that you know how it works. If you have issues building ExampleMod, check the steps again. If you're still having issues, contact me via Discord and I can put you in the right direction ;)
-Changing the RootNamespace option in your .csproj will change the default namespace that new .cs files are put into by the skeleton code.

-If you want your mod to be editable by non-Windows users, you can remove the exclusion of the .csproj file in build.txt. Others will then be able to open the .csproj after unpacking it with tModReader.

This is guide version 1.2. Changelog:
- 1.0: Initial release.
- 1.1: A bit more information, typo fixes.
- 1.2: More information, added template .csproj files
 

Attachments

Last edited:

ALmaZss

Plantera
I want to add bumping sound when my projectile collides with tile using OnTileCollide hook, but PlaySound method uses sounds of totally not items, like when 10 is harpoon's bumping sound, it is actually sound of opening the menu.
 

DaRealRoan

Terrarian
help trying to update my mods but the mod browser says 'Tha Mod rowser server is under heavy load. Try again later'.
what do i do if i only have 15 minutes to play?
 

DoYouEvenCookie

Terrarian
Code:
if (projectile.ai[1] > 0)
projectile.ai[0] = 0;
if (this.ai[0] == 0f)
{
this.velocity *= -1;
}
this.netUpdate = true;
Error:
file stuff (32,22) : error CS 1061 : file stuff does not contain a definition for 'ai' and no extension method 'ai' accepting a first argument of type file stuff could be found
help please
 

jopojelly

Retinazer
tModLoader
How would I make a ore spawn like the hardmode ores (Cobalt, Mythril, Adamantite etc) do?



Also how would I make a item spawn in one of the dungeon gold chests?

Also how would I make modded biome chests?

For recipes how would I make the tile required be the hardmode anvils (Mythril or Orichalcum) or forges (Adamantite or Titanium) without the pre-hardmode ones being usable?

Also how would I make something require the Demon/Crimson altar to be made?
For the last 2, just add the correct tile.

The ExampleMod has an example of ice chest items.

The other ones need to be more specific, so I know which part is the part you need help with
[doublepost=1465662220,1465662165][/doublepost]
Error:
file stuff (32,22) : error CS 1061 : file stuff does not contain a definition for 'ai' and no extension method 'ai' accepting a first argument of type file stuff could be found
help please
"this" needs to be "projectile"
[doublepost=1465662293][/doublepost]
help trying to update my mods but the mod browser says 'Tha Mod rowser server is under heavy load. Try again later'.
what do i do if i only have 15 minutes to play?
There's been an unusual amount of traffic these last few days, so the daily bandwidth gets eaten up really quickly. I'm looking into it.
[doublepost=1465662337][/doublepost]
I want to add bumping sound when my projectile collides with tile using OnTileCollide hook, but PlaySound method uses sounds of totally not items, like when 10 is harpoon's bumping sound, it is actually sound of opening the menu.
Show me what you got and tell me where you got the numbers that you expected to work.
 

11pixels

Terrarian
i dont know if this is exactly the right place to report problems, but i have a problem when i try to download any mod with mod browser
Code:
The system cannot find the file specified
   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at Terraria.ModLoader.UI.UIErrorMessage.OpenFile(UIMouseEvent evt, UIElement listeningElement)
   at Terraria.UI.UIElement.Click(UIMouseEvent evt)
   at Terraria.UI.UserInterface.Update(GameTime time)
   at Terraria.Main.do_Update(GameTime gameTime)
   at Terraria.Main.Update(GameTime gameTime)
 

jopojelly

Retinazer
tModLoader
How do I make stream/ray projectile like Water Scepter's one?
You can copy the item properties from the spreadsheet. As far as the projectile is concerned, most of the visual is just dust that looks flowy. I think the actual projectile is transparent.
[doublepost=1465662584,1465662492][/doublepost]
i dont know if this is exactly the right place to report problems, but i have a problem when i try to download any mod with mod browser
Code:
The system cannot find the file specified
   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at Terraria.ModLoader.UI.UIErrorMessage.OpenFile(UIMouseEvent evt, UIElement listeningElement)
   at Terraria.UI.UIElement.Click(UIMouseEvent evt)
   at Terraria.UI.UserInterface.Update(GameTime time)
   at Terraria.Main.do_Update(GameTime gameTime)
   at Terraria.Main.Update(GameTime gameTime)
That looks like the mod browser is telling you there is an error, but that directory is somehow not accessable by the program.
 

11pixels

Terrarian
i dont know if this is exactly the right place to report problems, but i have a problem when i try to download any mod with mod browser
Code:
The system cannot find the file specified
   at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
   at Terraria.ModLoader.UI.UIErrorMessage.OpenFile(UIMouseEvent evt, UIElement listeningElement)
   at Terraria.UI.UIElement.Click(UIMouseEvent evt)
   at Terraria.UI.UserInterface.Update(GameTime time)
   at Terraria.Main.do_Update(GameTime gameTime)
   at Terraria.Main.Update(GameTime gameTime)
I've tried to run as administrator, and make the Terraria folder in Documents/My Games/ non read only (like, untick the read only thing), but still nothing.
 

ALmaZss

Plantera
For the last 2, just add the correct tile.

The ExampleMod has an example of ice chest items.

The other ones need to be more specific, so I know which part is the part you need help with
[doublepost=1465662220,1465662165][/doublepost]
"this" needs to be "projectile"
[doublepost=1465662293][/doublepost]
There's been an unusual amount of traffic these last few days, so the daily bandwidth gets eaten up really quickly. I'm looking into it.
[doublepost=1465662337][/doublepost]
Show me what you got and tell me where you got the numbers that you expected to work.
I'm taking numbers from my post http://forums.terraria.org/index.php?threads/sound-ids.41821/ .
And what do you mean, asking me what I got?
[doublepost=1465663165][/doublepost]I guess there is something like types of sounds, but I wonder how I can use them properly.
 

jopojelly

Retinazer
tModLoader
I'm taking numbers from my post http://forums.terraria.org/index.php?threads/sound-ids.41821/ .
And what do you mean, asking me what I got?
[doublepost=1465663165][/doublepost]I guess there is something like types of sounds, but I wonder how I can use them properly.
Yeah, those are just the item use sounds. The tile collide sounds are a completely different category. Look in the dust and sound catalogue mod. They are explained there.

I've tried to run as administrator, and make the Terraria folder in Documents/My Games/ non read only (like, untick the read only thing), but still nothing.
That is odd. I don't know what is going on there.
 

11pixels

Terrarian
Yeah, those are just the item use sounds. The tile collide sounds are a completely different category. Look in the dust and sound catalogue mod. They are explained there.


That is odd. I don't know what is going on there.
Any suggestions? I'm going to uninstall terraria completely then install it again, gonna create new character, start new world then play for few mintues and at the end I'll try to put the mods.
 

jopojelly

Retinazer
tModLoader
Any suggestions? I'm going to uninstall terraria completely then install it again, gonna create new character, start new world then play for few mintues and at the end I'll try to put the mods.
Well, the error is it can't open the error file. Actually, this error message looks like it happened when you clicked the open file button, is that right? You don't need to open the file.
 

11pixels

Terrarian
Well, the error is it can't open the error file. Actually, this error message looks like it happened when you clicked the open file button, is that right? You don't need to open the file.
Error happens when I click the button for installing, then first i clicked open file but after i did that again it opened...idk
 

11pixels

Terrarian
You mean installing a mod, right? Did you read the error message in the window there?
first error after trying to install mod was about heavy load on server or something, second error was cannot find file specified, then it opened the folder with Runtime Error file which showed the same error: "cannot find file specified"
 

ALmaZss

Plantera
I want when hit by a projectile at the enemy, it appeared the dust. When I use this code nothing happens
Code:
        public override void OnHitNPC(NPC target, int damage, float knockback, bool crit)
        {
            int a = Dust.NewDust(new Vector2(target.position.X, target.position.Y + 2f), target.width, target.height, 21, target.velocity.X * 0.2f, target.velocity.Y * 0.2f, 100, default(Color), 2f);
            Main.dust[a].noGravity = true;
            Main.dust[a].velocity *= 0.3f;
            Dust b = Main.dust[a];
            b.velocity.X = b.velocity.X - target.velocity.X * 0.2f;
        }
 
Last edited:

W1K

Witch
Quick and fast question, is there any way to hide an NPC's health bar? Specifically, I need this to prevent a worm NPC from showing the (usually wrong) hp of its single parts. Vanilla worms seem to use a bool called "dontCountMe", but setting it to true didn't seem to do anything.
 

Four

Terrarian
Hey whenever I try to download a mod it says "The mod browser server is currently under heavy load. Try again later."
Can I do anything to fix this or do I just have to wait?
 
Top Bottom