Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
e4c8229
add: Dedicated Server implementation
kuwacom Mar 4, 2026
eb75a93
Merge branch 'main' into feature/dedicated-server
kuwacom Mar 4, 2026
6d44e40
add: refactor world loader & add server properties
kuwacom Mar 4, 2026
1d9dccb
update: implement enhanced logging functionality with configurable lo…
kuwacom Mar 4, 2026
7137c44
Merge remote-tracking branch 'origin/main' into feature/dedicated-server
kuwacom Mar 4, 2026
965676f
update: update keyboard and mouse input initialization 1dc8a005ed1114…
kuwacom Mar 5, 2026
7cb4178
fix: change virtual screen resolution to 1920x1080(HD)
kuwacom Mar 5, 2026
0068ed5
Merge remote-tracking branch 'upstream/main' into feature/dedicated-s…
kuwacom Mar 6, 2026
b4eb98e
fix: dedicated server build settings for miniaudio migration and miss…
kuwacom Mar 6, 2026
392dfda
update: changed the virtual screen to 720p
kuwacom Mar 6, 2026
dd779e7
Merge branch 'smartcmd:main' into feature/dedicated-server
kuwacom Mar 6, 2026
06bff53
add: add Docker support for Dedicated Server
kuwacom Mar 6, 2026
e7f12e7
Merge branch 'feature/dedicated-server' of github.com:kuwacom/Minecra…
kuwacom Mar 6, 2026
b8d6289
fix: add initial save for newly created worlds in dedicated server
kuwacom Mar 6, 2026
31bfb7e
update: add basically all configuration options that are implemented …
kuwacom Mar 6, 2026
9e4052e
update: add LAN advertising configuration for server.properties
kuwacom Mar 7, 2026
965a859
add: add implementing interactive command line using linenoise
kuwacom Mar 7, 2026
5f118ca
update: enhance command line completion with predictive hints
kuwacom Mar 7, 2026
fa09e28
add: implement `StringUtils` for string manipulation and refactor usages
kuwacom Mar 7, 2026
4bb1829
fix: send DisconnectPacket on shutdown and fix Win64 recv-thread tear…
kuwacom Mar 7, 2026
dd10c25
fix: return client to menus when Win64 host connection drops
kuwacom Mar 7, 2026
83063f4
Merge origin/main into feature/dedicated-server
kuwacom Mar 7, 2026
35f81c6
update: converted Japanese comments to English
kuwacom Mar 7, 2026
891052e
add: create `Minecraft.Server` developer guide in English and Japanese
kuwacom Mar 7, 2026
71cd0d3
update: add note about issue
kuwacom Mar 7, 2026
49f41b8
add: add `nlohmann/json` json lib
kuwacom Mar 7, 2026
da284c1
add: add FileUtils
kuwacom Mar 8, 2026
b535baa
add: Dedicated Server BAN access manager with persistent player and I…
kuwacom Mar 8, 2026
c91efe0
update: changed file read/write operations to use `FileUtils`.
kuwacom Mar 8, 2026
b250be7
fix: Re-added the source that had somehow disappeared.
kuwacom Mar 8, 2026
71fd1e3
add: significantly improved the dedicated server logging system
kuwacom Mar 8, 2026
dca2a73
Merge origin/main into feature/dedicated-server
kuwacom Mar 8, 2026
842ffe2
fix: added the updated library source
kuwacom Mar 8, 2026
8b68b81
add: add `ban` and `pardon` commands for Player and IP
kuwacom Mar 8, 2026
590241c
fix: fix stop command shutdown process
kuwacom Mar 8, 2026
2979755
fix: fixed the save logic during server shutdown
kuwacom Mar 8, 2026
ed5bf4d
update: added new sever files to Docker entrypoint
kuwacom Mar 8, 2026
aa66924
fix: replace shutdown flag with atomic variable for thread safety
kuwacom Mar 8, 2026
b31e5ce
update: update Dedicated Server developer guide
kuwacom Mar 8, 2026
4ad8247
update: check for the existence of `GameHDD` and create
kuwacom Mar 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,12 @@ Minecraft.World/x64_Debug/
Minecraft.World/Release/
Minecraft.World/x64_Release/

