Will It Host? / Terraria

Can you run a Minecraft server in Terraria?

It hosted#13 of 18 by difficulty

Yes. The process listening on port 25565 is Terraria, and a vanilla Minecraft client connects to it and plays on it. It runs both ways: place a block in Minecraft and a tile appears in Terraria at the matching spot, mine a tile in Terraria and the block disappears in Minecraft. Two worlds, one 3D and one 2D, editing each other in real time.

verdict
It hosted
A vanilla Minecraft client connected and played on it.
difficulty
#13 of 18
Ranked against everything else in the series, hardest first.
built withC#
protocolMinecraft 1.8.9
read the source on github β†’

How it works

A tModLoader mod, which is a C# assembly loaded into Terraria's own process, so System.Net.Sockets gives you a TCP server. Terraria's world state is not thread-safe, so the socket thread only pushes events onto a ConcurrentQueue and PostUpdateWorld drains it on the game thread where touching Main.tile is safe. Every sixth tick the mod walks the mapped region, compares HasTile and TileType against the previous pass, and sends anything that changed as a block change.

The part that nearly stopped it

Deciding which dimension to throw away. Minecraft has three and Terraria has two, and the tile grid runs the opposite way as well, because Terraria's Y axis grows downward, which is what makes a world build itself upside down until you invert it.

What got it over the line

Keeping X and Y and ignoring Z, so a wall mirrors almost perfectly. Terraria does not know Z exists and never gets told.

What it cannot do

Minecraft 1.8.9, the same target as the rest of the series. Depth is flattened, so blocks at different depths land on the same tile and tiles mirrored back always arrive at Z zero. Only a window of roughly 80 by 40 around your Terraria player is mirrored, and Terraria's own tile updates are not filtered, so grass spreading or sand falling gets sent to Minecraft like any other change.

Why this is possible at all

A Minecraft Java server is a smaller thing than its reputation suggests. It is a socket, a packet codec and a game loop. The client opens one TCP connection, sends a handshake naming its protocol version, moves through login into the play state, and from then on both sides exchange length-prefixed packets describing chunks, entities and movement. None of that needs a game engine. It needs something that can hold a socket open and put the right bytes on it in the right order, which is why Terraria can be made to do it. In every episode the host is the hard part.

Every build in this series targets Minecraft 1.8.9 for one specific reason. In 1.8 a chunk is a flat byte array you can send uncompressed. From 1.9 onward chunk data is palette-encoded into bit-packed longs and the connection expects zlib, which is not something you can hand-write in VBA. 1.8.9 is the last release where the whole protocol is within reach of a scripting runtime that was never meant for it.

We have written both halves of that up properly: how the Minecraft server protocol works covers the wire format, and what a Minecraft server actually needs to run covers the four things a real one cannot do without.

Questions

Can Terraria run a Minecraft server?

Yes, through tModLoader. Mods are C# assemblies loaded into Terraria's process, so a mod can open a TCP listener on port 25565 and speak the Minecraft protocol from inside the game. Build it in the Develop Mods menu and start it with /mcstart in chat. The full source is on GitHub.

Was C# easier than the earlier builds?

Much. C# has sockets, BitConverter, ConcurrentQueue and real byte arrays, so nothing had to be faked, where VBA has no unsigned right shift and no way to see the bytes of a double, and VLC's Lua 5.1 has no string.pack at all. The work moved from the encoding to the design.

The rest of the series

See the full Will It Host? board β†’

Or just host it properly

Terraria is not where your survival world should live. AMD Ryzen 9700X, hard-reserved RAM, NVMe, online in under a minute with a free address, DDoS protection and a 7-day money-back guarantee.