Will It Host? / Minecraft

Can you run a Minecraft server inside Minecraft?

It hosted#21 of 21 by difficulty

Yes, and more than one. A Fabric mod makes a 1.21.1 world take connections like a real server, puts a live 1:4 scale model of it on a table you can reach in to, and turns any sign reading [server] in to a whole extra server for as long as it is powered. The redstone signal strength is the player cap. Every port belongs to the one Minecraft process.

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

How it works

The mod accepts the connection and speaks handshake, status, login and configuration itself using the game's own packet codecs, then hands the socket to a connection object the server treats as its own. From the play phase on, vanilla code runs the player, which is why nothing about gameplay had to be written. A powered Server Sign boots a second MinecraftServer inside the process the way Mojang's own in-process test server is built, with its own thread, save folder, world and Netty listener.

The part that nearly stopped it

Being the one host that already is a server. Every other episode is about persuading a program to hold a socket, and Minecraft does that for a living, so hosting one inside it proves nothing on its own. The work had to go somewhere the protocol was not.

What got it over the line

Making the servers things in the world. The table is a void dimension the mod fills cell by cell from block change events on whichever server it is showing, and ops standing over it can pick a player up and put them down somewhere else, kick one with a stick, fill a 4x4x4 region of the real world by placing a block, or lock a column by powering its cell. It is a normal world, so tripwire across your base's cells fires when someone walks in to it on the real server. Server Signs make the rest redstone: a comparator reads the player count, the text glows green while the server is up, and cutting the power tells everyone on it "Server powered down".

What it cannot do

Minecraft 1.21.1, the one episode that is not on 1.8.9, because this host ships the codecs already. No authentication on any door, so anyone who can reach the port joins under any name. Only ops can touch the real world from the table. Signs nest one level deep, so a Server Sign inside a Server Sign's world does nothing. Nothing listens at the main menu.

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 Minecraft can be made to do it. In every episode the host is the hard part.

Almost every build in this series targets Minecraft 1.8.9, because in 1.8 a chunk is a flat byte array you can send uncompressed, where from 1.9 onward chunk data is palette-encoded into bit-packed longs and the connection expects zlib. This one runs on 1.21.1 instead. Minecraft ships those codecs already, so there was nothing left to hand-write and no reason to go back.

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

What is the point of a Minecraft server inside Minecraft?

The hosting is the boring half, so this one is about what a server can be once it is an object in a world. A sign is a server rack, a lever is its power switch, a comparator reads its player count, and the table is a model of the whole thing you can pick players up off. It is also the only episode where survival, mobs, chests, redstone and the Nether all work, because vanilla code is running the players.

Why is this one on 1.21.1 when the rest are on 1.8.9?

Because the reason for 1.8.9 does not apply here. The rest of the series targets it because 1.8 chunk data is a flat byte array you can write by hand, where modern versions are palette-encoded, bit-packed and expect zlib. This host already has those codecs, so there is nothing to hand-write and no reason to go back.

The rest of the series

See the full Will It Host? board β†’

Or just host it properly

Minecraft 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.