Minecraft.Server/x64/
Minecraft.Server/Debug/
Minecraft.Server/x64_Debug/
Minecraft.Server/Release/
Minecraft.Server/x64_Release/

build/*

# Existing build output files
Expand All @@ -434,6 +440,9 @@ build/*
# Local saves
Minecraft.Client/Saves/

tmp*/
_server_asset_probe/
server-data/
# Visual Studio Per-User Config
*.user
/out
87 changes: 86 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,82 @@ target_link_libraries(MinecraftClient PRIVATE
>
)

set(MINECRAFT_SERVER_SOURCES ${MINECRAFT_CLIENT_SOURCES})
list(APPEND MINECRAFT_SERVER_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Windows64/ServerMain.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Access/Access.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Access/BanManager.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Console/ServerCli.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Console/ServerCliInput.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Console/ServerCliParser.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Console/ServerCliEngine.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Console/ServerCliRegistry.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Console/commands/CliCommandBan.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Console/commands/CliCommandBanIp.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Console/commands/CliCommandBanList.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Console/commands/CliCommandHelp.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Console/commands/CliCommandPardon.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Console/commands/CliCommandPardonIp.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Console/commands/CliCommandStop.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Console/commands/CliCommandList.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Console/commands/CliCommandTp.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Console/commands/CliCommandGamemode.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Common/FileUtils.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Common/StringUtils.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/ServerLogger.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/ServerLogManager.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/ServerProperties.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/vendor/linenoise/linenoise.c"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/WorldManager.cpp"
)

add_executable(MinecraftServer ${MINECRAFT_SERVER_SOURCES})
target_include_directories(MinecraftServer PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/Iggy/include"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Xbox/Sentient/Include"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.World/x64headers"
"${CMAKE_CURRENT_SOURCE_DIR}/include/"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Server/Windows64"
)
target_compile_definitions(MinecraftServer PRIVATE
$<$<CONFIG:Debug>:_LARGE_WORLDS;_DEBUG_MENUS_ENABLED;_DEBUG;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_WINDOWS64;MINECRAFT_SERVER_BUILD>
$<$<NOT:$<CONFIG:Debug>>:_LARGE_WORLDS;_DEBUG_MENUS_ENABLED;_CRT_NON_CONFORMING_SWPRINTFS;_CRT_SECURE_NO_WARNINGS;_WINDOWS64;MINECRAFT_SERVER_BUILD>
)
if(MSVC)
configure_msvc_target(MinecraftServer)
target_link_options(MinecraftServer PRIVATE
$<$<CONFIG:Release>:/LTCG /INCREMENTAL:NO>
)
endif()

set_target_properties(MinecraftServer PROPERTIES
OUTPUT_NAME "Minecraft.Server"
VS_DEBUGGER_WORKING_DIRECTORY "$<TARGET_FILE_DIR:MinecraftServer>"
VS_DEBUGGER_COMMAND_ARGUMENTS "-port 25565 -bind 0.0.0.0 -name DedicatedServer"
)

target_link_libraries(MinecraftServer PRIVATE
MinecraftWorld
d3d11
XInput9_1_0
wsock32
legacy_stdio_definitions
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/Iggy/lib/iggy_w64.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/Iggy/lib/iggyperfmon_w64.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/Iggy/lib/iggyexpruntime_w64.lib"
$<$<CONFIG:Debug>:
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Input_d.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Storage_d.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Render_PC_d.lib"
>
$<$<NOT:$<CONFIG:Debug>>:
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Input.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Storage.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/Minecraft.Client/Windows64/4JLibs/libs/4J_Render_PC.lib"
>
)

if(CMAKE_HOST_WIN32)
message(STATUS "Starting redist copy...")
execute_process(
Expand Down Expand Up @@ -147,4 +223,13 @@ else()
message(FATAL_ERROR "Redist and asset copying is only supported on Windows (Robocopy) and Unix systems (rsync).")
endif()

set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT MinecraftClient)
add_custom_command(TARGET MinecraftServer POST_BUILD
COMMAND "${CMAKE_COMMAND}"
-DPROJECT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
-DOUTPUT_DIR="$<TARGET_FILE_DIR:MinecraftServer>"
-DCONFIGURATION=$<CONFIG>
-P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CopyServerAssets.cmake"
VERBATIM
)

