This is the Terraria Server API, the API that TShock for Terraria runs on.
- Hooks for the most used events & calls used by Terraria.
- Runs plugins from the ServerPlugins folder.
- Direct access to all methods inside Terraria Server itself.
Fork is now over at https://github.com/NyxStudios/TerrariaAPI-Server
Home Page: https://tshock.co
This is the Terraria Server API, the API that TShock for Terraria runs on.
add more language interface, help more player enjoy tshock.
Currently if you start a server without a input stream/the input stream EOFs (/dev/null for example), the server will create a .crash file which leads to an "unsaveable" world.
This is because there's no null check on text
here.
Sorry there's no PR attached, but it was already pretty messy to get a build system and to get to the cause of that crash.
The -ip startup flag is missing from the API. It was implemented here originally.
We never released 1,13 so I am assuming we are planning to release 1,13 when weve updated to the newest Terraria version.
The fancy api is ticked to 1,14 assuming we would release 1,13 prior to integrating so this issue is here to determine where we go.
seems to be an issue with how assemblies are loaded and whatnot. I will investigate it tomorrow sometime, but if someone else has any ideas...
I have look up the code and i think the worldgen.cs is missing this one?
public static void paintEffect(int x, int y, byte color, byte oldColor)
{
int color2 = (int)(color ?? oldColor); <------ I am not sure how to fix this
Color newColor = WorldGen.paintColor(color2);
for (int i = 0; i < 10; i++)
{
int num = Dust.NewDust(new Vector2((float)(x * 16), (float)(y * 16)), 16, 16, 143, 0f, 0f, 50, newColor, 1f);
if (Main.rand.Next(2) == 0)
{
Main.dust[num].noGravity = true;
Main.dust[num].scale *= 1.2f;
}
else
{
Main.dust[num].scale *= 0.5f;
}
}
}
For example, there are 2001 Dust instances and 501 Gore instances, and each instance in their arrays is created. We should remove stuff like this to decrease memory usage.
Because 1.2 will probably force pretty much any plugin to upgrade, this would be a good opportunity to do have some major upgrades of the server api.
I would like to suggest a revamp of the current hook system, I think the best way to express my thoughts is by showing you a prototype implementation of it.
(Imagine all hooks to be defined by the HookManager class in the same way as the NetGetData is implemented. Could also use partial classes if this becomes too messy.)
This is how a plugin would then register a handler:
PluginAPI.Hooks.NetGetData.Register(this, this.Net_GetData, 10);
This implementation would have the following advantages:
The only downside I see of this implementation is that the invoking of hooks eats a bit more performance than the old system, considering my (very vague) performance testing on this maybe a few nanosecs more per hook invoke within an average system.
We have a hook for StrinkeNPC but it is never invoked, nor was it in 1.1.2. I am quite confused. Is there a reason why we dont use it?
The merge with 1.2.4 broke the boot process under mono. Seems that Terraria / ProgramServer.cs is setting the process priority immediately now on line 13, which is a root-only function call under mono. Commenting out lines 12 and 13 solve this problem and at least get the server booting.
Tiles still don't load up on the client, but that's beyond the scope of this issue (good luck with that!)
I am making a TShock plugin and I am using the NPCSpawn hook. I can correctly get the NPC, but it's position (x,y) is always (0,0). Is this a bug or intended?
public override void Initialize()
{
.....
ServerApi.Hooks.NpcSpawn.Register(this, OnNpcSpawn, 5);
....
}
....
public void OnNpcSpawn(NpcSpawnEventArgs args)
{
NPC npc= args.Npc;
Log.ConsoleInfo("NPC " + npc.type + " Spawned at " + npc.position.X + ", " + npc.position.Y);
}
NPC 61 Spawned at 0, 0
NPC 69 Spawned at 0, 0
[Server API] Error System.AggregateException
---> System.ObjectDisposedException
at System.IO.__Error.StreamIsClosed()
at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.BinaryWriter.Write(Int16 value)
at Terraria.NetMessage.SendData(Int32 msgType, Int32 remoteClient, Int32 ignoreClient, String text, Int32 number, Single number2, Single number3, Single number4, Int32 number5)
at Terraria.NetMessage.syncJoin(Int32 plr)
at Terraria.MessageBuffer.<GetData>m__17()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
---> (Internal Exception #0) System.ObjectDisposedException
at System.IO.__Error.StreamIsClosed()
at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.BinaryWriter.Write(Int16 value)
at Terraria.NetMessage.SendData(Int32 msgType, Int32 remoteClient, Int32 ignoreClient, String text, Int32 number, Single number2, Single number3, Single number4, Int32 number5)
at Terraria.NetMessage.syncJoin(Int32 plr)
at Terraria.MessageBuffer.<GetData>m__17()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()<---
We have bamboo now, remove this so @Deathmax stops getting mentioned to hell.
Thanks!
Hey everyone. Awesome project, but one question.. can I contribute?
Just saw some messy code and want to know if I could fix it up in my spare time.
Regular socket BeginRead/Write does not work properly on Mono for Terraria. As a result, synchronous methods are used and gameplay is jerky.
In some unknown circumstances, NetMessage.SendBytes will wait forever to do it's async write to a socket - possibly a deadlock situation in which BeginWrite is just waiting for a place in the thread pool.
When this happens, the server can no longer send data, and must be restarted.
There is more information about the issue in this discussion
http://tshock.co/xf/index.php?threads/server-freezing-problem.1085/
New item in last update, the changes in Lang.cs are missing, something like tshock can't find the item.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.