Hello terrarians, and welcome to an updated thread on how to make a modified client in terraria. This thread will only cover how to modify the executable and inject code at startup. It will not cover how to make commands, or do anything really, but it will put you on the right track. If this post gets enough attention and likes, I will do a second part with more info (Hooking chat, adding commands).
Part 1 (Download DNSPY and open the Terraria executable) :
To download DNSpy, please visit this link.
https://******.com/0xd4d/dnSpy/releases DNSpy is .Net debugger and assembly editor, which will allow you to modify the Terraria executable. Once you have opened the link, click DNSpy.zip, and wait for it to download. Once it is finished, open the .zip file with a archive extracting program (7-zip or WinRAR), and then scroll down and open dnSpy-x86.exe. Once in the program, click on File>Open..., then find and select Terraria.exe (from your steamapps folder.).
Part 2 (Patch the Terraria executable to hook startup code)
Great, you got it open. I'm proud of you for making it this far. Okay, now this is where it may get a little harder. Try to keep up. First, look to the Assembly Explorer. It's on the far left and it is very noticeably blue. Found it? Great. Now scroll through the list until you find "Terraria". Press the drop-down triangle, again, look for "Terraria" except now in yellow, drop-down it again, and find "Program", now in green, once again press the arrow to drop-down. Now, right click "LaunchGame(...", and click "Edit Method". Now, a box will open. Delete these lines.
Code:
if (Platform.IsOSX)
{
Main.OnEngineLoad += delegate
{
Main.instance.IsMouseVisible = false;
};
}
Now tap "Compile". Okay, you still with me? No? Once you are back in the Assembly Explorer, move up back towards the yellow "Terraria", and right click it. Click "Add Class". Once it shows the blank box, paste this in.
Code:
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
namespace Terraria
{
public class Mods
{
public static void Main()
{
Terraria.Main.OnTick += Mods.OnUpdate;
}
static Mods()
{
}
public static void OnUpdate()
{
//code in here will run every frame
}
public Mods()
{
}
}
}
Then, press "Compile". Great, you should probably now save your client. Go to File>Save Module and click "OK". You can now start it by pressing Debug>Start Debugging... To make sure it worked, add this code inside the brackets of "public static void OnUpdate()" to your Mods code (under yellow Terraria).
Code:
Terraria.Main.NewText("Hello World!");
(Then File>Save Module, obviously.) If it worked, Hello World! will spam your chat really fast whenever you are in game. Feel free to remove this after.