set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT MinecraftServer)
34 changes: 33 additions & 1 deletion COMPILE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
## Visual Studio (`.sln`)

1. Open `MinecraftConsoles.sln` in Visual Studio 2022.
2. Set `Minecraft.Client` as the Startup Project.
2. Set Startup Project:
- Client: `Minecraft.Client`
- Dedicated server: `Minecraft.Server`
3. Select configuration:
- `Debug` (recommended), or
- `Release`
Expand All @@ -12,6 +14,17 @@
- `Build > Build Solution` (or `Ctrl+Shift+B`)
- Start debugging with `F5`.

### Dedicated server debug arguments

- Default debugger arguments for `Minecraft.Server`:
- `-port 25565 -bind 0.0.0.0 -name DedicatedServer`
- You can override arguments in:
- `Project Properties > Debugging > Command Arguments`
- `Minecraft.Server` post-build copies only the dedicated-server asset set:
- `Common/Media/MediaWindows64.arc`
- `Common/res`
- `Windows64/GameHDD`

## CMake (Windows x64)

Configure (use your VS Community instance explicitly):
Expand All @@ -32,13 +45,32 @@ Build Release:
cmake --build build --config Release --target MinecraftClient
```

Build Dedicated Server (Debug):

```powershell
cmake --build build --config Debug --target MinecraftServer
```

Build Dedicated Server (Release):

```powershell
cmake --build build --config Release --target MinecraftServer
```

Run executable:

```powershell
cd .\build\Debug
.\MinecraftClient.exe
```

Run dedicated server:

```powershell
cd .\build\Debug
.\Minecraft.Server.exe -port 25565 -bind 0.0.0.0 -name DedicatedServer
```

Notes:
- The CMake build is Windows-only and x64-only.
- Contributors on macOS or Linux need a Windows machine or VM to build the project. Running the game via Wine is separate from having a supported build environment.
Expand Down
36 changes: 23 additions & 13 deletions Minecraft.Client/Common/Console_Utils.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
#include "stdafx.h"
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
#include "..\..\Minecraft.Server\ServerLogManager.h"
#endif

//--------------------------------------------------------------------------------------
// Name: DebugSpewV()
// Desc: Internal helper function
//--------------------------------------------------------------------------------------
#ifndef _CONTENT_PACKAGE
static VOID DebugSpewV( const CHAR* strFormat, const va_list pArgList )
static VOID DebugSpewV( const CHAR* strFormat, va_list pArgList )
{
#if defined __PS3__ || defined __ORBIS__ || defined __PSVITA__
assert(0);
assert(0);
#else
CHAR str[2048];
// Use the secure CRT to avoid buffer overruns. Specify a count of
// _TRUNCATE so that too long strings will be silently truncated
// rather than triggering an error.
_vsnprintf_s( str, _TRUNCATE, strFormat, pArgList );
OutputDebugStringA( str );
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
// Dedicated server routes legacy debug spew through ServerLogger to preserve CLI prompt handling.
if (ServerRuntime::ServerLogManager::ShouldForwardClientDebugLogs())
{
ServerRuntime::ServerLogManager::ForwardClientDebugSpewLogV(strFormat, pArgList);
return;
}
#endif
CHAR str[2048];
// Use the secure CRT to avoid buffer overruns. Specify a count of
// _TRUNCATE so that too long strings will be silently truncated
// rather than triggering an error.
_vsnprintf_s( str, _TRUNCATE, strFormat, pArgList );
OutputDebugStringA( str );
#endif
}
#endif
Expand All @@ -31,10 +42,9 @@ VOID CDECL DebugPrintf( const CHAR* strFormat, ... )
#endif
{
#ifndef _CONTENT_PACKAGE
va_list pArgList;
va_start( pArgList, strFormat );
DebugSpewV( strFormat, pArgList );
va_end( pArgList );
va_list pArgList;
va_start( pArgList, strFormat );
DebugSpewV( strFormat, pArgList );
va_end( pArgList );
#endif
}

117 changes: 69 additions & 48 deletions Minecraft.Client/Common/Consoles_App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
#include "GameRules\ConsoleSchematicFile.h"
#include "..\User.h"
#include "..\..\Minecraft.World\LevelData.h"
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
#include "..\..\Minecraft.Server\ServerLogManager.h"
#endif
#include "..\..\Minecraft.World\net.minecraft.world.entity.player.h"
#include "..\EntityRenderDispatcher.h"
#include "..\..\Minecraft.World\compression.h"
Expand Down Expand Up @@ -240,66 +243,84 @@ void CMinecraftApp::DebugPrintf(const char *szFormat, ...)
{

#ifndef _FINAL_BUILD
char buf[1024];
va_list ap;
va_start(ap, szFormat);
vsnprintf(buf, sizeof(buf), szFormat, ap);
va_end(ap);
OutputDebugStringA(buf);
va_list ap;
va_start(ap, szFormat);
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
// Dedicated server routes client debug spew through ServerLogger so CLI output stays prompt-safe.
if (ServerRuntime::ServerLogManager::ShouldForwardClientDebugLogs())
{
ServerRuntime::ServerLogManager::ForwardClientAppDebugLogV(szFormat, ap);
va_end(ap);
return;
}
#endif
char buf[1024];
vsnprintf(buf, sizeof(buf), szFormat, ap);
va_end(ap);
OutputDebugStringA(buf);
#endif

}

void CMinecraftApp::DebugPrintf(int user, const char *szFormat, ...)
{
#ifndef _FINAL_BUILD
if(user == USER_NONE)
return;
char buf[1024];
va_list ap;
va_start(ap, szFormat);
vsnprintf(buf, sizeof(buf), szFormat, ap);
va_end(ap);
if(user == USER_NONE)
return;
va_list ap;
va_start(ap, szFormat);
#if defined(_WINDOWS64) && defined(MINECRAFT_SERVER_BUILD)
// Dedicated server routes client debug spew through ServerLogger so CLI output stays prompt-safe.
if (ServerRuntime::ServerLogManager::ShouldForwardClientDebugLogs())
{
ServerRuntime::ServerLogManager::ForwardClientUserDebugLogV(user, szFormat, ap);
va_end(ap);
return;
}
#endif
char buf[1024];
vsnprintf(buf, sizeof(buf), szFormat, ap);
va_end(ap);
#ifdef __PS3__
unsigned int writelen;
sys_tty_write(SYS_TTYP_USER1 + ( user - 1 ), buf, strlen(buf), &writelen );
unsigned int writelen;
sys_tty_write(SYS_TTYP_USER1 + ( user - 1 ), buf, strlen(buf), &writelen );
#elif defined __PSVITA__
switch(user)
{
case 0:
{
SceUID tty2 = sceIoOpen("tty2:", SCE_O_WRONLY, 0);
if(tty2>=0)
{
std::string string1(buf);
sceIoWrite(tty2, string1.c_str(), string1.length());
sceIoClose(tty2);
}
}
break;
case 1:
{
SceUID tty3 = sceIoOpen("tty3:", SCE_O_WRONLY, 0);
if(tty3>=0)
{
std::string string1(buf);
sceIoWrite(tty3, string1.c_str(), string1.length());
sceIoClose(tty3);
}
}
break;
default:
OutputDebugStringA(buf);
break;
}
switch(user)
{
case 0:
{
SceUID tty2 = sceIoOpen("tty2:", SCE_O_WRONLY, 0);
if(tty2>=0)
{
std::string string1(buf);
sceIoWrite(tty2, string1.c_str(), string1.length());
sceIoClose(tty2);
}
}
break;
case 1:
{
SceUID tty3 = sceIoOpen("tty3:", SCE_O_WRONLY, 0);
if(tty3>=0)
{
std::string string1(buf);
sceIoWrite(tty3, string1.c_str(), string1.length());
sceIoClose(tty3);
}
}
break;
default:
OutputDebugStringA(buf);
break;
}
#else
OutputDebugStringA(buf);
OutputDebugStringA(buf);
#endif
#ifndef _XBOX
if(user == USER_UI)
{
ui.logDebugString(buf);
}
if(user == USER_UI)
{
ui.logDebugString(buf);
}
#endif
#endif
}
Expand Down
Loading