Standalone [Cross Platform] Open Terraria API

Status
Not open for further replies.

SignatureBeef

Terrarian
Introducing the Open Terraria API version 2.0
The Open Terraria API, known as OTAPI, is a unique low-level API for Terraria that exposes events and provides performance optimisations while supporting both client and server executables on all official platforms.

You can use this modification as a NuGet package to power your own project with minimal update downtime*, or you can build plugins for NyxStudios' TShock which uses OTAPI under the hood.

How does it work?
Simple - we reuse the official binaries and add our modifications in via our patching process.
This method means we do not have to update our logic to match the new updated Terraria code, and so we can focus on adjusting our modifications (e.g. tiles, hooks, performance improvements) should they detect an abnormality.

Who is this intended for?
This is primarily intended for developers who want to create their own client or server modifications (just like TShock), as well as server administrators and GSPs who want to run the vanilla server with the ability to have better memory usage.

Want to help?
Simply head on over to TShock and join the Discord chat to get in the loop. A number of the developers here are familiar with the project and can help you.

Upcoming in version 3.0 (for developers)
This version of the OTAPI introduces a couple cool new features.
  • The first being a pattern based query mechanism that you can use to find meta data (ie methods, fields etc).
  • Secondly a new auto hook mechanism has been introduced
Combine these two new features together and you can hook a number of methods in one go, see below.

Code:
// hooks any method prefixed with "Send" in Terraria.NetMessage
// this generates a number of Pre/Post hooks in ModFramework.ModHooks.NetMessage
// which can be used in external API consumers
new Query("Terraria.NetMessage.Send*", _framework.CecilAssemblies)
    .Run()
    .Hook()
;

// hooking a single method
// this generates PreAddShop & PostAddShop hooks in ModFramework.ModHooks.Chest
// which can be used in external API consumers
new Query("Terraria.Chest.AddShop(Terraria.Item)", _framework.CecilAssemblies)
    .Run()
    .Hook()
;
 
Last edited:
To give some more info about TShock's involvement: we're working on the next generation of TShock (TShock 5) which will run on our middleware (Orion). In the future we will drop support for our own server modding API and move onto the Open Terraria API (OTAPI) fully.

For any non-modders out there, I'd suggest simply downloading the server executable and running it in place of the vanilla terraria server. If you run it without plugins then it works the same as the vanilla server however OTAPI has a greatly reduced memory footprint and has been proven to run on Mono.

It should also be noted that the client mod does not bypass steam and should be perfectly legal to use.
 
Is there any good place to contact you, DeathCradle? Like Steam or Skype? I have a few questions about this API.
 
Status
Not open for further replies.
Back
Top Bottom