Skip to content

Repository files navigation

⛏️ MinecraftServerCore

A Minecraft: Java Edition server core written from scratch in C++ — raw sockets, hand-rolled protocol, no reference code.

C++ Minecraft CMake Platform Status

⚠️ 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.

✨ Features

  • 🤝 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 Buffer class 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.log via plog

🛠️ Tech stack

  • 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, sockets and the author's engine (filesystem / network helpers)

🔨 Building

Requirements: CMake ≥ 3.25 and a C++20 MSVC toolchain. The server is Windows-only (Winsock).

Note: CMakeLists.txt pulls several dependencies from a local directory (LIBRARIES_PATH, E:/Projects/libraries by default): plog, zlib, nbt, bson, b64, sockets and the author's engine sources. These are not vendored in this repository, so you must provide them and point LIBRARIES_PATH at their location before configuring.

git clone https://github.com/kewldan/MinecraftServerCore.git
cd MinecraftServerCore

cmake -B build -S . -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release

The executable is emitted into the repository root (MinecraftCore.exe). Run it from there so it can find registry-codec.nbt and favicon.png, then point a Minecraft 1.19.4 client at localhost:25565.

About

Minecraft server backend implementation from scratch WIP

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages