Compare commits
No commits in common. "master" and "2.4.2" have entirely different histories.
|
@ -115,37 +115,30 @@ 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
|
# Optimizations
|
||||||
string(CONCAT COMPILE_FLAGS_SETUP
|
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||||
# Optimizations
|
add_compile_options(-O3 -s)
|
||||||
"if(CMAKE_BUILD_TYPE STREQUAL \"Release\")\n"
|
else()
|
||||||
" add_compile_options(-O3 -s)\n"
|
add_compile_options(-g)
|
||||||
"else()\n"
|
endif()
|
||||||
" add_compile_options(-g)\n"
|
|
||||||
"endif()\n"
|
|
||||||
|
|
||||||
# PIC
|
# Use LLD When Using Clang
|
||||||
"set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)\n"
|
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||||
|
add_link_options("-fuse-ld=lld")
|
||||||
|
endif()
|
||||||
|
|
||||||
# Warnings
|
# PIC
|
||||||
"add_link_options(-Wl,--no-undefined)\n"
|
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||||
|
|
||||||
# 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)
|
||||||
|
@ -154,9 +147,10 @@ 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)
|
||||||
# Buld Dependencies
|
add_definitions(-D_GNU_SOURCE)
|
||||||
add_subdirectory(dependencies)
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
# Version
|
# Version
|
||||||
set_property(
|
set_property(
|
||||||
|
@ -195,15 +189,5 @@ endif()
|
||||||
|
|
||||||
# Install SDK
|
# Install SDK
|
||||||
if(BUILD_ARM_COMPONENTS)
|
if(BUILD_ARM_COMPONENTS)
|
||||||
install(EXPORT sdk DESTINATION "${MCPI_SDK_DIR}" FILE "sdk-targets.cmake" EXPORT_LINK_INTERFACE_LIBRARIES)
|
install(EXPORT sdk DESTINATION "${MCPI_SDK_DIR}" EXPORT_LINK_INTERFACE_LIBRARIES)
|
||||||
string(CONCAT SDK_SETUP
|
|
||||||
# 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"
|
|
||||||
)
|
|
||||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/sdk.cmake" "${SDK_SETUP}")
|
|
||||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/sdk.cmake" DESTINATION "${MCPI_SDK_DIR}")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
**2.4.3**
|
|
||||||
* Fix Signs With CP-437
|
|
||||||
|
|
||||||
**2.4.2**
|
**2.4.2**
|
||||||
* Fix Picking Up Lava
|
* Fix Picking Up Lava
|
||||||
* Fix Wayland App ID
|
* Fix Wayland App ID
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Example Mods
|
# Example Mods
|
||||||
This is an example of a mod that can be built using the modding SDK.
|
This is an example of a mod that cane 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 |
|
@ -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 Access: %s: %s", name, strerror(errno));
|
WARN("Unable To Acesss: %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 = NULL;
|
char *new_path;
|
||||||
safe_asprintf(&new_path, "%s/bin", binary_directory);
|
safe_asprintf(&new_path, "%s/bin", binary_directory);
|
||||||
// Add Existing PATH
|
// Add Existing PATH
|
||||||
{
|
{
|
||||||
|
@ -332,6 +332,7 @@ 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)
|
||||||
|
@ -343,7 +344,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(&mcpi_ld_path, ":%s", value);
|
string_append(&transitive_ld_path, ":%s", value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,42 +155,34 @@ 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) {
|
||||||
// Convert
|
// Signs Only Accepts ASCII Characters
|
||||||
size_t str_size = 4 /* Maximum UTF-8 character size */ + 1 /* NULL-terminator */;
|
size_t in_size = 4; // 1 UTF-32LE Codepoint
|
||||||
char str[str_size];
|
size_t out_size = 4; // 4 ASCII Characters Max
|
||||||
memset(str, 0, str_size);
|
size_t real_out_size = out_size + 1 /* NULL-terminator */;
|
||||||
codepoint_to_utf8((unsigned char *) str, codepoint);
|
char *output = (char *) malloc(real_out_size);
|
||||||
char *cp437_str = to_cp437(str);
|
ALLOC_CHECK(output);
|
||||||
// Send Event·
|
memset(output, 0, real_out_size);
|
||||||
for (int i = 0; cp437_str[i] != '\0'; i++) {
|
iconv_t cd = iconv_open("ASCII//TRANSLIT", "UTF-32LE");
|
||||||
character_event(cp437_str[i]);
|
if (cd != (iconv_t) -1) {
|
||||||
|
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(cp437_str);
|
free(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 media-layer-core)
|
target_link_libraries(sign mods-headers reborn-patch symbols feature input)
|
||||||
|
|
||||||
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)
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <SDL/SDL.h>
|
|
||||||
#include <libreborn/libreborn.h>
|
#include <libreborn/libreborn.h>
|
||||||
#include <symbols/minecraft.h>
|
#include <symbols/minecraft.h>
|
||||||
|
|
||||||
|
@ -9,16 +8,6 @@
|
||||||
#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) {
|
||||||
|
@ -30,10 +19,18 @@ 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();
|
||||||
|
@ -44,25 +41,28 @@ static void TextEditScreen_updateEvents_injection(unsigned char *screen) {
|
||||||
// Call Original Method
|
// Call Original Method
|
||||||
(*Screen_updateEvents)(screen);
|
(*Screen_updateEvents)(screen);
|
||||||
|
|
||||||
if (!*(bool *)(screen + Screen_passthrough_input_property_offset)) {
|
if (*(char *)(screen + 4) == '\0') {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,6 @@ 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
|
||||||
|
@ -557,7 +554,6 @@ 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