57 lines
1.3 KiB
C++
Raw Normal View History

2021-07-04 19:02:45 -04:00
#include <vector>
#include <libreborn/libreborn.h>
2021-09-11 23:18:12 -04:00
#include <symbols/minecraft.h>
2022-03-06 20:07:49 -05:00
#include <media-layer/core.h>
2021-07-04 19:02:45 -04:00
2022-06-25 17:30:08 -04:00
#include <mods/feature/feature.h>
#include <mods/init/init.h>
#include "input-internal.h"
#include <mods/input/input.h>
2021-07-04 19:02:45 -04:00
// Run Functions On Input Tick
static std::vector<input_tick_function_t> &get_input_tick_functions() {
static std::vector<input_tick_function_t> functions;
return functions;
}
void input_run_on_tick(input_tick_function_t function) {
get_input_tick_functions().push_back(function);
}
// Handle Input Fixes
2024-04-03 03:19:12 -04:00
static void Minecraft_tickInput_injection(Minecraft_tickInput_t original, Minecraft *minecraft) {
2021-07-04 19:02:45 -04:00
// Call Original Method
2024-04-03 03:19:12 -04:00
original(minecraft);
2021-07-04 19:02:45 -04:00
// Run Input Tick Functions
for (input_tick_function_t function : get_input_tick_functions()) {
2024-01-07 03:23:43 -05:00
function(minecraft);
2021-07-04 19:02:45 -04:00
}
}
// Init
void init_input() {
// Miscellaneous
_init_misc();
// Toggleable Options
_init_toggle();
// Item Dropping
_init_drop();
// Enable Bow & Arrow Fix
_init_bow();
// Loop
2024-04-03 03:19:12 -04:00
overwrite_calls(Minecraft_tickInput, Minecraft_tickInput_injection);
2021-07-04 19:02:45 -04:00
// Allow Attacking Mobs
_init_attack();
2022-03-06 20:07:49 -05:00
// Disable Raw Mouse Motion
2022-04-09 20:01:16 -04:00
if (feature_has("Disable Raw Mouse Motion (Not Recommended)", server_disabled)) {
2022-03-06 20:07:49 -05:00
media_set_raw_mouse_motion_enabled(0);
}
2021-07-04 19:02:45 -04:00
}