Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
e2518e734c | |||
35cafec1ee | |||
4ab6b7aed1 | |||
edd346dd66 | |||
0d9f498aa7 | |||
d761ad8614 | |||
4977898bcd | |||
513628d91f | |||
9a521ebca2 | |||
deae36ed94 | |||
00d6ee4f9a | |||
8dd562a20f | |||
c11c7203ef |
1
.gitignore
vendored
1
.gitignore
vendored
@ -12,4 +12,3 @@
|
|||||||
/*.AppImage
|
/*.AppImage
|
||||||
/core*
|
/core*
|
||||||
/qemu_*
|
/qemu_*
|
||||||
/cmake/.prebuilt-armhf-toolchain
|
|
||||||
|
5
.gitmodules
vendored
5
.gitmodules
vendored
@ -1,15 +1,16 @@
|
|||||||
[submodule "dependencies/libpng/src"]
|
[submodule "dependencies/libpng/src"]
|
||||||
path = dependencies/libpng/src
|
path = dependencies/libpng/src
|
||||||
url = https://github.com/glennrp/libpng.git
|
url = https://gitea.thebrokenrail.com/minecraft-pi-reborn/libpng.git
|
||||||
[submodule "dependencies/zlib/src"]
|
[submodule "dependencies/zlib/src"]
|
||||||
path = dependencies/libpng/zlib/src
|
path = dependencies/libpng/zlib/src
|
||||||
url = https://github.com/madler/zlib.git
|
url = https://github.com/madler/zlib.git
|
||||||
|
ignore = dirty
|
||||||
[submodule "dependencies/glfw/src"]
|
[submodule "dependencies/glfw/src"]
|
||||||
path = media-layer/core/dependencies/glfw/src
|
path = media-layer/core/dependencies/glfw/src
|
||||||
url = https://github.com/glfw/glfw.git
|
url = https://github.com/glfw/glfw.git
|
||||||
[submodule "dependencies/zenity/src"]
|
[submodule "dependencies/zenity/src"]
|
||||||
path = dependencies/zenity/src
|
path = dependencies/zenity/src
|
||||||
url = https://gitea.thebrokenrail.com/TheBrokenRail/zenity.git
|
url = https://gitea.thebrokenrail.com/minecraft-pi-reborn/zenity.git
|
||||||
[submodule "launcher/dependencies/patchelf/src"]
|
[submodule "launcher/dependencies/patchelf/src"]
|
||||||
path = launcher/dependencies/patchelf/src
|
path = launcher/dependencies/patchelf/src
|
||||||
url = https://github.com/NixOS/patchelf.git
|
url = https://github.com/NixOS/patchelf.git
|
||||||
|
@ -99,10 +99,14 @@ project(minecraft-pi-reborn)
|
|||||||
include(cmake/util.cmake)
|
include(cmake/util.cmake)
|
||||||
|
|
||||||
# Sanity Checks
|
# Sanity Checks
|
||||||
if(BUILD_NATIVE_COMPONENTS AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" AND NOT MCPI_IS_MIXED_BUILD)
|
set(IS_ARM_TARGETING FALSE)
|
||||||
|
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l")
|
||||||
|
set(IS_ARM_TARGETING TRUE)
|
||||||
|
endif()
|
||||||
|
if(BUILD_NATIVE_COMPONENTS AND NOT IS_ARM_TARGETING AND NOT MCPI_IS_MIXED_BUILD)
|
||||||
message(FATAL_ERROR "Project is configured as a mixed-buld, but MCPI_IS_MIXED_BUILD is disabled.")
|
message(FATAL_ERROR "Project is configured as a mixed-buld, but MCPI_IS_MIXED_BUILD is disabled.")
|
||||||
endif()
|
endif()
|
||||||
if(BUILD_ARM_COMPONENTS AND NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
|
if(BUILD_ARM_COMPONENTS AND NOT IS_ARM_TARGETING)
|
||||||
message(FATAL_ERROR "ARM-Targeting Compiler Required")
|
message(FATAL_ERROR "ARM-Targeting Compiler Required")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -115,30 +119,37 @@ if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
|||||||
set(CMAKE_INSTALL_PREFIX "${DEFAULT_PREFIX}" CACHE PATH "" FORCE)
|
set(CMAKE_INSTALL_PREFIX "${DEFAULT_PREFIX}" CACHE PATH "" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Required Compile Flags
|
||||||
|
string(CONCAT COMPILE_FLAGS_SETUP
|
||||||
# Optimizations
|
# Optimizations
|
||||||
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
"if(CMAKE_BUILD_TYPE STREQUAL \"Release\")\n"
|
||||||
add_compile_options(-O3 -s)
|
" add_compile_options(-O3 -s)\n"
|
||||||
else()
|
"else()\n"
|
||||||
add_compile_options(-g)
|
" add_compile_options(-g)\n"
|
||||||
endif()
|
"endif()\n"
|
||||||
|
|
||||||
# Use LLD When Using Clang
|
|
||||||
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
|
||||||
add_link_options("-fuse-ld=lld")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# PIC
|
# PIC
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
"set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)\n"
|
||||||
|
|
||||||
|
# Warnings
|
||||||
|
"add_link_options(-Wl,--no-undefined)\n"
|
||||||
|
|
||||||
|
# C Standard
|
||||||
|
"add_definitions(-D_GNU_SOURCE)\n"
|
||||||
|
"set(CMAKE_C_STANDARD 99)\n"
|
||||||
|
"set(CMAKE_CXX_STANDARD 11)\n"
|
||||||
|
|
||||||
|
# Skip RPath
|
||||||
|
"set(CMAKE_SKIP_BUILD_RPATH TRUE)"
|
||||||
|
)
|
||||||
|
cmake_language(EVAL CODE "${COMPILE_FLAGS_SETUP}")
|
||||||
|
|
||||||
# Fast Math
|
# Fast Math
|
||||||
add_compile_options(-ffast-math)
|
add_compile_options(-ffast-math)
|
||||||
|
|
||||||
# Buld Dependencies
|
|
||||||
add_subdirectory(dependencies)
|
|
||||||
|
|
||||||
# Warnings
|
# Warnings
|
||||||
add_compile_options(-Wall -Wextra -Werror -Wpointer-arith -Wshadow -Wnull-dereference)
|
add_compile_options(-Wall -Wextra -Werror -Wpointer-arith -Wshadow -Wnull-dereference)
|
||||||
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
if(CMAKE_C_COMPILER_ID STREQUAL \"GNU\")
|
||||||
# Prevents False Positives
|
# Prevents False Positives
|
||||||
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 10.0)
|
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 10.0)
|
||||||
add_compile_options(-Wno-stringop-overflow)
|
add_compile_options(-Wno-stringop-overflow)
|
||||||
@ -147,10 +158,9 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
|||||||
add_compile_options(-Wno-array-bounds -Wno-stringop-overread)
|
add_compile_options(-Wno-array-bounds -Wno-stringop-overread)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
add_link_options(-Wl,--no-undefined)
|
|
||||||
add_definitions(-D_GNU_SOURCE)
|
# Buld Dependencies
|
||||||
set(CMAKE_C_STANDARD 99)
|
add_subdirectory(dependencies)
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
|
||||||
|
|
||||||
# Version
|
# Version
|
||||||
set_property(
|
set_property(
|
||||||
@ -189,5 +199,14 @@ endif()
|
|||||||
|
|
||||||
# Install SDK
|
# Install SDK
|
||||||
if(BUILD_ARM_COMPONENTS)
|
if(BUILD_ARM_COMPONENTS)
|
||||||
install(EXPORT sdk DESTINATION "${MCPI_SDK_DIR}" EXPORT_LINK_INTERFACE_LIBRARIES)
|
install(EXPORT sdk DESTINATION "${MCPI_SDK_DIR}" FILE "sdk-targets.cmake" EXPORT_LINK_INTERFACE_LIBRARIES)
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/sdk.cmake"
|
||||||
|
# Compile Flags
|
||||||
|
"${COMPILE_FLAGS_SETUP}\n"
|
||||||
|
# Log
|
||||||
|
"message(STATUS \"Using Reborn SDK v${MCPI_VERSION}\")\n"
|
||||||
|
# Include Targets
|
||||||
|
"include(\"\${CMAKE_CURRENT_LIST_DIR}/sdk-targets.cmake\")\n"
|
||||||
|
)
|
||||||
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sdk.cmake" DESTINATION "${MCPI_SDK_DIR}")
|
||||||
endif()
|
endif()
|
||||||
|
12
cmake/embed-resource.cmake
Normal file
12
cmake/embed-resource.cmake
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Read Hex Data
|
||||||
|
file(READ "${EMBED_IN}" data HEX)
|
||||||
|
|
||||||
|
# Convert Hex Data For C Compatibility
|
||||||
|
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," data "${data}")
|
||||||
|
|
||||||
|
# Get C Name
|
||||||
|
get_filename_component(name "${EMBED_IN}" NAME)
|
||||||
|
string(MAKE_C_IDENTIFIER "${name}" name)
|
||||||
|
|
||||||
|
# Write Data
|
||||||
|
file(WRITE "${EMBED_OUT}" "#include <stddef.h>\nconst unsigned char ${name}[] = {${data}};\nconst size_t ${name}_len = sizeof (${name});\n")
|
@ -1,16 +1,3 @@
|
|||||||
# Locations
|
|
||||||
set(toolchain_dir "${CMAKE_CURRENT_LIST_DIR}/.prebuilt-armhf-toolchain")
|
|
||||||
set(sysroot_dir "${CMAKE_CURRENT_BINARY_DIR}/bundled-armhf-sysroot")
|
|
||||||
|
|
||||||
# Force Toolchain
|
|
||||||
set(CMAKE_C_COMPILER "${toolchain_dir}/bin/arm-none-linux-gnueabihf-gcc")
|
|
||||||
set(CMAKE_CXX_COMPILER "${toolchain_dir}/bin/arm-none-linux-gnueabihf-g++")
|
|
||||||
set(CMAKE_SYSTEM_NAME "Linux")
|
|
||||||
set(CMAKE_SYSTEM_PROCESSOR "arm")
|
|
||||||
unset(CMAKE_TOOLCHAIN_FILE CACHE)
|
|
||||||
|
|
||||||
# Download If Needed
|
|
||||||
if(NOT EXISTS "${CMAKE_C_COMPILER}")
|
|
||||||
# Pick URL
|
# Pick URL
|
||||||
execute_process(COMMAND uname -m OUTPUT_VARIABLE arch OUTPUT_STRIP_TRAILING_WHITESPACE)
|
execute_process(COMMAND uname -m OUTPUT_VARIABLE arch OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
if(arch STREQUAL "x86_64")
|
if(arch STREQUAL "x86_64")
|
||||||
@ -23,26 +10,32 @@ if(NOT EXISTS "${CMAKE_C_COMPILER}")
|
|||||||
message(FATAL_ERROR "Unable To Download Prebuilt ARMHF Toolchain")
|
message(FATAL_ERROR "Unable To Download Prebuilt ARMHF Toolchain")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Download
|
# Download If Needed
|
||||||
message(STATUS "Downloading Prebuilt ARMHF Toolchain...")
|
|
||||||
file(REMOVE_RECURSE "${toolchain_dir}")
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
set(FETCHCONTENT_QUIET FALSE)
|
set(FETCHCONTENT_QUIET FALSE)
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
prebuilt-armhf-toolchain
|
prebuilt-armhf-toolchain
|
||||||
URL "${toolchain_url}"
|
URL "${toolchain_url}"
|
||||||
URL_HASH "SHA256=${toolchain_sha256}"
|
URL_HASH "SHA256=${toolchain_sha256}"
|
||||||
SOURCE_DIR "${toolchain_dir}"
|
|
||||||
)
|
)
|
||||||
FetchContent_Populate(prebuilt-armhf-toolchain)
|
FetchContent_MakeAvailable(prebuilt-armhf-toolchain)
|
||||||
|
set(FETCHCONTENT_QUIET TRUE)
|
||||||
|
set(toolchain_dir "${prebuilt-armhf-toolchain_SOURCE_DIR}")
|
||||||
|
|
||||||
# Force Sysroot Rebuild
|
# Force Toolchain
|
||||||
file(REMOVE_RECURSE "${sysroot_dir}")
|
file(WRITE "${toolchain_dir}/toolchain.cmake"
|
||||||
endif()
|
"set(CMAKE_C_COMPILER \"\${CMAKE_CURRENT_LIST_DIR}/bin/arm-none-linux-gnueabihf-gcc\")\n"
|
||||||
|
"set(CMAKE_CXX_COMPILER \"\${CMAKE_CURRENT_LIST_DIR}/bin/arm-none-linux-gnueabihf-g++\")\n"
|
||||||
|
"set(CMAKE_SYSTEM_NAME \"Linux\")\n"
|
||||||
|
"set(CMAKE_SYSTEM_PROCESSOR \"arm\")\n"
|
||||||
|
)
|
||||||
|
set(CMAKE_TOOLCHAIN_FILE "${toolchain_dir}/toolchain.cmake" CACHE STRING "" FORCE)
|
||||||
|
|
||||||
# Build Sysroot
|
# Build Sysroot
|
||||||
if(NOT EXISTS "${sysroot_dir}")
|
set(sysroot_dir "${CMAKE_CURRENT_BINARY_DIR}/bundled-armhf-sysroot")
|
||||||
|
if("${toolchain_dir}/bin/arm-none-linux-gnueabihf-gcc" IS_NEWER_THAN "${sysroot_dir}")
|
||||||
# Create Directory
|
# Create Directory
|
||||||
|
file(REMOVE_RECURSE "${sysroot_dir}")
|
||||||
file(MAKE_DIRECTORY "${sysroot_dir}")
|
file(MAKE_DIRECTORY "${sysroot_dir}")
|
||||||
|
|
||||||
# Copy Files From Toolchain
|
# Copy Files From Toolchain
|
||||||
|
@ -8,3 +8,19 @@ function(install_symlink target link)
|
|||||||
file(CREATE_LINK "${target}" "${CMAKE_BINARY_DIR}/symlink/${link}" SYMBOLIC)
|
file(CREATE_LINK "${target}" "${CMAKE_BINARY_DIR}/symlink/${link}" SYMBOLIC)
|
||||||
install(FILES "${CMAKE_BINARY_DIR}/symlink/${link}" DESTINATION "${parent}")
|
install(FILES "${CMAKE_BINARY_DIR}/symlink/${link}" DESTINATION "${parent}")
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
# Embed Resources
|
||||||
|
set(util_list_dir "${CMAKE_CURRENT_LIST_DIR}")
|
||||||
|
function(embed_resource target file)
|
||||||
|
# Get C Name
|
||||||
|
get_filename_component(name "${file}" NAME)
|
||||||
|
string(MAKE_C_IDENTIFIER "${name}" name)
|
||||||
|
# Add Command
|
||||||
|
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
|
||||||
|
COMMAND "${CMAKE_COMMAND}"
|
||||||
|
ARGS "-DEMBED_IN=${CMAKE_CURRENT_SOURCE_DIR}/${file}" "-DEMBED_OUT=${CMAKE_CURRENT_BINARY_DIR}/${name}.c" "-P" "${util_list_dir}/embed-resource.cmake"
|
||||||
|
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${file}" "${util_list_dir}/embed-resource.cmake"
|
||||||
|
)
|
||||||
|
# Add To Target
|
||||||
|
target_sources("${target}" PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/${name}.c")
|
||||||
|
endfunction()
|
||||||
|
19
dependencies/libpng/CMakeLists.txt
vendored
19
dependencies/libpng/CMakeLists.txt
vendored
@ -11,26 +11,15 @@ add_compile_options(-w)
|
|||||||
# Options
|
# Options
|
||||||
set(PNG_TESTS FALSE CACHE BOOL "" FORCE)
|
set(PNG_TESTS FALSE CACHE BOOL "" FORCE)
|
||||||
set(PNG_NO_STDIO FALSE CACHE BOOL "" FORCE)
|
set(PNG_NO_STDIO FALSE CACHE BOOL "" FORCE)
|
||||||
set(PNG_STATIC FALSE CACHE BOOL "" FORCE)
|
set(PNG_BUILD_ZLIB TRUE CACHE BOOL "" FORCE)
|
||||||
set(PNG_SHARED TRUE CACHE BOOL "" FORCE)
|
|
||||||
|
|
||||||
# Download
|
# Download
|
||||||
set(ZLIB_LIBRARY zlibstatic)
|
set(ZLIB_LIBRARY zlibstatic)
|
||||||
set(ZLIB_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/zlib/src")
|
set(ZLIB_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/zlib/src" "${CMAKE_CURRENT_BINARY_DIR}/zlib/src")
|
||||||
set(CMAKE_POLICY_DEFAULT_CMP0054 OLD) # Silence Warning
|
|
||||||
set(CMAKE_POLICY_DEFAULT_CMP0003 NEW) # Silence Warning
|
|
||||||
set(CMAKE_POLICY_DEFAULT_CMP0022 NEW) # Fix Error
|
|
||||||
set(M_LIBRARY m) # No Full Paths!
|
|
||||||
add_subdirectory(src EXCLUDE_FROM_ALL)
|
add_subdirectory(src EXCLUDE_FROM_ALL)
|
||||||
set(CMAKE_POLICY_DEFAULT_CMP0054 NEW) # Re-Enable New Behavior
|
|
||||||
|
|
||||||
# Setup Target
|
# Use Symbol Versioning
|
||||||
set_target_properties(png12 PROPERTIES LINK_OPTIONS "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libpng.vers") # Use Symbol Versioning
|
set_target_properties(png12 PROPERTIES LINK_OPTIONS "LINKER:--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libpng.vers")
|
||||||
set_target_properties(png12 PROPERTIES DEBUG_POSTFIX "") # Fix LibPNG Suffix In Debug Mode
|
|
||||||
target_include_directories(png12 PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>")
|
|
||||||
foreach(zlib_include_dir IN ITEMS "${ZLIB_INCLUDE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/zlib/src")
|
|
||||||
target_include_directories(png12 PUBLIC "$<BUILD_INTERFACE:${zlib_include_dir}>")
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# Ensure Build
|
# Ensure Build
|
||||||
add_custom_target(png12-build ALL DEPENDS png12)
|
add_custom_target(png12-build ALL DEPENDS png12)
|
||||||
|
2
dependencies/libpng/src
vendored
2
dependencies/libpng/src
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 5bb5bf345aef1e62adcfe30791f4364730a2aede
|
Subproject commit 6c445538879f9e916f8e62723d2ac7cd77d96191
|
2
dependencies/zenity/src
vendored
2
dependencies/zenity/src
vendored
@ -1 +1 @@
|
|||||||
Subproject commit d673e9aab842d7151d92eb9164872dc05e748db2
|
Subproject commit 27cd9e88a72538b00d172dee67d94cb4ce6bc9b9
|
@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
**2.4.3**
|
||||||
|
* Fix Signs With CP-437
|
||||||
|
|
||||||
|
**2.4.2**
|
||||||
|
* Fix Picking Up Lava
|
||||||
|
* Fix Wayland App ID
|
||||||
|
|
||||||
**2.4.1**
|
**2.4.1**
|
||||||
* Allow More Characters In Usernames And Chat
|
* Allow More Characters In Usernames And Chat
|
||||||
* Fix Running On ARMHF Debian Buster
|
* Fix Running On ARMHF Debian Buster
|
||||||
|
@ -7,15 +7,15 @@ Download packages [here](https://jenkins.thebrokenrail.com/job/minecraft-pi-rebo
|
|||||||
* Debian Buster/Ubuntu 18.04 Or Higher
|
* Debian Buster/Ubuntu 18.04 Or Higher
|
||||||
* QEMU User-Mode
|
* QEMU User-Mode
|
||||||
* Debian/Ubuntu: ``sudo apt install qemu-user``
|
* Debian/Ubuntu: ``sudo apt install qemu-user``
|
||||||
* Arch: ``sudo pacman -Sy qemu-user``
|
* Arch: ``sudo pacman -S qemu-user``
|
||||||
* Client-Only Dependencies
|
* Client-Only Dependencies
|
||||||
* Graphics Drivers
|
* Graphics Drivers
|
||||||
* GTK+ 3
|
* GTK+ 3
|
||||||
* Debian/Ubuntu: ``sudo apt install libgtk-3-0``
|
* Debian/Ubuntu: ``sudo apt install libgtk-3-0``
|
||||||
* Arch: ``sudo pacman -Sy gtk3``
|
* Arch: ``sudo pacman -S gtk3``
|
||||||
* OpenAL
|
* OpenAL
|
||||||
* Debian/Ubuntu: ``sudo apt install libopenal1``
|
* Debian/Ubuntu: ``sudo apt install libopenal1``
|
||||||
* Arch: ``sudo pacman -Sy openal``
|
* Arch: ``sudo pacman -S openal``
|
||||||
|
|
||||||
### Running
|
### Running
|
||||||
Follow [these](https://docs.appimage.org/introduction/quickstart.html#how-to-run-an-appimage) instructions.
|
Follow [these](https://docs.appimage.org/introduction/quickstart.html#how-to-run-an-appimage) instructions.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Example Mods
|
# Example Mods
|
||||||
This is an example of a mod that cane be built using the modding SDK.
|
This is an example of a mod that can be built using the modding SDK.
|
||||||
|
|
||||||
* **Expanded Creative Mod**: This specific mod adds even more items and blocks to the Creative Inventory. It was originally by [@Bigjango13](https://github.com/bigjango13).
|
* **Expanded Creative Mod**: This specific mod adds even more items and blocks to the Creative Inventory. It was originally by [@Bigjango13](https://github.com/bigjango13).
|
||||||
* **Chat Commands Mod**: This specific mod makes an chat message starting with a ``/`` handled by the MCPI API.
|
* **Chat Commands Mod**: This specific mod makes an chat message starting with a ``/`` handled by the MCPI API.
|
||||||
|
BIN
images/start.png
BIN
images/start.png
Binary file not shown.
Before Width: | Height: | Size: 155 KiB After Width: | Height: | Size: 155 KiB |
@ -8,14 +8,8 @@ add_executable(launcher src/bootstrap.c src/patchelf.c src/crash-report.c)
|
|||||||
if(MCPI_SERVER_MODE)
|
if(MCPI_SERVER_MODE)
|
||||||
target_sources(launcher PRIVATE src/server/launcher.c)
|
target_sources(launcher PRIVATE src/server/launcher.c)
|
||||||
else()
|
else()
|
||||||
add_custom_command(
|
embed_resource(launcher src/client/available-feature-flags)
|
||||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/available-feature-flags.c"
|
target_sources(launcher PRIVATE src/client/launcher.cpp)
|
||||||
COMMAND xxd -i available-feature-flags "${CMAKE_CURRENT_BINARY_DIR}/available-feature-flags.c"
|
|
||||||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/client/available-feature-flags"
|
|
||||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src/client"
|
|
||||||
VERBATIM
|
|
||||||
)
|
|
||||||
target_sources(launcher PRIVATE src/client/launcher.cpp "${CMAKE_CURRENT_BINARY_DIR}/available-feature-flags.c")
|
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(launcher reborn-util)
|
target_link_libraries(launcher reborn-util)
|
||||||
# RPath
|
# RPath
|
||||||
@ -44,7 +38,7 @@ else()
|
|||||||
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/launcher.desktop"
|
file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/launcher.desktop"
|
||||||
"Terminal=false\n"
|
"Terminal=false\n"
|
||||||
"StartupNotify=false\n"
|
"StartupNotify=false\n"
|
||||||
"StartupWMClass=${MCPI_APP_TITLE}\n"
|
"StartupWMClass=${MCPI_APP_ID}\n"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
install(
|
install(
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 734daa3d0f79cf1a0c81f927d846ace5d6a2c8e1
|
Subproject commit c2b419dc2a0d6095eaa69b65ad5854ce847bdd01
|
@ -53,7 +53,7 @@ static void load(char **ld_preload, char *folder) {
|
|||||||
string_append(ld_preload, "%s%s", *ld_preload == NULL ? "" : ":", name);
|
string_append(ld_preload, "%s%s", *ld_preload == NULL ? "" : ":", name);
|
||||||
} else if (result == -1 && errno != 0) {
|
} else if (result == -1 && errno != 0) {
|
||||||
// Fail
|
// Fail
|
||||||
WARN("Unable To Acesss: %s: %s", name, strerror(errno));
|
WARN("Unable To Access: %s: %s", name, strerror(errno));
|
||||||
errno = 0;
|
errno = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ void pre_bootstrap(int argc, char *argv[]) {
|
|||||||
// Configure PATH
|
// Configure PATH
|
||||||
{
|
{
|
||||||
// Add Library Directory
|
// Add Library Directory
|
||||||
char *new_path;
|
char *new_path = NULL;
|
||||||
safe_asprintf(&new_path, "%s/bin", binary_directory);
|
safe_asprintf(&new_path, "%s/bin", binary_directory);
|
||||||
// Add Existing PATH
|
// Add Existing PATH
|
||||||
{
|
{
|
||||||
@ -332,7 +332,6 @@ void bootstrap(int argc, char *argv[]) {
|
|||||||
// Library Search Path For ARM Components
|
// Library Search Path For ARM Components
|
||||||
{
|
{
|
||||||
// Add ARM Library Directory
|
// Add ARM Library Directory
|
||||||
// (This Overrides LD_LIBRARY_PATH Using ld.so's --library-path Option)
|
|
||||||
safe_asprintf(&mcpi_ld_path, "%s/lib/arm", binary_directory);
|
safe_asprintf(&mcpi_ld_path, "%s/lib/arm", binary_directory);
|
||||||
|
|
||||||
// Add ARM Sysroot Libraries (Ensure Priority) (Ignore On Actual ARM System)
|
// Add ARM Sysroot Libraries (Ensure Priority) (Ignore On Actual ARM System)
|
||||||
@ -344,7 +343,7 @@ void bootstrap(int argc, char *argv[]) {
|
|||||||
{
|
{
|
||||||
char *value = getenv("LD_LIBRARY_PATH");
|
char *value = getenv("LD_LIBRARY_PATH");
|
||||||
if (value != NULL && strlen(value) > 0) {
|
if (value != NULL && strlen(value) > 0) {
|
||||||
string_append(&transitive_ld_path, ":%s", value);
|
string_append(&mcpi_ld_path, ":%s", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ static std::string strip_feature_flag_default(std::string flag, bool *default_re
|
|||||||
|
|
||||||
// Load Available Feature Flags
|
// Load Available Feature Flags
|
||||||
extern unsigned char available_feature_flags[];
|
extern unsigned char available_feature_flags[];
|
||||||
extern unsigned int available_feature_flags_len;
|
extern size_t available_feature_flags_len;
|
||||||
static void load_available_feature_flags(std::function<void(std::string)> callback) {
|
static void load_available_feature_flags(std::function<void(std::string)> callback) {
|
||||||
// Get Path
|
// Get Path
|
||||||
char *binary_directory = get_binary_directory();
|
char *binary_directory = get_binary_directory();
|
||||||
@ -112,7 +112,7 @@ static void run_zenity_and_set_env(const char *env_name, std::vector<std::string
|
|||||||
full_command.push_back("--title");
|
full_command.push_back("--title");
|
||||||
full_command.push_back(DIALOG_TITLE);
|
full_command.push_back(DIALOG_TITLE);
|
||||||
full_command.push_back("--name");
|
full_command.push_back("--name");
|
||||||
full_command.push_back(MCPI_APP_TITLE);
|
full_command.push_back(MCPI_APP_ID);
|
||||||
full_command.insert(full_command.end(), command.begin(), command.end());
|
full_command.insert(full_command.end(), command.begin(), command.end());
|
||||||
// Convert To C Array
|
// Convert To C Array
|
||||||
const char *full_command_array[full_command.size() + 1];
|
const char *full_command_array[full_command.size() + 1];
|
||||||
|
@ -22,7 +22,7 @@ static void show_report(const char *log_filename) {
|
|||||||
const char *command[] = {
|
const char *command[] = {
|
||||||
"zenity",
|
"zenity",
|
||||||
"--title", DIALOG_TITLE,
|
"--title", DIALOG_TITLE,
|
||||||
"--name", MCPI_APP_TITLE,
|
"--name", MCPI_APP_ID,
|
||||||
"--width", CRASH_REPORT_DIALOG_WIDTH,
|
"--width", CRASH_REPORT_DIALOG_WIDTH,
|
||||||
"--height", CRASH_REPORT_DIALOG_HEIGHT,
|
"--height", CRASH_REPORT_DIALOG_HEIGHT,
|
||||||
"--text-info",
|
"--text-info",
|
||||||
|
@ -6,5 +6,6 @@
|
|||||||
#cmakedefine MCPI_USE_PREBUILT_ARMHF_TOOLCHAIN
|
#cmakedefine MCPI_USE_PREBUILT_ARMHF_TOOLCHAIN
|
||||||
#cmakedefine MCPI_USE_GLES1_COMPATIBILITY_LAYER
|
#cmakedefine MCPI_USE_GLES1_COMPATIBILITY_LAYER
|
||||||
#cmakedefine MCPI_APP_TITLE "@MCPI_APP_TITLE@"
|
#cmakedefine MCPI_APP_TITLE "@MCPI_APP_TITLE@"
|
||||||
|
#cmakedefine MCPI_APP_ID "@MCPI_APP_ID@"
|
||||||
#cmakedefine MCPI_VERSION "@MCPI_VERSION@"
|
#cmakedefine MCPI_VERSION "@MCPI_VERSION@"
|
||||||
#cmakedefine MCPI_SDK_DIR "@MCPI_SDK_DIR@"
|
#cmakedefine MCPI_SDK_DIR "@MCPI_SDK_DIR@"
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit c50d53160fa9b579dda0d0a4f9a7c2512940df8e
|
Subproject commit c18851f52ec9704eb06464058a600845ec1eada1
|
@ -14,6 +14,11 @@ endif()
|
|||||||
add_library(GLESv1_CM SHARED ${GLES_SRC})
|
add_library(GLESv1_CM SHARED ${GLES_SRC})
|
||||||
if(NOT MCPI_HEADLESS_MODE)
|
if(NOT MCPI_HEADLESS_MODE)
|
||||||
target_link_libraries(GLESv1_CM PRIVATE glfw PUBLIC reborn-util PRIVATE dl PRIVATE m)
|
target_link_libraries(GLESv1_CM PRIVATE glfw PUBLIC reborn-util PRIVATE dl PRIVATE m)
|
||||||
|
# Shaders
|
||||||
|
if(MCPI_USE_GLES1_COMPATIBILITY_LAYER)
|
||||||
|
embed_resource(GLESv1_CM src/compatibility-layer/shaders/main.vsh)
|
||||||
|
embed_resource(GLESv1_CM src/compatibility-layer/shaders/main.fsh)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Common
|
# Common
|
||||||
|
@ -54,16 +54,16 @@ static void log_shader(GLuint shader, const char *name) {
|
|||||||
ERR("Failed To Compile %s Shader", name);
|
ERR("Failed To Compile %s Shader", name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static GLuint compile_shader(const char *vertex_shader_text, const char *fragment_shader_text) {
|
static GLuint compile_shader(const char *vertex_shader_text, const int vertex_shader_length, const char *fragment_shader_text, const int fragment_shader_length) {
|
||||||
// Vertex Shader
|
// Vertex Shader
|
||||||
const GLuint vertex_shader = real_glCreateShader()(REAL_GL_VERTEX_SHADER);
|
const GLuint vertex_shader = real_glCreateShader()(REAL_GL_VERTEX_SHADER);
|
||||||
real_glShaderSource()(vertex_shader, 1, &vertex_shader_text, NULL);
|
real_glShaderSource()(vertex_shader, 1, &vertex_shader_text, &vertex_shader_length);
|
||||||
real_glCompileShader()(vertex_shader);
|
real_glCompileShader()(vertex_shader);
|
||||||
log_shader(vertex_shader, "Vertex");
|
log_shader(vertex_shader, "Vertex");
|
||||||
|
|
||||||
// Fragment Shader
|
// Fragment Shader
|
||||||
const GLuint fragment_shader = real_glCreateShader()(REAL_GL_FRAGMENT_SHADER);
|
const GLuint fragment_shader = real_glCreateShader()(REAL_GL_FRAGMENT_SHADER);
|
||||||
real_glShaderSource()(fragment_shader, 1, &fragment_shader_text, NULL);
|
real_glShaderSource()(fragment_shader, 1, &fragment_shader_text, &fragment_shader_length);
|
||||||
real_glCompileShader()(fragment_shader);
|
real_glCompileShader()(fragment_shader);
|
||||||
log_shader(fragment_shader, "Fragment");
|
log_shader(fragment_shader, "Fragment");
|
||||||
|
|
||||||
@ -78,70 +78,14 @@ static GLuint compile_shader(const char *vertex_shader_text, const char *fragmen
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Shader
|
// Shader
|
||||||
|
extern unsigned char main_vsh[];
|
||||||
|
extern size_t main_vsh_len;
|
||||||
|
extern unsigned char main_fsh[];
|
||||||
|
extern size_t main_fsh_len;
|
||||||
static GLuint get_shader() {
|
static GLuint get_shader() {
|
||||||
static GLuint program = 0;
|
static GLuint program = 0;
|
||||||
if (program == 0) {
|
if (program == 0) {
|
||||||
static const char *vertex_shader_text =
|
program = compile_shader((const char *) main_vsh, main_vsh_len, (const char *) main_fsh, main_fsh_len);
|
||||||
"#version 100\n"
|
|
||||||
"precision mediump float;\n"
|
|
||||||
// Matrices
|
|
||||||
"uniform mat4 u_projection;\n"
|
|
||||||
"uniform mat4 u_model_view;\n"
|
|
||||||
"uniform mat4 u_texture;\n"
|
|
||||||
// Texture
|
|
||||||
"attribute vec3 a_vertex_coords;\n"
|
|
||||||
"attribute vec2 a_texture_coords;\n"
|
|
||||||
"varying vec4 v_texture_pos;\n"
|
|
||||||
// Color
|
|
||||||
"attribute vec4 a_color;\n"
|
|
||||||
"varying vec4 v_color;\n"
|
|
||||||
// Fog
|
|
||||||
"varying vec4 v_fog_eye_position;\n"
|
|
||||||
// Main
|
|
||||||
"void main() {\n"
|
|
||||||
" v_texture_pos = u_texture * vec4(a_texture_coords.xy, 0.0, 1.0);\n"
|
|
||||||
" gl_Position = u_projection * u_model_view * vec4(a_vertex_coords.xyz, 1.0);\n"
|
|
||||||
" v_color = a_color;\n"
|
|
||||||
" v_fog_eye_position = u_model_view * vec4(a_vertex_coords.xyz, 1.0);\n"
|
|
||||||
"}";
|
|
||||||
static const char *fragment_shader_text =
|
|
||||||
"#version 100\n"
|
|
||||||
"precision mediump float;\n"
|
|
||||||
// Texture
|
|
||||||
"uniform bool u_has_texture;"
|
|
||||||
"uniform sampler2D u_texture_unit;\n"
|
|
||||||
// Color
|
|
||||||
"varying vec4 v_color;\n"
|
|
||||||
"varying vec4 v_texture_pos;\n"
|
|
||||||
// Alpha Test
|
|
||||||
"uniform bool u_alpha_test;\n"
|
|
||||||
// Fog
|
|
||||||
"uniform bool u_fog;\n"
|
|
||||||
"uniform vec4 u_fog_color;\n"
|
|
||||||
"uniform bool u_fog_is_linear;\n"
|
|
||||||
"uniform float u_fog_start;\n"
|
|
||||||
"uniform float u_fog_end;\n"
|
|
||||||
"varying vec4 v_fog_eye_position;\n"
|
|
||||||
// Main
|
|
||||||
"void main(void) {\n"
|
|
||||||
" gl_FragColor = v_color;\n"
|
|
||||||
" if (u_has_texture) {\n"
|
|
||||||
" gl_FragColor *= texture2D(u_texture_unit, v_texture_pos.xy);\n"
|
|
||||||
" }\n"
|
|
||||||
" if (u_alpha_test && gl_FragColor.a <= 0.1) {\n"
|
|
||||||
" discard;\n"
|
|
||||||
" }\n"
|
|
||||||
" if (u_fog) {\n"
|
|
||||||
" float fog_factor;\n"
|
|
||||||
" if (u_fog_is_linear) {\n"
|
|
||||||
" fog_factor = (u_fog_end - length(v_fog_eye_position)) / (u_fog_end - u_fog_start);\n"
|
|
||||||
" } else {\n"
|
|
||||||
" fog_factor = exp(-u_fog_start * length(v_fog_eye_position));\n"
|
|
||||||
" }\n"
|
|
||||||
" gl_FragColor = mix(gl_FragColor, u_fog_color, 1.0 - clamp(fog_factor, 0.0, 1.0));\n"
|
|
||||||
" }\n"
|
|
||||||
"}";
|
|
||||||
program = compile_shader(vertex_shader_text, fragment_shader_text);
|
|
||||||
}
|
}
|
||||||
return program;
|
return program;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
#version 100
|
||||||
|
precision mediump float;
|
||||||
|
// Texture
|
||||||
|
uniform bool u_has_texture;
|
||||||
|
uniform sampler2D u_texture_unit;
|
||||||
|
// Color
|
||||||
|
varying vec4 v_color;
|
||||||
|
varying vec4 v_texture_pos;
|
||||||
|
// Alpha Test
|
||||||
|
uniform bool u_alpha_test;
|
||||||
|
// Fog
|
||||||
|
uniform bool u_fog;
|
||||||
|
uniform vec4 u_fog_color;
|
||||||
|
uniform bool u_fog_is_linear;
|
||||||
|
uniform float u_fog_start;
|
||||||
|
uniform float u_fog_end;
|
||||||
|
varying vec4 v_fog_eye_position;
|
||||||
|
// Main
|
||||||
|
void main(void) {
|
||||||
|
gl_FragColor = v_color;
|
||||||
|
// Texture
|
||||||
|
if (u_has_texture) {
|
||||||
|
gl_FragColor *= texture2D(u_texture_unit, v_texture_pos.xy);
|
||||||
|
}
|
||||||
|
// Alpha Test
|
||||||
|
if (u_alpha_test && gl_FragColor.a <= 0.1) {
|
||||||
|
discard;
|
||||||
|
}
|
||||||
|
// Fog
|
||||||
|
if (u_fog) {
|
||||||
|
float fog_factor;
|
||||||
|
if (u_fog_is_linear) {
|
||||||
|
fog_factor = (u_fog_end - length(v_fog_eye_position)) / (u_fog_end - u_fog_start);
|
||||||
|
} else {
|
||||||
|
fog_factor = exp(-u_fog_start * length(v_fog_eye_position));
|
||||||
|
}
|
||||||
|
gl_FragColor = mix(gl_FragColor, u_fog_color, 1.0 - clamp(fog_factor, 0.0, 1.0));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
#version 100
|
||||||
|
precision mediump float;
|
||||||
|
// Matrices
|
||||||
|
uniform mat4 u_projection;
|
||||||
|
uniform mat4 u_model_view;
|
||||||
|
uniform mat4 u_texture;
|
||||||
|
// Texture
|
||||||
|
attribute vec3 a_vertex_coords;
|
||||||
|
attribute vec2 a_texture_coords;
|
||||||
|
varying vec4 v_texture_pos;
|
||||||
|
// Color
|
||||||
|
attribute vec4 a_color;
|
||||||
|
varying vec4 v_color;
|
||||||
|
// Fog
|
||||||
|
varying vec4 v_fog_eye_position;
|
||||||
|
// Main
|
||||||
|
void main(void) {
|
||||||
|
v_texture_pos = u_texture * vec4(a_texture_coords.xy, 0.0, 1.0);
|
||||||
|
gl_Position = u_projection * u_model_view * vec4(a_vertex_coords.xyz, 1.0);
|
||||||
|
v_color = a_color;
|
||||||
|
v_fog_eye_position = u_model_view * vec4(a_vertex_coords.xyz, 1.0);
|
||||||
|
}
|
@ -155,34 +155,42 @@ static void glfw_key(__attribute__((unused)) GLFWwindow *window, int key, int sc
|
|||||||
event.key.keysym.mod = glfw_modifier_to_sdl_modifier(mods);
|
event.key.keysym.mod = glfw_modifier_to_sdl_modifier(mods);
|
||||||
event.key.keysym.sym = glfw_key_to_sdl_key(key);
|
event.key.keysym.sym = glfw_key_to_sdl_key(key);
|
||||||
SDL_PushEvent(&event);
|
SDL_PushEvent(&event);
|
||||||
if (key == GLFW_KEY_BACKSPACE && !up) {
|
|
||||||
character_event('\b');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass Text To Minecraft
|
// Pass Text To Minecraft
|
||||||
|
static void codepoint_to_utf8(unsigned char *const buffer, const unsigned int code) {
|
||||||
|
// https://stackoverflow.com/a/42013433/16198887
|
||||||
|
if (code <= 0x7f) {
|
||||||
|
buffer[0] = code;
|
||||||
|
} else if (code <= 0x7ff) {
|
||||||
|
buffer[0] = 0xc0 | (code >> 6); // 110xxxxx
|
||||||
|
buffer[1] = 0x80 | (code & 0x3f); // 10xxxxxx
|
||||||
|
} else if (code <= 0xffff) {
|
||||||
|
buffer[0] = 0xe0 | (code >> 12); // 1110xxxx
|
||||||
|
buffer[1] = 0x80 | ((code >> 6) & 0x3f); // 10xxxxxx
|
||||||
|
buffer[2] = 0x80 | (code & 0x3f); // 10xxxxxx
|
||||||
|
} else if (code <= 0x10ffff) {
|
||||||
|
buffer[0] = 0xf0 | (code >> 18); // 11110xxx
|
||||||
|
buffer[1] = 0x80 | ((code >> 12) & 0x3f); // 10xxxxxx
|
||||||
|
buffer[2] = 0x80 | ((code >> 6) & 0x3f); // 10xxxxxx
|
||||||
|
buffer[3] = 0x80 | (code & 0x3f); // 10xxxxxx
|
||||||
|
}
|
||||||
|
}
|
||||||
static void glfw_char(__attribute__((unused)) GLFWwindow *window, unsigned int codepoint) {
|
static void glfw_char(__attribute__((unused)) GLFWwindow *window, unsigned int codepoint) {
|
||||||
if (is_interactable) {
|
if (is_interactable) {
|
||||||
// Signs Only Accepts ASCII Characters
|
// Convert
|
||||||
size_t in_size = 4; // 1 UTF-32LE Codepoint
|
size_t str_size = 4 /* Maximum UTF-8 character size */ + 1 /* NULL-terminator */;
|
||||||
size_t out_size = 4; // 4 ASCII Characters Max
|
char str[str_size];
|
||||||
size_t real_out_size = out_size + 1 /* NULL-terminator */;
|
memset(str, 0, str_size);
|
||||||
char *output = (char *) malloc(real_out_size);
|
codepoint_to_utf8((unsigned char *) str, codepoint);
|
||||||
ALLOC_CHECK(output);
|
char *cp437_str = to_cp437(str);
|
||||||
memset(output, 0, real_out_size);
|
// Send Event·
|
||||||
iconv_t cd = iconv_open("ASCII//TRANSLIT", "UTF-32LE");
|
for (int i = 0; cp437_str[i] != '\0'; i++) {
|
||||||
if (cd != (iconv_t) -1) {
|
character_event(cp437_str[i]);
|
||||||
safe_iconv(cd, (char *) &codepoint, in_size, output, out_size);
|
|
||||||
iconv_close(cd);
|
|
||||||
} else {
|
|
||||||
IMPOSSIBLE();
|
|
||||||
}
|
|
||||||
for (size_t i = 0; output[i] != '\0'; i++) {
|
|
||||||
character_event(output[i]);
|
|
||||||
}
|
}
|
||||||
// Free
|
// Free
|
||||||
free(output);
|
free(cp437_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,6 +316,9 @@ void SDL_WM_SetCaption(const char *title, __attribute__((unused)) const char *ic
|
|||||||
// Extra Settings
|
// Extra Settings
|
||||||
glfwWindowHint(GLFW_AUTO_ICONIFY, GLFW_FALSE);
|
glfwWindowHint(GLFW_AUTO_ICONIFY, GLFW_FALSE);
|
||||||
glfwWindowHint(GLFW_ALPHA_BITS, 0); // Fix Transparent Window On Wayland
|
glfwWindowHint(GLFW_ALPHA_BITS, 0); // Fix Transparent Window On Wayland
|
||||||
|
// App ID
|
||||||
|
glfwWindowHintString(GLFW_X11_CLASS_NAME, MCPI_APP_ID);
|
||||||
|
glfwWindowHintString(GLFW_WAYLAND_APP_ID, MCPI_APP_ID);
|
||||||
|
|
||||||
// Create Window
|
// Create Window
|
||||||
glfw_window = glfwCreateWindow(DEFAULT_WIDTH, DEFAULT_HEIGHT, title, NULL, NULL);
|
glfw_window = glfwCreateWindow(DEFAULT_WIDTH, DEFAULT_HEIGHT, title, NULL, NULL);
|
||||||
|
@ -66,7 +66,7 @@ else()
|
|||||||
target_link_libraries(input mods-headers reborn-patch symbols creative feature misc media-layer-core)
|
target_link_libraries(input mods-headers reborn-patch symbols creative feature misc media-layer-core)
|
||||||
|
|
||||||
add_library(sign SHARED src/sign/sign.cpp)
|
add_library(sign SHARED src/sign/sign.cpp)
|
||||||
target_link_libraries(sign mods-headers reborn-patch symbols feature input)
|
target_link_libraries(sign mods-headers reborn-patch symbols feature input media-layer-core)
|
||||||
|
|
||||||
add_library(touch SHARED src/touch/touch.cpp)
|
add_library(touch SHARED src/touch/touch.cpp)
|
||||||
target_link_libraries(touch mods-headers reborn-patch symbols feature)
|
target_link_libraries(touch mods-headers reborn-patch symbols feature)
|
||||||
|
@ -32,15 +32,14 @@ static int32_t BucketItem_getIcon(__attribute__((unused)) unsigned char *item, i
|
|||||||
static int32_t BucketItem_useOn(__attribute__((unused)) unsigned char *item, ItemInstance *item_instance, unsigned char *player, unsigned char *level, int32_t x, int32_t y, int32_t z, int32_t hit_side, __attribute__((unused)) float hit_x, __attribute__((unused)) float hit_y, __attribute__((unused)) float hit_z) {
|
static int32_t BucketItem_useOn(__attribute__((unused)) unsigned char *item, ItemInstance *item_instance, unsigned char *player, unsigned char *level, int32_t x, int32_t y, int32_t z, int32_t hit_side, __attribute__((unused)) float hit_x, __attribute__((unused)) float hit_y, __attribute__((unused)) float hit_z) {
|
||||||
if (item_instance->count < 1) {
|
if (item_instance->count < 1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else if (item_instance->auxiliary == 0) {
|
||||||
if (item_instance->auxiliary == 0) {
|
|
||||||
// Empty Bucket
|
// Empty Bucket
|
||||||
int32_t new_auxiliary = 0;
|
int32_t new_auxiliary = 0;
|
||||||
int32_t tile = (*Level_getTile)(level, x, y, z);
|
int32_t tile = (*Level_getTile)(level, x, y, z);
|
||||||
if (tile == *(int32_t *) (*Tile_calmWater + Tile_id_property_offset)) {
|
if (tile == *(int32_t *) (*Tile_calmWater + Tile_id_property_offset)) {
|
||||||
new_auxiliary = *(int32_t *) (*Tile_water + Tile_id_property_offset);
|
new_auxiliary = *(int32_t *) (*Tile_water + Tile_id_property_offset);
|
||||||
} else if (tile == *(int32_t *) (*Tile_calmLava + Tile_id_property_offset)) {
|
} else if (tile == *(int32_t *) (*Tile_calmLava + Tile_id_property_offset)) {
|
||||||
new_auxiliary = *(int32_t *) (*Tile_water + Tile_id_property_offset);
|
new_auxiliary = *(int32_t *) (*Tile_lava + Tile_id_property_offset);
|
||||||
}
|
}
|
||||||
if (new_auxiliary != 0) {
|
if (new_auxiliary != 0) {
|
||||||
// Valid
|
// Valid
|
||||||
@ -108,6 +107,9 @@ static int32_t BucketItem_useOn(__attribute__((unused)) unsigned char *item, Ite
|
|||||||
Material_isSolid_t Material_isSolid = *(Material_isSolid_t *) (material_vtable + Material_isSolid_vtable_offset);
|
Material_isSolid_t Material_isSolid = *(Material_isSolid_t *) (material_vtable + Material_isSolid_vtable_offset);
|
||||||
valid = !(*Material_isSolid)(material);
|
valid = !(*Material_isSolid)(material);
|
||||||
}
|
}
|
||||||
|
if (item_instance->auxiliary != *(int32_t *) (*Tile_water + Tile_id_property_offset) && item_instance->auxiliary != *(int32_t *) (*Tile_lava + Tile_id_property_offset)) {
|
||||||
|
valid = false;
|
||||||
|
}
|
||||||
if (valid) {
|
if (valid) {
|
||||||
(*Level_setTileAndData)(level, x, y, z, item_instance->auxiliary, 0);
|
(*Level_setTileAndData)(level, x, y, z, item_instance->auxiliary, 0);
|
||||||
item_instance->auxiliary = 0;
|
item_instance->auxiliary = 0;
|
||||||
|
@ -29,7 +29,7 @@ static void *chat_thread(__attribute__((unused)) void *nop) {
|
|||||||
const char *command[] = {
|
const char *command[] = {
|
||||||
"zenity",
|
"zenity",
|
||||||
"--title", DIALOG_TITLE,
|
"--title", DIALOG_TITLE,
|
||||||
"--name", MCPI_APP_TITLE,
|
"--name", MCPI_APP_ID,
|
||||||
"--entry",
|
"--entry",
|
||||||
"--text", "Enter Chat Message:",
|
"--text", "Enter Chat Message:",
|
||||||
NULL
|
NULL
|
||||||
|
@ -88,7 +88,7 @@ static void *create_world_thread(__attribute__((unused)) void *nop) {
|
|||||||
const char *command[] = {
|
const char *command[] = {
|
||||||
"zenity",
|
"zenity",
|
||||||
"--title", DIALOG_TITLE,
|
"--title", DIALOG_TITLE,
|
||||||
"--name", MCPI_APP_TITLE,
|
"--name", MCPI_APP_ID,
|
||||||
"--entry",
|
"--entry",
|
||||||
"--text", "Enter World Name:",
|
"--text", "Enter World Name:",
|
||||||
"--entry-text", DEFAULT_WORLD_NAME,
|
"--entry-text", DEFAULT_WORLD_NAME,
|
||||||
@ -115,7 +115,7 @@ static void *create_world_thread(__attribute__((unused)) void *nop) {
|
|||||||
const char *command[] = {
|
const char *command[] = {
|
||||||
"zenity",
|
"zenity",
|
||||||
"--title", DIALOG_TITLE,
|
"--title", DIALOG_TITLE,
|
||||||
"--name", MCPI_APP_TITLE,
|
"--name", MCPI_APP_ID,
|
||||||
"--list",
|
"--list",
|
||||||
"--radiolist",
|
"--radiolist",
|
||||||
"--width", GAME_MODE_DIALOG_SIZE,
|
"--width", GAME_MODE_DIALOG_SIZE,
|
||||||
@ -148,7 +148,7 @@ static void *create_world_thread(__attribute__((unused)) void *nop) {
|
|||||||
const char *command[] = {
|
const char *command[] = {
|
||||||
"zenity",
|
"zenity",
|
||||||
"--title", DIALOG_TITLE,
|
"--title", DIALOG_TITLE,
|
||||||
"--name", MCPI_APP_TITLE,
|
"--name", MCPI_APP_ID,
|
||||||
"--entry",
|
"--entry",
|
||||||
"--only-numerical",
|
"--only-numerical",
|
||||||
"--text", "Enter Seed (Leave Blank For Random):",
|
"--text", "Enter Seed (Leave Blank For Random):",
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <SDL/SDL.h>
|
||||||
#include <libreborn/libreborn.h>
|
#include <libreborn/libreborn.h>
|
||||||
#include <symbols/minecraft.h>
|
#include <symbols/minecraft.h>
|
||||||
|
|
||||||
@ -8,6 +9,16 @@
|
|||||||
#include <mods/input/input.h>
|
#include <mods/input/input.h>
|
||||||
#include <mods/sign/sign.h>
|
#include <mods/sign/sign.h>
|
||||||
|
|
||||||
|
// Handle Backspace
|
||||||
|
static int32_t sdl_key_to_minecraft_key_injection(int32_t sdl_key) {
|
||||||
|
if (sdl_key == SDLK_BACKSPACE) {
|
||||||
|
return 8;
|
||||||
|
} else {
|
||||||
|
// Call Original Method
|
||||||
|
return (*sdl_key_to_minecraft_key)(sdl_key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Open Sign Screen
|
// Open Sign Screen
|
||||||
static void LocalPlayer_openTextEdit_injection(unsigned char *local_player, unsigned char *sign) {
|
static void LocalPlayer_openTextEdit_injection(unsigned char *local_player, unsigned char *sign) {
|
||||||
if (*(int32_t *) (sign + TileEntity_id_property_offset) == 4) {
|
if (*(int32_t *) (sign + TileEntity_id_property_offset) == 4) {
|
||||||
@ -19,19 +30,11 @@ static void LocalPlayer_openTextEdit_injection(unsigned char *local_player, unsi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define BACKSPACE_KEY 8
|
|
||||||
|
|
||||||
static int is_valid_key(char key) {
|
|
||||||
return (key >= 32 && key <= 126) || key == BACKSPACE_KEY;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store Text Input
|
// Store Text Input
|
||||||
std::vector<char> input;
|
std::vector<char> input;
|
||||||
void sign_key_press(char key) {
|
void sign_key_press(char key) {
|
||||||
if (is_valid_key(key)) {
|
|
||||||
input.push_back(key);
|
input.push_back(key);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
static void clear_input(__attribute__((unused)) unsigned char *minecraft) {
|
static void clear_input(__attribute__((unused)) unsigned char *minecraft) {
|
||||||
input.clear();
|
input.clear();
|
||||||
}
|
}
|
||||||
@ -41,28 +44,25 @@ static void TextEditScreen_updateEvents_injection(unsigned char *screen) {
|
|||||||
// Call Original Method
|
// Call Original Method
|
||||||
(*Screen_updateEvents)(screen);
|
(*Screen_updateEvents)(screen);
|
||||||
|
|
||||||
if (*(char *)(screen + 4) == '\0') {
|
if (!*(bool *)(screen + Screen_passthrough_input_property_offset)) {
|
||||||
unsigned char *vtable = *(unsigned char **) screen;
|
unsigned char *vtable = *(unsigned char **) screen;
|
||||||
for (char key : input) {
|
for (char key : input) {
|
||||||
if (key == BACKSPACE_KEY) {
|
|
||||||
// Handle Backspace
|
|
||||||
(*(Screen_keyPressed_t *) (vtable + Screen_keyPressed_vtable_offset))(screen, BACKSPACE_KEY);
|
|
||||||
} else {
|
|
||||||
// Handle Normal Key
|
// Handle Normal Key
|
||||||
(*(Screen_keyboardNewChar_t *) (vtable + Screen_keyboardNewChar_vtable_offset))(screen, key);
|
(*(Screen_keyboardNewChar_t *) (vtable + Screen_keyboardNewChar_vtable_offset))(screen, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
clear_input(NULL);
|
clear_input(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init
|
// Init
|
||||||
void init_sign() {
|
void init_sign() {
|
||||||
if (feature_has("Fix Sign Placement", server_disabled)) {
|
if (feature_has("Fix Sign Placement", server_disabled)) {
|
||||||
|
// Handle Backspace
|
||||||
|
overwrite_calls((void *) sdl_key_to_minecraft_key, (void *) sdl_key_to_minecraft_key_injection);
|
||||||
// Fix Signs
|
// Fix Signs
|
||||||
patch_address(LocalPlayer_openTextEdit_vtable_addr, (void *) LocalPlayer_openTextEdit_injection);
|
patch_address(LocalPlayer_openTextEdit_vtable_addr, (void *) LocalPlayer_openTextEdit_injection);
|
||||||
patch_address(TextEditScreen_updateEvents_vtable_addr, (void *) TextEditScreen_updateEvents_injection);
|
patch_address(TextEditScreen_updateEvents_vtable_addr, (void *) TextEditScreen_updateEvents_injection);
|
||||||
// Clear input On Input Tick
|
// Clear Input On Input Tick
|
||||||
input_run_on_tick(clear_input);
|
input_run_on_tick(clear_input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,20 +11,22 @@ build() {
|
|||||||
cd "build/${MODE}-${ARCH}"
|
cd "build/${MODE}-${ARCH}"
|
||||||
|
|
||||||
# Create Prefix
|
# Create Prefix
|
||||||
local prefix="$(cd ../../; pwd)/out/${MODE}-${ARCH}"
|
if [ -z "${DESTDIR+x}" ]; then
|
||||||
rm -rf "${prefix}"
|
export DESTDIR="$(cd ../../; pwd)/out/${MODE}-${ARCH}"
|
||||||
mkdir -p "${prefix}"
|
rm -rf "${DESTDIR}"
|
||||||
|
mkdir -p "${DESTDIR}"
|
||||||
|
fi
|
||||||
|
|
||||||
# Build ARM Components
|
# Build ARM Components
|
||||||
cd arm
|
cd arm
|
||||||
cmake --build .
|
cmake --build .
|
||||||
DESTDIR="${prefix}" cmake --install .
|
cmake --install .
|
||||||
cd ../
|
cd ../
|
||||||
|
|
||||||
# Build Native Components
|
# Build Native Components
|
||||||
cd native
|
cd native
|
||||||
cmake --build .
|
cmake --build .
|
||||||
DESTDIR="${prefix}" cmake --install .
|
cmake --install .
|
||||||
cd ../
|
cd ../
|
||||||
|
|
||||||
# Exit
|
# Exit
|
||||||
|
@ -30,8 +30,7 @@ run() {
|
|||||||
|
|
||||||
# Host Dependencies Needed For Compile
|
# Host Dependencies Needed For Compile
|
||||||
queue_pkg \
|
queue_pkg \
|
||||||
libwayland-bin \
|
libwayland-bin
|
||||||
xxd
|
|
||||||
|
|
||||||
# Host Dependencies Needed For Running
|
# Host Dependencies Needed For Running
|
||||||
queue_pkg \
|
queue_pkg \
|
||||||
|
@ -18,6 +18,9 @@ static renderCursor_t renderCursor = (renderCursor_t) 0x480c4;
|
|||||||
typedef void (*sleepMs_t)(int32_t x);
|
typedef void (*sleepMs_t)(int32_t x);
|
||||||
static sleepMs_t sleepMs = (sleepMs_t) 0x13cf4;
|
static sleepMs_t sleepMs = (sleepMs_t) 0x13cf4;
|
||||||
|
|
||||||
|
typedef int32_t (*sdl_key_to_minecraft_key_t)(int32_t sdl_key);
|
||||||
|
static sdl_key_to_minecraft_key_t sdl_key_to_minecraft_key = (sdl_key_to_minecraft_key_t) 0x1243c;
|
||||||
|
|
||||||
static char **default_path = (char **) 0xe264; // /.minecraft/
|
static char **default_path = (char **) 0xe264; // /.minecraft/
|
||||||
static char **default_username = (char **) 0x18fd4; // StevePi
|
static char **default_username = (char **) 0x18fd4; // StevePi
|
||||||
static char **minecraft_pi_version = (char **) 0x39d94; // v0.1.1 alpha
|
static char **minecraft_pi_version = (char **) 0x39d94; // v0.1.1 alpha
|
||||||
@ -554,6 +557,7 @@ static uint32_t Screen_rendered_buttons_property_offset = 0x18; // std::vector<B
|
|||||||
static uint32_t Screen_selectable_buttons_property_offset = 0x30; // std::vector<Button *>
|
static uint32_t Screen_selectable_buttons_property_offset = 0x30; // std::vector<Button *>
|
||||||
static uint32_t Screen_width_property_offset = 0x8; // int32_t
|
static uint32_t Screen_width_property_offset = 0x8; // int32_t
|
||||||
static uint32_t Screen_height_property_offset = 0xc; // int32_t
|
static uint32_t Screen_height_property_offset = 0xc; // int32_t
|
||||||
|
static uint32_t Screen_passthrough_input_property_offset = 0x10; // bool
|
||||||
|
|
||||||
// Button
|
// Button
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user