Will It Host? / Visual Studio Code

Can you run a Minecraft server in VS Code?

It hosted#16 of 18 by difficulty

Yes. The process listening on port 25565 is Code, and a vanilla Minecraft client connects to it and plays on it. The world is a file. Place a block and a line writes itself, delete a line and the block vanishes, which turns every editor feature you already have into a world editing tool, because all of them are just text edits.

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

How it works

A VS Code extension. The extension host is a Node process inside Code, so net.createServer binds the port as Code itself. Two halves that never talk to each other, both talking to a Map: block placements append lines, and onDidChangeTextDocument parses the whole document with one regex, diffs it against the previous Map and sends what moved as block changes. Find and replace, undo, copy and paste, sort lines and snippets all edit the world, because VS Code has no idea what a block is.

The part that nearly stopped it

The echo. Placing a block in Minecraft writes a line, which fires the change event, which would send the block straight back to the client that had just placed it.

What got it over the line

An applying flag that suppresses the outbound diff while the extension is the one writing, with the Map updated to match so the next diff comes out empty regardless. Edits are debounced at 60ms as well, so a 382-line structure snippet is one diff.

What it cannot do

Minecraft 1.8.9, the same target as the rest of the series, and a 5x5 chunk world three sections tall. No entities, no chat commands, no second player and no saving.

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 Visual Studio Code 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 VS Code run a Minecraft server?

Yes. VS Code extensions run in a Node process inside Code, so an extension can call net.createServer and listen on port 25565 as the editor itself. No dependencies, no build step and no npm install: clone the repo, press F5 and run Minecraft: Start Server. The full source is on GitHub.

What does editing the file actually do?

Everything you would hope. Find and replace turns every stone block into glowstone across the world, undo reverts a 382-block structure in one keystroke, and multi-cursor editing moves forty blocks at once. The file is one line per block, block name then at then the coordinates, and lines that do not match are ignored so you can leave notes among them.

The rest of the series

See the full Will It Host? board β†’

Or just host it properly

Visual Studio Code 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.