Skip to content

Implementation of Dedicated Server in Isolation#498

Open
kuwacom wants to merge 7 commits intosmartcmd:mainfrom
kuwacom:feature/dedicated-server
Open

Implementation of Dedicated Server in Isolation#498
kuwacom wants to merge 7 commits intosmartcmd:mainfrom
kuwacom:feature/dedicated-server

Conversation

@kuwacom
Copy link
Contributor

@kuwacom kuwacom commented Mar 4, 2026

Description

This PR introduces a Windows64 Dedicated Server executable (Minecraft.Server) and related runtime/build support.
It enables headless hosting with configurable bind IP/port, world bootstrap via server.properties.
Minecraft.Client changes are intentionally minimal and limited to dedicated-server startup compatibility.
#65

image

Changes

New Behavior

  • Added dedicated server entrypoint and project:
    • Minecraft.Server/Windows64/ServerMain.cpp
    • Minecraft.Server/Minecraft.Server.vcxproj (+ filters)
  • Added dedicated-server runtime modules:
    • ServerProperties (server.properties load/normalize/save for level-name / level-id)
    • WorldManager (load existing world by level-id, fallback to create new world)
    • ServerLogger (log levels: debug|info|warn|error)
  • Added build/runtime wiring:
    • CMakeLists.txt: new MinecraftServer target and post-build asset copy
    • cmake/CopyServerAssets.cmake: minimal required server assets only
    • MinecraftConsoles.sln, COMPILE.md, .gitignore updates
  • Dedicated server launch supports:
    • -port, -ip/-bind, -name, -seed, -loglevel, -help

Minecraft.Client Changes (Minimum Scope)

Only the following Minecraft.Client files were changed, strictly for dedicated-server bridge behavior:

  1. Minecraft.Client/MinecraftServer.h

    • Added NetworkGameInitData::dedicatedNoLocalHostPlayer.
  2. Minecraft.Client/Common/Network/GameNetworkManager.cpp

    • Added dedicated path to skip local host ClientConnection creation when hosting as dedicated server.
    • Preserved telemetry/game-mode initialization for host path.
  3. Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp

    • Switched host startup to use configured bind IP/port globals.
    • Calls new Winsock overload with bind IP.
  4. Minecraft.Client/Windows64/Network/WinsockNetLayer.h

    • Added HostGame(const char* bindIp, int port) overload.
  5. Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp

    • Implemented bind-IP-aware host socket setup.
    • Kept existing HostGame(int port) as wrapper for compatibility.
    • Updated default Win64 host bind IP to 0.0.0.0 (from loopback) for dedicated listening.

kuwacom added 4 commits March 4, 2026 18:12
- Introduced `ServerMain.cpp` for the dedicated server logic, handling command-line arguments, server initialization, and network management.
- Created `postbuild_server.ps1` script for post-build tasks, including copying necessary resources and DLLs for the dedicated server.
- Added `CopyServerAssets.cmake` to manage the copying of server assets during the build process, ensuring required files are available for the dedicated server.
- Defined project filters in `Minecraft.Server.vcxproj.filters` for better organization of server-related files.
- Introduced ServerLogger for logging startup steps and world I/O operations.
- Implemented ServerProperties for loading and saving server configuration from `server.properties`.
- Added WorldManager to handle world loading and creation based on server properties.
- Updated ServerMain to integrate server properties loading and world management.
- Enhanced project files to include new source and header files for the server components.
@kuwacom
Copy link
Contributor Author

kuwacom commented Mar 4, 2026

I hadn’t been merging upstream changes while implementing, so I’m in the middle of merging them now...

# Conflicts:
#	Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp
#	Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp
#	Minecraft.Client/Windows64/Network/WinsockNetLayer.h
@gizmogoat
Copy link

gizmogoat commented Mar 4, 2026

Some things have changed in the past day-ish, watch out for incompatibilities/redundant re-implementations of these:

@kuwacom
Copy link
Contributor Author

kuwacom commented Mar 4, 2026

So -server has been added, I see.
From a quick look at the issues, it seems there are still a few world-related bugs remaining.

servers.txt is a nice addition as well.
It’s more user-friendly than -target.

kuwacom added 2 commits March 5, 2026 09:38
Since 31881af56936aeef38ff322b975fd0 , `skinHud.swf` for 720 is not included in `MediaWindows64.arc`,
the app crashes unless the virtual screen is set to HD.
@kuwacom
Copy link
Contributor Author

kuwacom commented Mar 5, 2026

It was partially affected by #495, but I was able to merge it without any issues.

@haychk
Copy link

haychk commented Mar 5, 2026

is it still only LAN multiplayer only? or can worlds be opened up to more people?

@kuwacom
Copy link
Contributor Author

kuwacom commented Mar 5, 2026

It can be accessed from anywhere if you have a suitable network that can be accessed from the global internet (a network line that can open the specified TCP port).

In short, it's a regular server app.

@haychk
Copy link

haychk commented Mar 5, 2026

oh damn. so i could run this on a vps?

@kuwacom
Copy link
Contributor Author

kuwacom commented Mar 5, 2026

Yes, but since it still uses a lot of Windows API internally (to maintain compatibility), it requires a Windows system or a system that includes Windows API to run.

I would like to eventually release a Linux version and put it into Docker.

@haychk
Copy link

haychk commented Mar 5, 2026

i mean, i've tried it on linux and it works fine. i could try and create a docker image if you'd like

@gizmogoat
Copy link

I would like to eventually release a Linux version and put it into Docker.

You can run it fine on Linux without a GUI launcher via umu

@kuwacom
Copy link
Contributor Author

kuwacom commented Mar 5, 2026

i mean, i've tried it on linux and it works fine. i could try and create a docker image if you'd like

seriously!
That's nice.

@haychk
Copy link

haychk commented Mar 5, 2026

wine also works really well. tried lutris and has similar results to umu

@kuwacom
Copy link
Contributor Author

kuwacom commented Mar 5, 2026

Which one has a smaller image size?
wine or umu

@haychk
Copy link

haychk commented Mar 5, 2026

wine iirc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants