From 91ee97f0054ccc2cdcb758d59d71eeb0793c7312 Mon Sep 17 00:00:00 2001 From: Bigjango13 Date: Sun, 7 Apr 2024 20:29:23 -0700 Subject: [PATCH] Fix HOOKing mods --- mods/include/mods/chat/chat.h | 2 ++ mods/include/mods/compat/compat.h | 2 ++ mods/include/mods/creative/creative.h | 4 +++- mods/include/mods/feature/feature.h | 2 ++ mods/include/mods/home/home.h | 2 ++ mods/include/mods/init/init.h | 4 +++- mods/include/mods/input/input.h | 2 ++ mods/include/mods/misc/misc.h | 2 ++ mods/include/mods/override/override.h | 2 ++ mods/include/mods/screenshot/screenshot.h | 2 ++ mods/include/mods/server/server.h | 2 ++ mods/include/mods/sign/sign.h | 4 +++- mods/include/mods/textures/textures.h | 2 ++ mods/include/mods/title-screen/title-screen.h | 2 ++ mods/include/mods/touch/touch.h | 2 ++ mods/include/mods/version/version.h | 2 ++ symbols/src/level/Level.def | 5 ++++- symbols/src/level/LevelData.def | 4 ++++ 18 files changed, 43 insertions(+), 4 deletions(-) diff --git a/mods/include/mods/chat/chat.h b/mods/include/mods/chat/chat.h index 8fb3c45e..e9f44379 100644 --- a/mods/include/mods/chat/chat.h +++ b/mods/include/mods/chat/chat.h @@ -5,9 +5,11 @@ #include #include +extern "C" { // Send API Command std::string chat_send_api_command(Minecraft *minecraft, std::string str); // Override using the HOOK() macro to provide customized chat behavior. void chat_send_message(ServerSideNetworkHandler *server_side_network_handler, char *username, char *message); void chat_handle_packet_send(Minecraft *minecraft, ChatPacket *packet); +}; diff --git a/mods/include/mods/compat/compat.h b/mods/include/mods/compat/compat.h index c307bc7d..75262de9 100644 --- a/mods/include/mods/compat/compat.h +++ b/mods/include/mods/compat/compat.h @@ -1,4 +1,6 @@ #pragma once +extern "C" { int compat_check_exit_requested(); void compat_request_exit(); +} \ No newline at end of file diff --git a/mods/include/mods/creative/creative.h b/mods/include/mods/creative/creative.h index 2b6f63e3..e073d923 100644 --- a/mods/include/mods/creative/creative.h +++ b/mods/include/mods/creative/creative.h @@ -1,3 +1,5 @@ #pragma once -int creative_is_restricted(); \ No newline at end of file +extern "C" { +int creative_is_restricted(); +} \ No newline at end of file diff --git a/mods/include/mods/feature/feature.h b/mods/include/mods/feature/feature.h index 7eea3ff5..0a0b64c7 100644 --- a/mods/include/mods/feature/feature.h +++ b/mods/include/mods/feature/feature.h @@ -2,7 +2,9 @@ #include +extern "C" { bool _feature_has(const char *name); +} #ifdef MCPI_SERVER_MODE #define _feature_has__server_defaul_is_server_disabled(name) 0 diff --git a/mods/include/mods/home/home.h b/mods/include/mods/home/home.h index 585163af..09e42830 100644 --- a/mods/include/mods/home/home.h +++ b/mods/include/mods/home/home.h @@ -1,3 +1,5 @@ #pragma once +extern "C" { char *home_get(); +} diff --git a/mods/include/mods/init/init.h b/mods/include/mods/init/init.h index 288bebc4..49580292 100644 --- a/mods/include/mods/init/init.h +++ b/mods/include/mods/init/init.h @@ -2,6 +2,7 @@ #include +extern "C" { void run_tests(); void init_version(); void init_compat(); @@ -31,4 +32,5 @@ void init_options(); void init_chat(); void init_bucket(); void init_cake(); -void init_home(); \ No newline at end of file +void init_home(); +} diff --git a/mods/include/mods/input/input.h b/mods/include/mods/input/input.h index 50f98f47..1e7322f3 100644 --- a/mods/include/mods/input/input.h +++ b/mods/include/mods/input/input.h @@ -2,6 +2,7 @@ #include +extern "C" { typedef void (*input_tick_function_t)(Minecraft *minecraft); void input_run_on_tick(input_tick_function_t function); @@ -13,3 +14,4 @@ void input_open_crafting(); void input_set_is_left_click(int val); void input_set_mouse_grab_state(int state); +} \ No newline at end of file diff --git a/mods/include/mods/misc/misc.h b/mods/include/mods/misc/misc.h index e9d6587e..44e410b9 100644 --- a/mods/include/mods/misc/misc.h +++ b/mods/include/mods/misc/misc.h @@ -4,6 +4,7 @@ #include +extern "C" { int32_t misc_get_real_selected_slot(Player *player); typedef void (*misc_update_function_Minecraft_t)(Minecraft *obj); @@ -23,3 +24,4 @@ typedef bool (*misc_update_function_key_press_t)(Minecraft *minecrtaft, int key) void misc_run_on_game_key_press(misc_update_function_key_press_t function); // In-Game Key Presses Only extern bool is_in_chat; +} \ No newline at end of file diff --git a/mods/include/mods/override/override.h b/mods/include/mods/override/override.h index dcd39aa8..d2aae2cf 100644 --- a/mods/include/mods/override/override.h +++ b/mods/include/mods/override/override.h @@ -1,3 +1,5 @@ #pragma once +extern "C" { char *override_get_path(const char *filename); +} \ No newline at end of file diff --git a/mods/include/mods/screenshot/screenshot.h b/mods/include/mods/screenshot/screenshot.h index f0e063dc..2ac4dffe 100644 --- a/mods/include/mods/screenshot/screenshot.h +++ b/mods/include/mods/screenshot/screenshot.h @@ -1,3 +1,5 @@ #pragma once +extern "C" { void screenshot_take(char *home); +} \ No newline at end of file diff --git a/mods/include/mods/server/server.h b/mods/include/mods/server/server.h index a13b93b5..06d19449 100644 --- a/mods/include/mods/server/server.h +++ b/mods/include/mods/server/server.h @@ -2,4 +2,6 @@ #include "server_properties.h" +extern "C" { ServerProperties &get_server_properties(); +} \ No newline at end of file diff --git a/mods/include/mods/sign/sign.h b/mods/include/mods/sign/sign.h index de0a4d43..46e5dd97 100644 --- a/mods/include/mods/sign/sign.h +++ b/mods/include/mods/sign/sign.h @@ -1,3 +1,5 @@ #pragma once -void sign_key_press(char key); \ No newline at end of file +extern "C" { +void sign_key_press(char key); +} \ No newline at end of file diff --git a/mods/include/mods/textures/textures.h b/mods/include/mods/textures/textures.h index 202a4fea..ae24a4d4 100644 --- a/mods/include/mods/textures/textures.h +++ b/mods/include/mods/textures/textures.h @@ -2,4 +2,6 @@ #include +extern "C" { void glTexSubImage2D_with_scaling(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLsizei normal_texture_width, GLsizei normal_texture_height, GLenum format, GLenum type, const void *pixels); +} \ No newline at end of file diff --git a/mods/include/mods/title-screen/title-screen.h b/mods/include/mods/title-screen/title-screen.h index bbe30a43..2426e702 100644 --- a/mods/include/mods/title-screen/title-screen.h +++ b/mods/include/mods/title-screen/title-screen.h @@ -3,4 +3,6 @@ #include #include +extern "C" { void title_screen_load_splashes(std::vector &splashes); +} \ No newline at end of file diff --git a/mods/include/mods/touch/touch.h b/mods/include/mods/touch/touch.h index bba97560..d897efcc 100644 --- a/mods/include/mods/touch/touch.h +++ b/mods/include/mods/touch/touch.h @@ -3,4 +3,6 @@ #include extern int touch_gui; +extern "C" { Button *touch_create_button(int id, std::string text); +} \ No newline at end of file diff --git a/mods/include/mods/version/version.h b/mods/include/mods/version/version.h index 27c1aaa1..065b59a9 100644 --- a/mods/include/mods/version/version.h +++ b/mods/include/mods/version/version.h @@ -1,3 +1,5 @@ #pragma once +extern "C" { char *version_get(); +} \ No newline at end of file diff --git a/symbols/src/level/Level.def b/symbols/src/level/Level.def index 44f1d43d..d5eb5605 100644 --- a/symbols/src/level/Level.def +++ b/symbols/src/level/Level.def @@ -4,7 +4,9 @@ vtable 0x10fcf0; method void saveLevelData() = 0xa2e94; method void setTile(int x, int y, int z, int id) = 0xa3904; +method void setTileNoUpdate(int x, int y, int z, int id) = 0xa342c; method void setData(int x, int y, int z, int data) = 0xa394c; +method void setDataNoUpdate(int x, int y, int z, int data) = 0xa3480; method void setTileAndData(int x, int y, int z, int id, int data) = 0xa38b4; method void setTileAndDataNoUpdate(int x, int y, int z, int id, int data) = 0xa33d0; // Calls setTileDirty and updateNearbyTiles @@ -56,5 +58,6 @@ property std::vector entities = 0x20; property std::vector tileentities = 0x50; property std::vector players = 0x60; property Dimension *dimension = 0x74; -property ChunkSource *chunk_source = 0xa5c; property bool no_update = 0x70; +property ChunkSource *chunk_source = 0xa5c; +property LevelData data = 0xa64; diff --git a/symbols/src/level/LevelData.def b/symbols/src/level/LevelData.def index 0f3758a3..d227ef4b 100644 --- a/symbols/src/level/LevelData.def +++ b/symbols/src/level/LevelData.def @@ -1 +1,5 @@ +method int getTime() = 0xba970; +method void setTime(int time) = 0xbab28; method bool getSpawnMobs() = 0xbabec; + +property int time = 0x68;