A Minecraft: Java Edition server core written from scratch in C++ — raw sockets, hand-rolled protocol, no reference code.
⚠️ Work in progress. This is a protocol experiment, not a playable server. It currently gets a vanilla 1.19.4 client through the server list and the beginning of the login flow — world, chunks and gameplay are not implemented.
- 🤝 Handshake state machine — parses the handshake packet (protocol version, address, next state) exactly like the vanilla protocol defines it
- 📋 Server list status — responds to status requests with JSON: version, player counts, MOTD description and a base64-encoded
favicon.png - 🏓 Ping / pong — echoes the client's ping payload so latency shows up in the server list
- 🔑 Login start handling — reads the player nickname and UUID, logs the UUID in canonical form, and answers with a Login Success packet
- 🌍 Login (play) packet — sends the Join Game packet including the full registry codec (
registry-codec.nbt), dimension list, view/simulation distance and respawn flags - 🔢 VarInt codec & packet buffer — custom
Bufferclass for writing VarInts, strings, arrays, longs and booleans into outgoing packets - 🧵 Threaded architecture — a listener thread accepts TCP connections, each connection reads packets on its own thread, and a 50 ms tick loop runs separately
- 🖥️ Console commands — minimal REPL on stdin (
exit, ...) - 📜 Logging — colored console output plus a rolling
latest.logvia plog
- Winsock2 (
Ws2_32) — raw TCP sockets - nlohmann/json — status response JSON
- plog — logging
- zlib — compression (linked statically)
- Base64 — favicon encoding
- Custom local libraries:
nbt,bson,socketsand the author'sengine(filesystem / network helpers)
Requirements: CMake ≥ 3.25, a C++20 MSVC toolchain and vcpkg. The server is Windows-only (Winsock).
Dependencies (plog, zlib, nlohmann-json, aklomp-base64 and the libraries needed by the author's Engine) are declared in vcpkg.json and resolved automatically through the vcpkg toolchain. The Engine sources are taken from the ENGINE_DIR cache variable (default: ../Engine next to this repository) or fetched from GitHub when that directory does not exist.
git clone https://github.com/kewldan/MinecraftServerCore.git
cd MinecraftServerCore
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release `
-DCMAKE_TOOLCHAIN_FILE=<vcpkg>/scripts/buildsystems/vcpkg.cmake `
-DVCPKG_TARGET_TRIPLET=x64-windows
cmake --build buildThe executable is emitted into build/ together with copies of server.ini, favicon.png and registry-codec.nbt (the server reads them from its working directory). Run it and point a Minecraft 1.19.4 client at localhost:25565. Port, player limit and MOTD are configured in server.ini (server.port, server.players, server.description); type exit in the console to stop the server.