mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/LCE-Revelations.git
synced 2026-05-25 13:25:38 +00:00
Adds the FourKit .NET 10 plugin host as a second dedicated server
build flavour alongside the existing vanilla server. Both flavours
build from the same source tree, with FourKit gated by the
MINECRAFT_SERVER_FOURKIT_BUILD preprocessor define.
Build layout:
Minecraft.Server vanilla, no plugin support, no .NET dep
Minecraft.Server.FourKit FourKit-enabled, ships with bundled
.NET 10 self-contained runtime in runtime/
and an empty plugins/ folder
Both produce a Minecraft.Server.exe in their own per-target output
dir. The variant identity lives in the directory name, not the
binary name, so either flavour can be shipped as a drop-in.
Native bridge (Minecraft.Server/FourKit*.{cpp,h}):
* FourKitRuntime: hosts CoreCLR via hostfxr's command-line init API
(the runtime-config API does not support self-contained components)
* FourKitBridge: ~50 Fire* event entry points, with inline no-op
stubs for the standalone build so gameplay code can call them
unconditionally
* FourKitNatives: ~80 native callbacks the managed side invokes
for player/world/inventory mutations
* FourKitMappers: type and enum mapping helpers
Managed plugin host (Minecraft.Server.FourKit/):
* Bukkit-style API: Player, World, Block, Inventory, Command,
Listener, EventHandler attribute, ~54 event classes
* PluginLoader with per-plugin AssemblyLoadContext
* FourKitHost as the [UnmanagedCallersOnly] entry point table
* Runtime resolves plugins relative to the host process so they
always live next to Minecraft.Server.exe regardless of where the
managed assembly itself is loaded from
Engine hooks (Minecraft.Client/, Minecraft.World/):
* Player lifecycle (PreLogin, Login, Join, Quit, Kick, Move,
Teleport, Portal, Death) wired into PendingConnection and
PlayerConnection without disturbing the cipher handshake or
identity-token security flow
* Inventory open/click/drop hooks across every container menu type
* Block place/break/grow/burn/spread/from-to hooks across the
full tile family
* Bed enter/leave, sign change, entity damage/death, ender pearl
teleport hooks
Regression fixes preserved while applying donor diffs:
* ServerPlayer::die() retains the LCE-Revelations hardcore branch
(setGameMode(ADVENTURE) + banPlayerForHardcoreDeath) in both the
FourKit and non-FourKit code paths
* ServerLevel::entityAdded() retains the sub-entity ID reassignment
loop required by the client's handleAddMob offset, fixing Ender
Dragon and Wither boss multi-part hit detection
* LivingEntity::travel() retains the raw Player* cast and the
cached frictionTile, both Revelations perf wins that the donor
silently reverted
* ServerLogger.cpp keeps the file-logging code donor stripped
* PlayerList.cpp end portal transition fix and UIScene_EndPoem
bounds-check are intact
Build system:
* Top-level CMakeLists.txt adds the Minecraft.Server.FourKit
subdirectory and pulls in the new shared cmake/ServerTarget.cmake
helper
* Minecraft.Server/cmake/sources/Common.cmake is now location
independent (uses CMAKE_CURRENT_LIST_DIR) so the source list
can be consumed from either server target's CMakeLists.txt
* The seven FourKit*.cpp/h files live in their own
_MINECRAFT_SERVER_COMMON_SERVER_FOURKIT variable so the
standalone target omits them
* configure-time .NET 10 SDK check fails fast with a clear
download link if the SDK is missing
* global.json pins the SDK to 10.0.100 with latestFeature
rollforward
Sample plugin (samples/HelloPlugin/) demonstrates the loader and
the PlayerJoinEvent listener pattern.
CI:
* nightly.yml builds both server flavours, ships
LCE-Revelations-Server-Win64.zip and
LCE-Revelations-Server-Win64-FourKit.zip, attests both, and
updates release notes for the dual-flavour layout
* pull-request.yml pulls in actions/setup-dotnet so the FourKit
publish step works in PR validation
* All zip artifacts and the client zip are renamed from
LCREWindows64 to LCE-Revelations-{Client,Server}-Win64
Documentation:
* COMPILE.md gets a VS 2022 quick start, .NET 10 prereq section,
server flavours explanation, and a troubleshooting section
* docs/FOURKIT_PORT_RECON.md captures the file-by-file recon that
drove the port
* docs/FOURKIT_PARITY.md is the canonical reference for which
events FourKit fires
Docker:
* docker-compose.dedicated-server.yml MC_RUNTIME_DIR default points
at the vanilla CMake output. The FourKit Docker image is
intentionally NOT shipped yet because hosting .NET 10 self
contained inside Wine has not been smoke-tested
106 lines
4.6 KiB
CMake
106 lines
4.6 KiB
CMake
# Shared CMake helper for the dedicated server executable targets.
|
|
#
|
|
# Both server flavours (vanilla "Minecraft.Server" and FourKit-enabled
|
|
# "Minecraft.Server.FourKit") share the same compile/link/asset/debugger
|
|
# settings. This helper applies them to a target after add_executable.
|
|
#
|
|
# The two targets are defined in different source subdirectories so that
|
|
# the Visual Studio generator emits their .vcxproj files into matching
|
|
# binary subdirectories (build/<dir>/Minecraft.Server/ and
|
|
# build/<dir>/Minecraft.Server.FourKit/), keeping the variant identity
|
|
# consistent across source dir, project file, and runtime output dir.
|
|
|
|
include_guard(GLOBAL)
|
|
|
|
include("${CMAKE_SOURCE_DIR}/cmake/CopyAssets.cmake")
|
|
|
|
# Apply shared compile/link/asset/debugger settings to a server executable target.
|
|
function(configure_lce_server_target target)
|
|
# compat_shims.cpp redefines internal MSVC CRT symbols which would explode
|
|
# if included via the precompiled header. CMake source-file properties are
|
|
# directory-scoped, so we have to apply this for the directory of every
|
|
# target that consumes the file (one per server flavour), not just once
|
|
# at module-include time.
|
|
set_source_files_properties(
|
|
"${CMAKE_SOURCE_DIR}/Minecraft.Client/compat_shims.cpp"
|
|
TARGET_DIRECTORY ${target}
|
|
PROPERTIES SKIP_PRECOMPILE_HEADERS ON
|
|
)
|
|
|
|
# Asset / redist source paths used by setup_asset_*_copy(). Defined inside
|
|
# the function so they are in scope when this helper is called from a
|
|
# different CMakeLists.txt. (CMake variables set at module file scope are
|
|
# not visible to function bodies invoked from other files.)
|
|
set(_asset_folder_pairs
|
|
"${CMAKE_SOURCE_DIR}/Minecraft.Client/Common/res" "Common/res"
|
|
)
|
|
set(_asset_files_pairs
|
|
"${CMAKE_SOURCE_DIR}/Minecraft.Client/Common/Media/MediaWindows64.arc" "Common/Media/"
|
|
)
|
|
|
|
target_include_directories(${target} PRIVATE
|
|
"${CMAKE_BINARY_DIR}/generated/" # Generated BuildVer.h
|
|
"${CMAKE_SOURCE_DIR}/Minecraft.Client/"
|
|
"${CMAKE_SOURCE_DIR}/Minecraft.Client/${PLATFORM_NAME}/Iggy/include"
|
|
"${CMAKE_SOURCE_DIR}/Minecraft.Server"
|
|
"${CMAKE_SOURCE_DIR}/include/"
|
|
)
|
|
target_compile_definitions(${target} PRIVATE
|
|
${MINECRAFT_SHARED_DEFINES}
|
|
MINECRAFT_SERVER_BUILD
|
|
)
|
|
target_precompile_headers(${target} PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:stdafx.h>")
|
|
|
|
configure_compiler_target(${target})
|
|
|
|
# Both flavours produce a binary literally named "Minecraft.Server.exe".
|
|
# The variant identity lives in the build directory name, not the file name,
|
|
# so end users can ship either one as a drop-in replacement. Override the
|
|
# per-config RUNTIME_OUTPUT_DIRECTORY explicitly because the default would
|
|
# otherwise put both targets in the same Minecraft.Server/<config>/ dir
|
|
# (the source dir of whichever CMakeLists.txt called add_executable) and
|
|
# ninja would complain about duplicate output rules.
|
|
set_target_properties(${target} PROPERTIES
|
|
OUTPUT_NAME "Minecraft.Server"
|
|
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${target}"
|
|
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/${target}/Debug"
|
|
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/${target}/Release"
|
|
VS_DEBUGGER_WORKING_DIRECTORY "$<TARGET_FILE_DIR:${target}>"
|
|
VS_DEBUGGER_COMMAND_ARGUMENTS "-port 25565 -bind 0.0.0.0 -name DedicatedServer"
|
|
)
|
|
|
|
target_link_libraries(${target} PRIVATE
|
|
Minecraft.World
|
|
d3d11
|
|
dxgi
|
|
d3dcompiler
|
|
XInput9_1_0
|
|
wsock32
|
|
legacy_stdio_definitions
|
|
$<$<CONFIG:Debug>:
|
|
"${CMAKE_SOURCE_DIR}/Minecraft.Client/${PLATFORM_NAME}/4JLibs/libs/4J_Input_d.lib"
|
|
"${CMAKE_SOURCE_DIR}/Minecraft.Client/${PLATFORM_NAME}/4JLibs/libs/4J_Storage_d.lib"
|
|
"${CMAKE_SOURCE_DIR}/Minecraft.Client/${PLATFORM_NAME}/4JLibs/libs/4J_Render_PC_d.lib"
|
|
>
|
|
$<$<NOT:$<CONFIG:Debug>>:
|
|
"${CMAKE_SOURCE_DIR}/Minecraft.Client/${PLATFORM_NAME}/4JLibs/libs/4J_Input.lib"
|
|
"${CMAKE_SOURCE_DIR}/Minecraft.Client/${PLATFORM_NAME}/4JLibs/libs/4J_Storage.lib"
|
|
"${CMAKE_SOURCE_DIR}/Minecraft.Client/${PLATFORM_NAME}/4JLibs/libs/4J_Render_PC.lib"
|
|
>
|
|
)
|
|
|
|
foreach(lib IN LISTS IGGY_LIBS)
|
|
target_link_libraries(${target} PRIVATE "${CMAKE_SOURCE_DIR}/Minecraft.Client/${PLATFORM_NAME}/Iggy/lib/${lib}")
|
|
endforeach()
|
|
|
|
# Per-target asset / redist copy steps. These create helper sub-targets
|
|
# named after the parent (e.g. AssetFileCopy_${target}) which is why each
|
|
# server flavour has its own set in the VS Solution Explorer.
|
|
setup_asset_folder_copy(${target} "${_asset_folder_pairs}")
|
|
setup_asset_file_copy(${target} "${_asset_files_pairs}")
|
|
add_copyredist_target(${target})
|
|
if(PLATFORM_NAME STREQUAL "Windows64")
|
|
add_gamehdd_target(${target})
|
|
endif()
|
|
endfunction()
|