Fix bucket pickup with scale-aware aiming and build-local Botcraft patches

This commit is contained in:
cantyonion committed 2026-11-24 15:31:16 +08:00
1 parent 0a6193f68e
commit 12c7332337
10 files changed
+416 -40

No files matched your search

+42 -21
View File
@@ -1,23 +1,44 @@
# Keep the pinned upstream revision reproducible while carrying targeted fixes.
# Never reset/checkout the submodule: refuse conflicting local edits instead.
# Botcraft downloads assets into its source directory. Give each version and
# patch set its own build-local checkout, including for out-of-tree builds.
find_package(Git REQUIRED)
set(_botcraft "${CMAKE_CURRENT_SOURCE_DIR}/3rd/Botcraft")
foreach(_patch_name Botcraft-inventory-sync.patch Botcraft-item-frame-spawn.patch)
set(_patch "${CMAKE_CURRENT_SOURCE_DIR}/patches/${_patch_name}")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${_patch}")
execute_process(COMMAND "${GIT_EXECUTABLE}" apply --reverse --check "${_patch}"
WORKING_DIRECTORY "${_botcraft}" RESULT_VARIABLE _already_applied OUTPUT_QUIET ERROR_QUIET)
if(NOT _already_applied EQUAL 0)
execute_process(COMMAND "${GIT_EXECUTABLE}" apply --check "${_patch}"
WORKING_DIRECTORY "${_botcraft}" RESULT_VARIABLE _can_apply OUTPUT_QUIET ERROR_VARIABLE _error)
if(NOT _can_apply EQUAL 0)
message(FATAL_ERROR "Botcraft patch ${_patch_name} conflicts with the checkout; preserve local changes and inspect it manually.\n${_error}")
endif()
execute_process(COMMAND "${GIT_EXECUTABLE}" apply "${_patch}"
WORKING_DIRECTORY "${_botcraft}" RESULT_VARIABLE _applied ERROR_VARIABLE _error)
if(NOT _applied EQUAL 0)
message(FATAL_ERROR "Could not apply Botcraft patch ${_patch_name}: ${_error}")
endif()
message(STATUS "Applied Botcraft patch ${_patch_name}")
endif()
set(_upstream "${CMAKE_CURRENT_SOURCE_DIR}/3rd/Botcraft")
execute_process(COMMAND "${GIT_EXECUTABLE}" rev-parse HEAD WORKING_DIRECTORY "${_upstream}"
OUTPUT_VARIABLE _revision OUTPUT_STRIP_TRAILING_WHITESPACE COMMAND_ERROR_IS_FATAL ANY)
set(_inputs "${_revision}")
set(_patches)
foreach(_name inventory-sync item-frame-spawn player-eye-height)
set(_patch "${CMAKE_CURRENT_SOURCE_DIR}/patches/Botcraft-${_name}.patch")
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${_patch}")
file(SHA256 "${_patch}" _digest)
string(APPEND _inputs " ${_digest}")
list(APPEND _patches "${_patch}")
endforeach()
string(SHA256 _key "${_inputs}")
string(SUBSTRING "${_key}" 0 16 _key)
set(BILICRAFT_BOTCRAFT_SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/_deps/Botcraft-${_key}")
set(_copy "${BILICRAFT_BOTCRAFT_SOURCE_DIR}")
if(NOT EXISTS "${_copy}/.git")
execute_process(COMMAND "${GIT_EXECUTABLE}" clone --no-checkout --no-hardlinks
"${_upstream}" "${_copy}" COMMAND_ERROR_IS_FATAL ANY)
endif()
if(NOT EXISTS "${_copy}/.git/bilicraft-patched")
execute_process(COMMAND "${GIT_EXECUTABLE}" checkout --detach "${_revision}"
WORKING_DIRECTORY "${_copy}" COMMAND_ERROR_IS_FATAL ANY)
execute_process(COMMAND "${GIT_EXECUTABLE}" apply ${_patches}
WORKING_DIRECTORY "${_copy}" COMMAND_ERROR_IS_FATAL ANY)
file(TOUCH "${_copy}/.git/bilicraft-patched")
endif()
# Reuse an initialized Asio checkout and downloaded game assets when available.
# On a fresh machine Botcraft fetches them in its build-local checkout.
if(EXISTS "${_upstream}/3rdparty/asio/.git" AND NOT EXISTS "${_copy}/3rdparty/asio/.git")
execute_process(COMMAND "${GIT_EXECUTABLE}" -c protocol.file.allow=always
-c "submodule.3rdparty/asio.url=${_upstream}/3rdparty/asio"
submodule update --init -- 3rdparty/asio
WORKING_DIRECTORY "${_copy}" COMMAND_ERROR_IS_FATAL ANY)
endif()
set(_assets "Assets/${BOTCRAFT_GAME_VERSION}/minecraft")
if(IS_DIRECTORY "${_upstream}/${_assets}" AND NOT EXISTS "${_copy}/${_assets}")
file(COPY "${_upstream}/${_assets}" DESTINATION "${_copy}/Assets/${BOTCRAFT_GAME_VERSION}")
endif()