minecraft-pi-reborn/mods/src/input/bow.c

34 lines
889 B
C
Raw Normal View History

2021-07-04 23:02:45 +00:00
#include <libreborn/libreborn.h>
2021-09-12 03:18:12 +00:00
#include <symbols/minecraft.h>
2021-07-04 23:02:45 +00:00
2022-06-25 21:30:08 +00:00
#include <mods/feature/feature.h>
#include "input-internal.h"
#include <mods/input/input.h>
2021-07-04 23:02:45 +00:00
// Store Right-Click Status
static int is_right_click = 0;
void input_set_is_right_click(int val) {
is_right_click = val;
}
// Enable Bow & Arrow Fix
static int fix_bow = 0;
// Handle Bow & Arrow
2024-01-06 11:30:23 +00:00
static void _handle_bow(Minecraft *minecraft) {
2021-07-04 23:02:45 +00:00
if (fix_bow && !is_right_click) {
2024-01-06 11:30:23 +00:00
GameMode *game_mode = minecraft->game_mode;
LocalPlayer *player = minecraft->player;
2024-01-07 08:23:43 +00:00
if (player != NULL && game_mode != NULL && LocalPlayer_isUsingItem(player)) {
2024-01-06 11:30:23 +00:00
game_mode->vtable->releaseUsingItem(game_mode, (Player *) player);
2021-07-04 23:02:45 +00:00
}
}
}
// Init
void _init_bow() {
// Enable Bow & Arrow Fix
2022-04-10 00:01:16 +00:00
fix_bow = feature_has("Fix Bow & Arrow", server_disabled);
2021-10-04 23:42:55 +00:00
input_run_on_tick(_handle_bow);
2021-07-04 23:02:45 +00:00
}