Browse Source

Clean Up

master
TheBrokenRail 2 months ago
parent
commit
015235b889
  1. 3
      mods/src/input/bow.c
  2. 3
      mods/src/input/drop.cpp
  3. 15
      mods/src/input/input.cpp
  4. 5
      mods/src/input/input.h
  5. 6
      mods/src/input/misc.c
  6. 3
      mods/src/input/toggle.c
  7. 6
      mods/src/options/options.c
  8. 27
      symbols/include/symbols/minecraft.h

3
mods/src/input/bow.c

@ -14,7 +14,7 @@ void input_set_is_right_click(int val) {
static int fix_bow = 0;
// Handle Bow & Arrow
void _handle_bow(unsigned char *minecraft) {
static void _handle_bow(unsigned char *minecraft) {
if (fix_bow && !is_right_click) {
// GameMode Is Offset From minecraft By 0x160
// Player Is Offset From minecraft By 0x18c
@ -32,4 +32,5 @@ void _handle_bow(unsigned char *minecraft) {
void _init_bow() {
// Enable Bow & Arrow Fix
fix_bow = feature_has("Fix Bow & Arrow", 0);
input_run_on_tick(_handle_bow);
}

3
mods/src/input/drop.cpp

@ -21,7 +21,7 @@ void input_drop(int drop_slot) {
}
// Handle Drop Item Presses
void _handle_drop(unsigned char *minecraft) {
static void _handle_drop(unsigned char *minecraft) {
if (!(*Minecraft_isCreativeMode)(minecraft) && (drop_item_presses > 0 || drop_slot_pressed)) {
// Get Player
unsigned char *player = *(unsigned char **) (minecraft + Minecraft_player_property_offset);
@ -85,4 +85,5 @@ void _handle_drop(unsigned char *minecraft) {
// Init
void _init_drop() {
enable_drop = feature_has("Bind \"Q\" Key To Item Dropping", 0);
input_run_on_tick(_handle_drop);
}

15
mods/src/input/input.cpp

@ -21,21 +21,6 @@ static void Minecraft_tickInput_injection(unsigned char *minecraft) {
// Call Original Method
(*Minecraft_tickInput)(minecraft);
// Handle Bow
_handle_bow(minecraft);
// Handle Toggle Options
_handle_toggle_options(minecraft);
// Set Mouse Grab State
_handle_mouse_grab(minecraft);
// Handle Back Button
_handle_back(minecraft);
// Handle Item Drops
_handle_drop(minecraft);
// Run Input Tick Functions
for (input_tick_function_t function : get_input_tick_functions()) {
(*function)(minecraft);

5
mods/src/input/input.h

@ -19,14 +19,9 @@ void input_set_mouse_grab_state(int state);
__attribute__((visibility("internal"))) void _init_attack();
__attribute__((visibility("internal"))) void _init_bow();
__attribute__((visibility("internal"))) void _handle_bow(unsigned char *minecraft);
__attribute__((visibility("internal"))) void _handle_toggle_options(unsigned char *minecraft);
__attribute__((visibility("internal"))) void _init_misc();
__attribute__((visibility("internal"))) void _init_toggle();
__attribute__((visibility("internal"))) void _handle_mouse_grab(unsigned char *minecraft);
__attribute__((visibility("internal"))) void _handle_back(unsigned char *minecraft);
__attribute__((visibility("internal"))) void _init_drop();
__attribute__((visibility("internal"))) void _handle_drop(unsigned char *minecraft);
#ifdef __cplusplus
}

6
mods/src/input/misc.c

@ -19,7 +19,7 @@ int input_back() {
}
// Handle Back Button Presses
void _handle_back(unsigned char *minecraft) {
static void _handle_back(unsigned char *minecraft) {
unsigned char *minecraft_vtable = *(unsigned char **) minecraft;
Minecraft_handleBack_t Minecraft_handleBack = *(Minecraft_handleBack_t *) (minecraft_vtable + Minecraft_handleBack_vtable_offset);
for (int i = 0; i < back_button_presses; i++) {
@ -44,7 +44,7 @@ void input_set_mouse_grab_state(int state) {
}
// Grab/Un-Grab Mouse
void _handle_mouse_grab(unsigned char *minecraft) {
static void _handle_mouse_grab(unsigned char *minecraft) {
if (mouse_grab_state == -1) {
// Grab
(*Minecraft_grabMouse)(minecraft);
@ -88,4 +88,6 @@ void _init_misc() {
// Disable Opening Inventory Using The Cursor When Cursor Is Hidden
overwrite_calls((void *) Gui_handleClick, (void *) Gui_handleClick_injection);
}
input_run_on_tick(_handle_back);
input_run_on_tick(_handle_mouse_grab);
}

3
mods/src/input/toggle.c

@ -18,7 +18,7 @@ void input_third_person() {
}
// Handle Toggle Options
void _handle_toggle_options(unsigned char *minecraft) {
static void _handle_toggle_options(unsigned char *minecraft) {
if (enable_toggles) {
// Handle Functions
unsigned char *options = minecraft + Minecraft_options_property_offset;
@ -38,4 +38,5 @@ void _handle_toggle_options(unsigned char *minecraft) {
// Init
void _init_toggle() {
enable_toggles = feature_has("Bind Common Toggleable Options To Function Keys", 0);
input_run_on_tick(_handle_toggle_options);
}

6
mods/src/options/options.c

@ -100,20 +100,20 @@ void init_options() {
}
patch_address((void *) default_username, (void *) username);
// Disable Autojump By Default
if (feature_has("Disable Autojump By Default", 0)) {
// Disable Autojump By Default
unsigned char autojump_patch[4] = {0x00, 0x30, 0xa0, 0xe3}; // "mov r3, #0x0"
patch((void *) 0x44b90, autojump_patch);
}
// Display Nametags By Default
if (feature_has("Display Nametags By Default", 0)) {
// Display Nametags By Default
unsigned char display_nametags_patch[4] = {0x1d, 0x60, 0xc0, 0xe5}; // "strb r6, [r0, #0x1d]"
patch((void *) 0xa6628, display_nametags_patch);
}
// Enable Smooth Lighting
smooth_lighting = feature_has("Smooth Lighting", 0);
if (smooth_lighting) {
// Enable Smooth Lighting
unsigned char smooth_lighting_patch[4] = {0x01, 0x00, 0x53, 0xe3}; // "cmp r3, #0x1"
patch((void *) 0x59ea4, smooth_lighting_patch);
}

27
symbols/include/symbols/minecraft.h

@ -53,6 +53,15 @@ static uint32_t Tile_id_property_offset = 0x8;
// Structures
struct AABB {
float x1;
float y1;
float z1;
float x2;
float y2;
float z2;
};
struct LevelSettings {
unsigned long seed;
int32_t game_type;
@ -133,6 +142,8 @@ static uint32_t Minecraft_progress_property_offset = 0xc60; // int32_t
static uint32_t Minecraft_command_server_property_offset = 0xcc0; // CommandServer *
static uint32_t Minecraft_screen_property_offset = 0xc10; // Screen *
static uint32_t Minecraft_gui_property_offset = 0x198; // Gui
static uint32_t Minecraft_pov_property_offset = 0x150; // Mob *
static uint32_t Minecraft_perf_renderer_property_offset = 0xcbc; // PerfRenderer *
// GameRenderer
@ -197,6 +208,7 @@ static uint32_t Options_hide_gui_property_offset = 0xec; // unsigned char / bool
static uint32_t Options_third_person_property_offset = 0xed; // unsigned char / bool
static uint32_t Options_render_distance_property_offset = 0x10; // int32_t
static uint32_t Options_sound_property_offset = 0x4; // int32_t
static uint32_t Options_debug_property_offset = 0xee; // unsigned char / bool
// MouseBuildInput
@ -314,6 +326,21 @@ static Level_saveLevelData_t Level_saveLevelData = (Level_saveLevelData_t) 0xa2e
static uint32_t Level_players_property_offset = 0x60; // std::vector<ServerPlayer *>
// LevelRenderer
typedef void (*LevelRenderer_render_t)(unsigned char *level_renderer, unsigned char *mob, int param_1, float delta);
static LevelRenderer_render_t LevelRenderer_render = (LevelRenderer_render_t) 0x4f710;
typedef void (*LevelRenderer_renderDebug_t)(unsigned char *level_renderer, struct AABB *aabb, float delta);
static LevelRenderer_renderDebug_t LevelRenderer_renderDebug = (LevelRenderer_renderDebug_t) 0x4d310;
static uint32_t LevelRenderer_minecraft_property_offset = 0x4; // Minecraft *
// PerfRenderer
typedef void (*PerfRenderer_debugFpsMeterKeyPress_t)(unsigned char *perf_renderer, int key);
static PerfRenderer_debugFpsMeterKeyPress_t PerfRenderer_debugFpsMeterKeyPress = (PerfRenderer_debugFpsMeterKeyPress_t) 0x79118;
// TextEditScreen
#define TEXT_EDIT_SCREEN_SIZE 0xd0

Loading…
Cancel
Save