Modding Changes
This commit is contained in:
parent
f1fe1c140c
commit
c0156336df
2
dependencies/symbol-processor/src
vendored
2
dependencies/symbol-processor/src
vendored
@ -1 +1 @@
|
||||
Subproject commit 2a63f1ff521087f3faf23bf281503cc07a50d2df
|
||||
Subproject commit 5d2b146b08f48bc0e185d224eb69cb718c62bf72
|
@ -8,7 +8,7 @@
|
||||
// Syscall Method
|
||||
static uint32_t trampoline_syscall(const uint32_t id, const uint32_t length, const unsigned char *args) {
|
||||
// Make Syscall
|
||||
long ret = syscall(TRAMPOLINE_SYSCALL, id, length, args);
|
||||
const long ret = syscall(TRAMPOLINE_SYSCALL, id, length, args);
|
||||
if (ret == -1) {
|
||||
// Error
|
||||
ERR("Trampoline Error: %s", strerror(errno));
|
||||
@ -23,7 +23,7 @@ static int get_pipe(const char *env) {
|
||||
if (value == nullptr) {
|
||||
IMPOSSIBLE();
|
||||
}
|
||||
std::string str = value;
|
||||
const std::string str = value;
|
||||
return std::stoi(str);
|
||||
}
|
||||
static uint32_t trampoline_pipe(const uint32_t id, const bool allow_early_return, const uint32_t length, const unsigned char *args) {
|
||||
|
@ -25,7 +25,7 @@ struct copy_array {
|
||||
this->size = length * sizeof(T);
|
||||
this->data = arr;
|
||||
}
|
||||
copy_array(const char *str) {
|
||||
explicit copy_array(const char *str) {
|
||||
this->size = str != nullptr ? (strlen(str) + 1) : 0;
|
||||
this->data = str;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "../common/common.h"
|
||||
|
||||
// Trampoline Function
|
||||
extern "C" std::remove_pointer<trampoline_t>::type trampoline;
|
||||
extern "C" std::remove_pointer_t<trampoline_t> trampoline;
|
||||
|
||||
// Macro
|
||||
typedef uint32_t handler_t(trampoline_writer_t writer, const unsigned char *args);
|
||||
@ -17,9 +17,9 @@ __attribute__((visibility("internal"))) void _add_handler(unsigned char id, hand
|
||||
__attribute__((unused)) TrampolineArguments args(raw_args); \
|
||||
static typeof(name) *func = name;
|
||||
|
||||
// Arguemnts
|
||||
// Arguments
|
||||
struct TrampolineArguments {
|
||||
TrampolineArguments(const unsigned char *args) {
|
||||
explicit TrampolineArguments(const unsigned char *args) {
|
||||
this->raw_args = args;
|
||||
this->position = 0;
|
||||
}
|
||||
|
@ -10,6 +10,6 @@ extern "C" {
|
||||
std::string chat_send_api_command(const Minecraft *minecraft, const 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);
|
||||
void chat_send_message(ServerSideNetworkHandler *server_side_network_handler, const char *username, const char *message);
|
||||
void chat_handle_packet_send(const Minecraft *minecraft, ChatPacket *packet);
|
||||
}
|
||||
|
@ -2,7 +2,9 @@
|
||||
KEY(BACKSPACE, 0x8)
|
||||
KEY(DELETE, 0x2e)
|
||||
KEY(LEFT, 0x25)
|
||||
KEY(UP, 0x26)
|
||||
KEY(RIGHT, 0x27)
|
||||
KEY(DOWN, 0x28)
|
||||
KEY(F1, 0x70)
|
||||
KEY(F2, 0x71)
|
||||
KEY(F3, 0x72)
|
||||
|
@ -6,8 +6,8 @@
|
||||
#include <symbols/minecraft.h>
|
||||
|
||||
extern "C" {
|
||||
int32_t misc_get_real_selected_slot(Player *player);
|
||||
void misc_render_background(int color, Minecraft *minecraft, int x, int y, int width, int height);
|
||||
int32_t misc_get_real_selected_slot(const Player *player);
|
||||
void misc_render_background(int color, const Minecraft *minecraft, int x, int y, int width, int height);
|
||||
|
||||
extern bool is_in_chat;
|
||||
|
||||
|
@ -5,14 +5,12 @@
|
||||
#include <map>
|
||||
|
||||
class ServerProperties {
|
||||
|
||||
private:
|
||||
std::map<std::string, std::string> properties;
|
||||
|
||||
public:
|
||||
void load(std::istream& fstream);
|
||||
void load(std::istream &stream);
|
||||
|
||||
std::string get_string(std::string const& name, std::string const& def);
|
||||
int get_int(std::string const& name, std::string const& def);
|
||||
bool get_bool(std::string const& name, std::string const& def);
|
||||
[[nodiscard]] std::string get_string(const std::string &name, const std::string &def) const;
|
||||
[[nodiscard]] int get_int(const std::string &name, const std::string &def) const;
|
||||
[[nodiscard]] bool get_bool(const std::string &name, const std::string &def) const;
|
||||
};
|
@ -3,22 +3,23 @@
|
||||
#include <symbols/minecraft.h>
|
||||
|
||||
struct TextInputBox {
|
||||
static TextInputBox *create(const std::string &placeholder = "", const std::string &text = "");
|
||||
explicit TextInputBox(const std::string &placeholder = "", const std::string &text = "");
|
||||
~TextInputBox();
|
||||
|
||||
GuiComponent super;
|
||||
GuiComponent *component;
|
||||
|
||||
void setSize(int x, int y, int width = 200, int height = 12);
|
||||
void init(Font *pFont);
|
||||
void setEnabled(bool bEnabled);
|
||||
void keyPressed(int key);
|
||||
void charPressed(int chr);
|
||||
void charPressed(int k);
|
||||
void render();
|
||||
void tick();
|
||||
void setFocused(bool b);
|
||||
void onClick(int x, int y);
|
||||
[[nodiscard]] bool clicked(int x, int y) const;
|
||||
[[nodiscard]] bool clicked(int xPos, int yPos) const;
|
||||
[[nodiscard]] std::string getText() const;
|
||||
void setText(std::string text);
|
||||
void setText(const std::string &text);
|
||||
[[nodiscard]] bool isFocused() const;
|
||||
void setMaxLength(int max_length);
|
||||
|
||||
|
@ -5,8 +5,31 @@
|
||||
#include <mods/text-input-box/TextInputBox.h>
|
||||
|
||||
struct TextInputScreen {
|
||||
Screen super;
|
||||
std::vector<TextInputBox *> *m_textInputs;
|
||||
std::vector<TextInputBox *> *m_textInputs = nullptr;
|
||||
|
||||
static void setup(Screen_vtable *vtable);
|
||||
template <typename T>
|
||||
static void setup(Screen_vtable *vtable) {
|
||||
#define PATCH_VTABLE(name) \
|
||||
static Screen_##name##_t original_##name = vtable->name; \
|
||||
vtable->name = [](Screen *super, auto... args) { \
|
||||
original_##name(super, std::forward<decltype(args)>(args)...); \
|
||||
T *self = (T *) super; \
|
||||
self->data.text_input.name(std::forward<decltype(args)>(args)...); \
|
||||
}
|
||||
PATCH_VTABLE(keyPressed);
|
||||
PATCH_VTABLE(keyboardNewChar);
|
||||
PATCH_VTABLE(mouseClicked);
|
||||
PATCH_VTABLE(render);
|
||||
PATCH_VTABLE(init);
|
||||
PATCH_VTABLE(removed);
|
||||
#undef PATCH_VTABLE
|
||||
}
|
||||
|
||||
private:
|
||||
void keyPressed(int key) const;
|
||||
void keyboardNewChar(char key) const;
|
||||
void mouseClicked(int x, int y, int param_1) const;
|
||||
void render(int x, int y, float param_1) const;
|
||||
void init();
|
||||
void removed() const;
|
||||
};
|
||||
|
@ -4,5 +4,5 @@
|
||||
|
||||
extern int touch_gui;
|
||||
extern "C" {
|
||||
Button *touch_create_button(int id, std::string text);
|
||||
Button *touch_create_button(int id, const std::string &text);
|
||||
}
|
@ -7,9 +7,9 @@
|
||||
#include <mods/init/init.h>
|
||||
|
||||
// Fix Grass And Leaves Inventory Rendering When The gui_blocks Atlas Is Disabled
|
||||
static void ItemRenderer_renderGuiItemCorrect_injection_one(ItemRenderer_renderGuiItemCorrect_t original, Font *font, Textures *textures, const ItemInstance *item_instance, int32_t param_1, int32_t param_2) {
|
||||
int32_t leaves_id = Tile::leaves->id;
|
||||
int32_t grass_id = Tile::grass->id;
|
||||
static void ItemRenderer_renderGuiItemCorrect_injection_one(ItemRenderer_renderGuiItemCorrect_t original, Font *font, Textures *textures, const ItemInstance *item_instance, const int32_t param_1, const int32_t param_2) {
|
||||
const int32_t leaves_id = Tile::leaves->id;
|
||||
const int32_t grass_id = Tile::grass->id;
|
||||
// Replace Rendered Item With Carried Variant
|
||||
ItemInstance carried_item_instance;
|
||||
bool use_carried = false;
|
||||
@ -24,7 +24,7 @@ static void ItemRenderer_renderGuiItemCorrect_injection_one(ItemRenderer_renderG
|
||||
}
|
||||
|
||||
// Fix Toolbar Rendering
|
||||
GLboolean depth_test_was_enabled = glIsEnabled(GL_DEPTH_TEST);
|
||||
const GLboolean depth_test_was_enabled = glIsEnabled(GL_DEPTH_TEST);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
||||
// Call Original Method
|
||||
@ -57,7 +57,7 @@ static void Tesselator_color_injection(Tesselator_color_t original, Tesselator *
|
||||
// Call Original Method
|
||||
original(tesselator, r, g, b, a);
|
||||
}
|
||||
static void Tesselator_begin_injection(Tesselator_begin_t original, Tesselator *tesselator, int32_t mode) {
|
||||
static void Tesselator_begin_injection(Tesselator_begin_t original, Tesselator *tesselator, const int32_t mode) {
|
||||
// Call Original Method
|
||||
original(tesselator, mode);
|
||||
|
||||
@ -74,7 +74,7 @@ static void InventoryPane_renderBatch_Tesselator_color_injection(Tesselator *tes
|
||||
// Enable Item Color Fix
|
||||
item_color_fix_mode = 2;
|
||||
}
|
||||
static void ItemRenderer_renderGuiItem_two_injection_one(ItemRenderer_renderGuiItem_two_t original, Font *font, Textures *textures, const ItemInstance *item_instance, float param_1, float param_2, float param_3, float param_4, bool param_5) {
|
||||
static void ItemRenderer_renderGuiItem_two_injection_one(ItemRenderer_renderGuiItem_two_t original, Font *font, Textures *textures, const ItemInstance *item_instance, const float param_1, const float param_2, const float param_3, const float param_4, const bool param_5) {
|
||||
// Call Original Method
|
||||
original(font, textures, item_instance, param_1, param_2, param_3, param_4, param_5);
|
||||
|
||||
@ -92,7 +92,7 @@ static void FurnaceScreen_render_ItemRenderer_renderGuiItem_one_injection(Font *
|
||||
// Smooth Scrolling
|
||||
static float target_x;
|
||||
static float target_y;
|
||||
static void ItemRenderer_renderGuiItem_two_injection_two(ItemRenderer_renderGuiItem_two_t original, Font *font, Textures *textures, const ItemInstance *item_instance, float x, float y, float w, float h, bool param_5) {
|
||||
static void ItemRenderer_renderGuiItem_two_injection_two(ItemRenderer_renderGuiItem_two_t original, Font *font, Textures *textures, const ItemInstance *item_instance, const float x, const float y, const float w, const float h, const bool param_5) {
|
||||
target_x = x;
|
||||
target_y = y;
|
||||
original(font, textures, item_instance, x, y, w, h, param_5);
|
||||
|
@ -40,7 +40,7 @@ static void start_world(Minecraft *minecraft) {
|
||||
minecraft->selectLevel(name, name, settings);
|
||||
|
||||
// Open ProgressScreen
|
||||
ProgressScreen *screen = new ProgressScreen;
|
||||
ProgressScreen *screen = ProgressScreen::allocate();
|
||||
ALLOC_CHECK(screen);
|
||||
screen = screen->constructor();
|
||||
minecraft->setScreen((Screen *) screen);
|
||||
@ -54,7 +54,7 @@ static void handle_swap_buffers() {
|
||||
|
||||
// Track Ticks
|
||||
static unsigned long long int ticks = 0;
|
||||
static void Minecraft_tick_injection(__attribute__((unused)) Minecraft *minecraft) {
|
||||
static void Minecraft_tick_injection(__attribute__((unused)) const Minecraft *minecraft) {
|
||||
ticks++;
|
||||
}
|
||||
|
||||
|
@ -184,9 +184,9 @@ CUSTOM_VTABLE(bucket, FoodItem) {
|
||||
}
|
||||
|
||||
// Create Items
|
||||
static FoodItem *create_bucket(int32_t id, int32_t texture_x, int32_t texture_y, std::string name) {
|
||||
static FoodItem *create_bucket(const int32_t id, int32_t texture_x, int32_t texture_y, std::string name) {
|
||||
// Construct
|
||||
FoodItem *item = new FoodItem;
|
||||
FoodItem *item = FoodItem::allocate();
|
||||
ALLOC_CHECK(item);
|
||||
Item_constructor->get(false)((Item *) item, id); // FoodItem's Constructor Was Inlined
|
||||
|
||||
@ -253,7 +253,7 @@ static HitResult Mob_pick_Level_clip_injection(Level *level, const Vec3 ¶m_1
|
||||
// Call Original Method
|
||||
return level->clip(param_1, param_2, is_holding_bucket, clip_hitboxes);
|
||||
}
|
||||
static void handle_tick(Minecraft *minecraft) {
|
||||
static void handle_tick(const Minecraft *minecraft) {
|
||||
LocalPlayer *player = minecraft->player;
|
||||
if (player != nullptr) {
|
||||
// Get Selected Slot
|
||||
@ -261,14 +261,14 @@ static void handle_tick(Minecraft *minecraft) {
|
||||
Inventory *inventory = player->inventory;
|
||||
|
||||
// Get Item
|
||||
ItemInstance *inventory_item = inventory->getItem(selected_slot);
|
||||
const ItemInstance *inventory_item = inventory->getItem(selected_slot);
|
||||
// Check
|
||||
is_holding_bucket = inventory_item != nullptr && inventory_item->id == bucket->id && inventory_item->auxiliary == 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Prevent Breaking Liquid
|
||||
static bool is_calm_liquid(int32_t id) {
|
||||
static bool is_calm_liquid(const int32_t id) {
|
||||
if (id == Tile::calmWater->id) {
|
||||
return true;
|
||||
} else if (id == Tile::calmLava->id) {
|
||||
@ -277,14 +277,14 @@ static bool is_calm_liquid(int32_t id) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
static void Minecraft_handleMouseDown_injection(Minecraft_handleMouseDown_t original, Minecraft *minecraft, int param_1, bool can_destroy) {
|
||||
static void Minecraft_handleMouseDown_injection(Minecraft_handleMouseDown_t original, Minecraft *minecraft, const int param_1, bool can_destroy) {
|
||||
// Check
|
||||
Level *level = minecraft->level;
|
||||
if (level != nullptr) {
|
||||
int32_t x = minecraft->hit_result.x;
|
||||
int32_t y = minecraft->hit_result.y;
|
||||
int32_t z = minecraft->hit_result.z;
|
||||
int32_t tile = level->getTile(x, y, z);
|
||||
const int32_t tile = level->getTile(x, y, z);
|
||||
if (is_calm_liquid(tile)) {
|
||||
can_destroy = false;
|
||||
}
|
||||
@ -297,9 +297,9 @@ static void Minecraft_handleMouseDown_injection(Minecraft_handleMouseDown_t orig
|
||||
// Custom Crafting Recipes
|
||||
static void Recipes_injection(Recipes *recipes) {
|
||||
// Add
|
||||
Recipes_Type type1 = {
|
||||
.item = 0,
|
||||
.tile = 0,
|
||||
constexpr Recipes_Type type1 = {
|
||||
.item = nullptr,
|
||||
.tile = nullptr,
|
||||
.instance = {
|
||||
.count = 3,
|
||||
.id = 265,
|
||||
@ -314,7 +314,7 @@ static void Recipes_injection(Recipes *recipes) {
|
||||
};
|
||||
std::string line1 = "# #";
|
||||
std::string line2 = " # ";
|
||||
std::vector<Recipes_Type> types = {type1};
|
||||
std::vector types = {type1};
|
||||
recipes->addShapedRecipe_2(result, line1, line2, types);
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ static std::string Cake_getDescriptionId(__attribute__((unused)) Tile *tile) {
|
||||
}
|
||||
|
||||
// Textures
|
||||
static int Cake_getTexture2(__attribute__((unused)) Tile *tile, int face, __attribute__((unused)) int data) {
|
||||
static int Cake_getTexture2(__attribute__((unused)) Tile *tile, const int face, __attribute__((unused)) int data) {
|
||||
if (face == 1) {
|
||||
// Top texture
|
||||
return 121;
|
||||
@ -28,10 +28,10 @@ static int Cake_getTexture2(__attribute__((unused)) Tile *tile, int face, __attr
|
||||
return 122;
|
||||
}
|
||||
|
||||
static int Cake_getTexture3(__attribute__((unused)) Tile *tile, LevelSource *level, int x, int y, int z, int face) {
|
||||
static int Cake_getTexture3(__attribute__((unused)) Tile *tile, LevelSource *level, int x, int y, int z, const int face) {
|
||||
// Eaten face
|
||||
if (face == 3) {
|
||||
int data = level->getData(x, y, z);
|
||||
const int data = level->getData(x, y, z);
|
||||
if (data != 0 && data < 6) {
|
||||
// Sliced texture
|
||||
return 123;
|
||||
@ -69,7 +69,7 @@ static AABB *Cake_getAABB(Tile *tile, Level *level, int x, int y, int z) {
|
||||
// Get the size of the slices
|
||||
int data = level->getData(x, y, z);
|
||||
if (data >= 6) data = 0;
|
||||
float slice_size = (1.0 / 7.0) * (float) data;
|
||||
const float slice_size = (1.0 / 7.0) * (float) data;
|
||||
|
||||
// Corner 1
|
||||
AABB *aabb = &tile->aabb;
|
||||
@ -90,7 +90,7 @@ static void Cake_updateShape(Tile *tile, LevelSource *level, int x, int y, int z
|
||||
int data = level->getData(x, y, z);
|
||||
if (data >= 6) data = 0;
|
||||
// Get slice amount
|
||||
float slice_size = (1.0 / 7.0) * (float) data;
|
||||
const float slice_size = (1.0 / 7.0) * (float) data;
|
||||
tile->setShape(
|
||||
CAKE_LEN, 0.0, CAKE_LEN,
|
||||
1.0 - CAKE_LEN, 0.5, (1.0 - CAKE_LEN) - slice_size
|
||||
@ -116,7 +116,7 @@ static int Cake_use(__attribute__((unused)) Tile *tile, Level *level, int x, int
|
||||
// Makes the cakes
|
||||
static void make_cake() {
|
||||
// Construct
|
||||
cake = new Tile;
|
||||
cake = Tile::allocate();
|
||||
ALLOC_CHECK(cake);
|
||||
int texture = 122;
|
||||
cake->constructor(92, texture, Material::dirt);
|
||||
@ -170,9 +170,9 @@ static void Inventory_setupDefault_FillingContainer_addItem_call_injection(Filli
|
||||
// Recipe (only when buckets are enabled)
|
||||
static void Recipes_injection(Recipes *recipes) {
|
||||
// Sugar
|
||||
Recipes_Type sugar = {
|
||||
.item = 0,
|
||||
.tile = 0,
|
||||
constexpr Recipes_Type sugar = {
|
||||
.item = nullptr,
|
||||
.tile = nullptr,
|
||||
.instance = {
|
||||
.count = 1,
|
||||
.id = 353,
|
||||
@ -181,9 +181,9 @@ static void Recipes_injection(Recipes *recipes) {
|
||||
.letter = 's'
|
||||
};
|
||||
// Wheat
|
||||
Recipes_Type wheat = {
|
||||
.item = 0,
|
||||
.tile = 0,
|
||||
constexpr Recipes_Type wheat = {
|
||||
.item = nullptr,
|
||||
.tile = nullptr,
|
||||
.instance = {
|
||||
.count = 1,
|
||||
.id = 296,
|
||||
@ -192,9 +192,9 @@ static void Recipes_injection(Recipes *recipes) {
|
||||
.letter = 'w'
|
||||
};
|
||||
// Eggs
|
||||
Recipes_Type eggs = {
|
||||
.item = 0,
|
||||
.tile = 0,
|
||||
constexpr Recipes_Type eggs = {
|
||||
.item = nullptr,
|
||||
.tile = nullptr,
|
||||
.instance = {
|
||||
.count = 1,
|
||||
.id = 344,
|
||||
@ -203,9 +203,9 @@ static void Recipes_injection(Recipes *recipes) {
|
||||
.letter = 'e'
|
||||
};
|
||||
// Milk
|
||||
Recipes_Type milk = {
|
||||
.item = 0,
|
||||
.tile = 0,
|
||||
constexpr Recipes_Type milk = {
|
||||
.item = nullptr,
|
||||
.tile = nullptr,
|
||||
.instance = {
|
||||
.count = 1,
|
||||
.id = 325,
|
||||
|
@ -16,7 +16,7 @@ static EntityRenderDispatcher *EntityRenderDispatcher_injection(EntityRenderDisp
|
||||
original(dispatcher);
|
||||
|
||||
// Register TripodCameraRenderer
|
||||
TripodCameraRenderer *renderer = new TripodCameraRenderer;
|
||||
TripodCameraRenderer *renderer = TripodCameraRenderer::allocate();
|
||||
ALLOC_CHECK(renderer);
|
||||
renderer->constructor();
|
||||
dispatcher->assign((unsigned char) 0x5, (EntityRenderer *) renderer);
|
||||
@ -25,7 +25,7 @@ static EntityRenderDispatcher *EntityRenderDispatcher_injection(EntityRenderDisp
|
||||
}
|
||||
|
||||
// Display Smoke From TripodCamera Higher
|
||||
static void TripodCamera_tick_Level_addParticle_call_injection(Level *level, const std::string &particle, float x, float y, float z, float deltaX, float deltaY, float deltaZ, int count) {
|
||||
static void TripodCamera_tick_Level_addParticle_call_injection(Level *level, const std::string &particle, float x, const float y, float z, float deltaX, float deltaY, float deltaZ, int count) {
|
||||
// Call Original Method
|
||||
level->addParticle(particle, x, y + 0.5, z, deltaX, deltaY, deltaZ, count);
|
||||
}
|
||||
|
@ -8,10 +8,10 @@
|
||||
#define MAX_CHAT_MESSAGE_LENGTH 256
|
||||
|
||||
// Message Prefix
|
||||
__attribute__((visibility("internal"))) std::string _chat_get_prefix(char *username);
|
||||
__attribute__((visibility("internal"))) std::string _chat_get_prefix(const char *username);
|
||||
|
||||
// Queue Message For Sending
|
||||
__attribute__((visibility("internal"))) void _chat_send_message(Minecraft *minecraft, const char *message);
|
||||
__attribute__((visibility("internal"))) void _chat_send_message(const Minecraft *minecraft, const char *message);
|
||||
|
||||
// Init Chat UI
|
||||
__attribute__((visibility("internal"))) void _init_chat_ui();
|
@ -25,16 +25,16 @@ std::string chat_send_api_command(const Minecraft *minecraft, const std::string
|
||||
}
|
||||
|
||||
// Send API Chat Command
|
||||
static void send_api_chat_command(Minecraft *minecraft, const char *str) {
|
||||
static void send_api_chat_command(const Minecraft *minecraft, const char *str) {
|
||||
const std::string command = std::string("chat.post(") + str + ")\n";
|
||||
chat_send_api_command(minecraft, command);
|
||||
}
|
||||
|
||||
// Send Message To Players
|
||||
std::string _chat_get_prefix(char *username) {
|
||||
std::string _chat_get_prefix(const char *username) {
|
||||
return std::string("<") + username + "> ";
|
||||
}
|
||||
void chat_send_message(ServerSideNetworkHandler *server_side_network_handler, char *username, char *message) {
|
||||
void chat_send_message(ServerSideNetworkHandler *server_side_network_handler, const char *username, const char *message) {
|
||||
std::string full_message = _chat_get_prefix(username) + message;
|
||||
char *raw_str = strdup(full_message.c_str());
|
||||
ALLOC_CHECK(raw_str);
|
||||
@ -44,7 +44,7 @@ void chat_send_message(ServerSideNetworkHandler *server_side_network_handler, ch
|
||||
server_side_network_handler->displayGameMessage(full_message);
|
||||
}
|
||||
// Handle Chat packet Send
|
||||
void chat_handle_packet_send(Minecraft *minecraft, ChatPacket *packet) {
|
||||
void chat_handle_packet_send(const Minecraft *minecraft, ChatPacket *packet) {
|
||||
RakNetInstance *rak_net_instance = minecraft->rak_net_instance;
|
||||
if (rak_net_instance->isServer()) {
|
||||
// Hosting Multiplayer
|
||||
@ -58,8 +58,8 @@ void chat_handle_packet_send(Minecraft *minecraft, ChatPacket *packet) {
|
||||
}
|
||||
|
||||
// Manually Send (And Loopback) ChatPacket
|
||||
static void CommandServer_parse_CommandServer_dispatchPacket_injection(CommandServer *command_server, Packet *packet) {
|
||||
Minecraft *minecraft = command_server->minecraft;
|
||||
static void CommandServer_parse_CommandServer_dispatchPacket_injection(const CommandServer *command_server, Packet *packet) {
|
||||
const Minecraft *minecraft = command_server->minecraft;
|
||||
if (minecraft != nullptr) {
|
||||
chat_handle_packet_send(minecraft, (ChatPacket *) packet);
|
||||
}
|
||||
@ -67,17 +67,17 @@ static void CommandServer_parse_CommandServer_dispatchPacket_injection(CommandSe
|
||||
|
||||
// Handle ChatPacket Server-Side
|
||||
static void ServerSideNetworkHandler_handle_ChatPacket_injection(ServerSideNetworkHandler *server_side_network_handler, const RakNet_RakNetGUID &rak_net_guid, ChatPacket *chat_packet) {
|
||||
Player *player = server_side_network_handler->getPlayer(rak_net_guid);
|
||||
const Player *player = server_side_network_handler->getPlayer(rak_net_guid);
|
||||
if (player != nullptr) {
|
||||
const char *username = player->username.c_str();
|
||||
const char *message = chat_packet->message.c_str();
|
||||
chat_send_message(server_side_network_handler, (char *) username, (char *) message);
|
||||
chat_send_message(server_side_network_handler, username, message);
|
||||
}
|
||||
}
|
||||
|
||||
// Send Message
|
||||
void _chat_send_message(Minecraft *minecraft, const char *message) {
|
||||
send_api_chat_command(minecraft, (char *) message);
|
||||
void _chat_send_message(const Minecraft *minecraft, const char *message) {
|
||||
send_api_chat_command(minecraft, message);
|
||||
}
|
||||
|
||||
// Init
|
||||
|
@ -15,14 +15,14 @@ static std::vector<std::string> &get_history() {
|
||||
}
|
||||
|
||||
// Structure
|
||||
struct ChatScreen {
|
||||
TextInputScreen super;
|
||||
EXTEND_STRUCT(ChatScreen, Screen, struct {
|
||||
TextInputScreen text_input;
|
||||
TextInputBox *chat;
|
||||
Button *send;
|
||||
int history_pos;
|
||||
};
|
||||
});
|
||||
CUSTOM_VTABLE(chat_screen, Screen) {
|
||||
TextInputScreen::setup(vtable);
|
||||
TextInputScreen::setup<ChatScreen>(vtable);
|
||||
// Init
|
||||
static std::vector<std::string> local_history = {};
|
||||
static Screen_init_t original_init = vtable->init;
|
||||
@ -30,21 +30,21 @@ CUSTOM_VTABLE(chat_screen, Screen) {
|
||||
original_init(super);
|
||||
ChatScreen *self = (ChatScreen *) super;
|
||||
// Text Input
|
||||
self->chat = TextInputBox::create();
|
||||
self->super.m_textInputs->push_back(self->chat);
|
||||
self->chat->init(super->font);
|
||||
self->chat->setFocused(true);
|
||||
self->history_pos = get_history().size();
|
||||
self->data.chat = new TextInputBox;
|
||||
self->data.text_input.m_textInputs->push_back(self->data.chat);
|
||||
self->data.chat->init(super->font);
|
||||
self->data.chat->setFocused(true);
|
||||
self->data.history_pos = get_history().size();
|
||||
local_history = get_history();
|
||||
local_history.push_back("");
|
||||
// Determine Max Length
|
||||
std::string prefix = _chat_get_prefix(Strings::default_username);
|
||||
int max_length = MAX_CHAT_MESSAGE_LENGTH - prefix.length();
|
||||
self->chat->setMaxLength(max_length);
|
||||
const std::string prefix = _chat_get_prefix(Strings::default_username);
|
||||
const int max_length = MAX_CHAT_MESSAGE_LENGTH - prefix.length();
|
||||
self->data.chat->setMaxLength(max_length);
|
||||
// Send Button
|
||||
self->send = touch_create_button(1, "Send");
|
||||
super->rendered_buttons.push_back(self->send);
|
||||
super->selectable_buttons.push_back(self->send);
|
||||
self->data.send = touch_create_button(1, "Send");
|
||||
super->rendered_buttons.push_back(self->data.send);
|
||||
super->selectable_buttons.push_back(self->data.send);
|
||||
// Hide Chat Messages
|
||||
is_in_chat = true;
|
||||
};
|
||||
@ -53,13 +53,13 @@ CUSTOM_VTABLE(chat_screen, Screen) {
|
||||
vtable->removed = [](Screen *super) {
|
||||
original_removed(super);
|
||||
is_in_chat = false;
|
||||
ChatScreen *self = (ChatScreen *) super;
|
||||
delete self->chat;
|
||||
self->send->destructor_deleting();
|
||||
const ChatScreen *self = (ChatScreen *) super;
|
||||
delete self->data.chat;
|
||||
self->data.send->destructor_deleting();
|
||||
};
|
||||
// Rendering
|
||||
static Screen_render_t original_render = vtable->render;
|
||||
vtable->render = [](Screen *super, int x, int y, float param_1) {
|
||||
vtable->render = [](Screen *super, const int x, const int y, const float param_1) {
|
||||
// Background
|
||||
super->renderBackground();
|
||||
// Render Chat
|
||||
@ -71,46 +71,46 @@ CUSTOM_VTABLE(chat_screen, Screen) {
|
||||
static Screen_setupPositions_t original_setupPositions = vtable->setupPositions;
|
||||
vtable->setupPositions = [](Screen *super) {
|
||||
original_setupPositions(super);
|
||||
ChatScreen *self = (ChatScreen *) super;
|
||||
self->send->height = 24;
|
||||
self->send->width = 40;
|
||||
int x = 0;
|
||||
int y = super->height - self->send->height;
|
||||
int width = super->width - self->send->width;
|
||||
self->chat->setSize(x, y, width, self->send->height);
|
||||
self->send->y = super->height - self->send->height;
|
||||
self->send->x = x + width;
|
||||
const ChatScreen *self = (ChatScreen *) super;
|
||||
self->data.send->height = 24;
|
||||
self->data.send->width = 40;
|
||||
constexpr int x = 0;
|
||||
const int y = super->height - self->data.send->height;
|
||||
const int width = super->width - self->data.send->width;
|
||||
self->data.chat->setSize(x, y, width, self->data.send->height);
|
||||
self->data.send->y = super->height - self->data.send->height;
|
||||
self->data.send->x = x + width;
|
||||
};
|
||||
// Key Presses
|
||||
static Screen_keyPressed_t original_keyPressed = vtable->keyPressed;
|
||||
vtable->keyPressed = [](Screen *super, int key) {
|
||||
vtable->keyPressed = [](Screen *super, const int key) {
|
||||
// Handle Enter
|
||||
ChatScreen *self = (ChatScreen *) super;
|
||||
if (self->chat->isFocused()) {
|
||||
if (key == 0x0d) {
|
||||
if (self->chat->getText().length() > 0) {
|
||||
std::string text = self->chat->getText();
|
||||
if (self->data.chat->isFocused()) {
|
||||
if (key == MC_KEY_RETURN) {
|
||||
if (self->data.chat->getText().length() > 0) {
|
||||
const std::string text = self->data.chat->getText();
|
||||
if (get_history().size() == 0 || text != get_history().back()) {
|
||||
get_history().push_back(text);
|
||||
}
|
||||
_chat_send_message(super->minecraft, text.c_str());
|
||||
}
|
||||
super->minecraft->setScreen(nullptr);
|
||||
} else if (key == 0x26) {
|
||||
} else if (key == MC_KEY_UP) {
|
||||
// Up
|
||||
local_history.at(self->history_pos) = self->chat->getText();
|
||||
local_history.at(self->data.history_pos) = self->data.chat->getText();
|
||||
// Change
|
||||
self->history_pos -= 1;
|
||||
if (self->history_pos < 0) self->history_pos = local_history.size() - 1;
|
||||
self->chat->setText(local_history.at(self->history_pos));
|
||||
self->data.history_pos -= 1;
|
||||
if (self->data.history_pos < 0) self->data.history_pos = local_history.size() - 1;
|
||||
self->data.chat->setText(local_history.at(self->data.history_pos));
|
||||
return;
|
||||
} else if (key == 0x28) {
|
||||
} else if (key == MC_KEY_DOWN) {
|
||||
// Down
|
||||
local_history.at(self->history_pos) = self->chat->getText();
|
||||
local_history.at(self->data.history_pos) = self->data.chat->getText();
|
||||
// Change
|
||||
self->history_pos += 1;
|
||||
if (self->history_pos > int(local_history.size()) - 1) self->history_pos = 0;
|
||||
self->chat->setText(local_history.at(self->history_pos));
|
||||
self->data.history_pos += 1;
|
||||
if (self->data.history_pos > int(local_history.size()) - 1) self->data.history_pos = 0;
|
||||
self->data.chat->setText(local_history.at(self->data.history_pos));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -121,9 +121,9 @@ CUSTOM_VTABLE(chat_screen, Screen) {
|
||||
static Screen_buttonClicked_t original_buttonClicked = vtable->buttonClicked;
|
||||
vtable->buttonClicked = [](Screen *super, Button *button) {
|
||||
ChatScreen *self = (ChatScreen *) super;
|
||||
if (button == self->send) {
|
||||
if (button == self->data.send) {
|
||||
// Send
|
||||
self->chat->setFocused(true);
|
||||
self->data.chat->setFocused(true);
|
||||
super->keyPressed(0x0d);
|
||||
} else {
|
||||
// Call Original Method
|
||||
@ -135,10 +135,10 @@ static Screen *create_chat_screen() {
|
||||
// Construct
|
||||
ChatScreen *screen = new ChatScreen;
|
||||
ALLOC_CHECK(screen);
|
||||
screen->super.super.constructor();
|
||||
screen->super()->constructor();
|
||||
|
||||
// Set VTable
|
||||
screen->super.super.vtable = get_chat_screen_vtable();
|
||||
screen->super()->vtable = get_chat_screen_vtable();
|
||||
|
||||
// Return
|
||||
return (Screen *) screen;
|
||||
@ -146,7 +146,7 @@ static Screen *create_chat_screen() {
|
||||
|
||||
// Init
|
||||
void _init_chat_ui() {
|
||||
misc_run_on_game_key_press([](Minecraft *minecraft, int key) {
|
||||
misc_run_on_game_key_press([](Minecraft *minecraft, const int key) {
|
||||
if (key == MC_KEY_t) {
|
||||
if (minecraft->isLevelGenerated() && minecraft->screen == nullptr) {
|
||||
minecraft->setScreen(create_chat_screen());
|
||||
|
@ -17,17 +17,17 @@
|
||||
#define CREATIVE_STR GAME_MODE_STR("Creative")
|
||||
|
||||
// Structure
|
||||
struct CreateWorldScreen {
|
||||
TextInputScreen super;
|
||||
EXTEND_STRUCT(CreateWorldScreen, Screen, struct {
|
||||
TextInputScreen text_input;
|
||||
TextInputBox *name;
|
||||
TextInputBox *seed;
|
||||
Button *game_mode;
|
||||
Button *create;
|
||||
Button *back;
|
||||
};
|
||||
static void create_world(Minecraft *minecraft, std::string name, bool is_creative, std::string seed);
|
||||
});
|
||||
static void create_world(Minecraft *minecraft, std::string name, bool is_creative, std::string seed_str);
|
||||
CUSTOM_VTABLE(create_world_screen, Screen) {
|
||||
TextInputScreen::setup(vtable);
|
||||
TextInputScreen::setup<CreateWorldScreen>(vtable);
|
||||
// Constants
|
||||
static int line_height = 8;
|
||||
static int bottom_padding = 4;
|
||||
@ -43,42 +43,42 @@ CUSTOM_VTABLE(create_world_screen, Screen) {
|
||||
original_init(super);
|
||||
CreateWorldScreen *self = (CreateWorldScreen *) super;
|
||||
// Name
|
||||
self->name = TextInputBox::create("World Name", "Unnamed world");
|
||||
self->super.m_textInputs->push_back(self->name);
|
||||
self->name->init(super->font);
|
||||
self->name->setFocused(true);
|
||||
self->data.name = new TextInputBox("World Name", "Unnamed world");
|
||||
self->data.text_input.m_textInputs->push_back(self->data.name);
|
||||
self->data.name->init(super->font);
|
||||
self->data.name->setFocused(true);
|
||||
// Seed
|
||||
self->seed = TextInputBox::create("Seed");
|
||||
self->super.m_textInputs->push_back(self->seed);
|
||||
self->seed->init(super->font);
|
||||
self->seed->setFocused(false);
|
||||
self->data.seed = new TextInputBox("Seed");
|
||||
self->data.text_input.m_textInputs->push_back(self->data.seed);
|
||||
self->data.seed->init(super->font);
|
||||
self->data.seed->setFocused(false);
|
||||
// Game Mode
|
||||
self->game_mode = touch_create_button(1, CREATIVE_STR);
|
||||
super->rendered_buttons.push_back(self->game_mode);
|
||||
super->selectable_buttons.push_back(self->game_mode);
|
||||
self->data.game_mode = touch_create_button(1, CREATIVE_STR);
|
||||
super->rendered_buttons.push_back(self->data.game_mode);
|
||||
super->selectable_buttons.push_back(self->data.game_mode);
|
||||
// Create
|
||||
self->create = touch_create_button(2, "Create");
|
||||
super->rendered_buttons.push_back(self->create);
|
||||
super->selectable_buttons.push_back(self->create);
|
||||
self->data.create = touch_create_button(2, "Create");
|
||||
super->rendered_buttons.push_back(self->data.create);
|
||||
super->selectable_buttons.push_back(self->data.create);
|
||||
// Back
|
||||
self->back = touch_create_button(3, "Back");
|
||||
super->rendered_buttons.push_back(self->back);
|
||||
super->selectable_buttons.push_back(self->back);
|
||||
self->data.back = touch_create_button(3, "Back");
|
||||
super->rendered_buttons.push_back(self->data.back);
|
||||
super->selectable_buttons.push_back(self->data.back);
|
||||
};
|
||||
// Removal
|
||||
static Screen_removed_t original_removed = vtable->removed;
|
||||
vtable->removed = [](Screen *super) {
|
||||
original_removed(super);
|
||||
CreateWorldScreen *self = (CreateWorldScreen *) super;
|
||||
delete self->name;
|
||||
delete self->seed;
|
||||
self->game_mode->destructor_deleting();
|
||||
self->back->destructor_deleting();
|
||||
self->create->destructor_deleting();
|
||||
delete self->data.name;
|
||||
delete self->data.seed;
|
||||
self->data.game_mode->destructor_deleting();
|
||||
self->data.back->destructor_deleting();
|
||||
self->data.create->destructor_deleting();
|
||||
};
|
||||
// Rendering
|
||||
static Screen_render_t original_render = vtable->render;
|
||||
vtable->render = [](Screen *super, int x, int y, float param_1) {
|
||||
vtable->render = [](Screen *super, const int x, const int y, const float param_1) {
|
||||
// Background
|
||||
misc_render_background(80, super->minecraft, 0, 0, super->width, super->height);
|
||||
misc_render_background(32, super->minecraft, 0, content_y_offset_top, super->width, super->height - content_y_offset_top - content_y_offset_bottom);
|
||||
@ -89,9 +89,9 @@ CUSTOM_VTABLE(create_world_screen, Screen) {
|
||||
super->drawCenteredString(super->font, title, super->width / 2, title_padding, 0xffffffff);
|
||||
// Game Mode Description
|
||||
CreateWorldScreen *self = (CreateWorldScreen *) super;
|
||||
bool is_creative = self->game_mode->text == CREATIVE_STR;
|
||||
const bool is_creative = self->data.game_mode->text == CREATIVE_STR;
|
||||
std::string description = is_creative ? Strings::creative_mode_description : Strings::survival_mode_description;
|
||||
super->drawString(super->font, description, self->game_mode->x, self->game_mode->y + self->game_mode->height + description_padding, 0xa0a0a0);
|
||||
super->drawString(super->font, description, self->data.game_mode->x, self->data.game_mode->y + self->data.game_mode->height + description_padding, 0xa0a0a0);
|
||||
};
|
||||
// Positioning
|
||||
static Screen_setupPositions_t original_setupPositions = vtable->setupPositions;
|
||||
@ -99,33 +99,33 @@ CUSTOM_VTABLE(create_world_screen, Screen) {
|
||||
original_setupPositions(super);
|
||||
CreateWorldScreen *self = (CreateWorldScreen *) super;
|
||||
// Height/Width
|
||||
int width = 120;
|
||||
int height = button_height;
|
||||
self->create->width = self->back->width = self->game_mode->width = width;
|
||||
int seed_width = self->game_mode->width;
|
||||
constexpr int width = 120;
|
||||
const int height = button_height;
|
||||
self->data.create->width = self->data.back->width = self->data.game_mode->width = width;
|
||||
int seed_width = self->data.game_mode->width;
|
||||
int name_width = width * 1.5f;
|
||||
self->create->height = self->back->height = self->game_mode->height = height;
|
||||
int text_box_height = self->game_mode->height;
|
||||
self->data.create->height = self->data.back->height = self->data.game_mode->height = height;
|
||||
int text_box_height = self->data.game_mode->height;
|
||||
// Find Center Y
|
||||
int top = content_y_offset_top;
|
||||
int bottom = super->height - content_y_offset_bottom;
|
||||
const int top = content_y_offset_top;
|
||||
const int bottom = super->height - content_y_offset_bottom;
|
||||
int center_y = ((bottom - top) / 2) + top;
|
||||
center_y -= (description_padding + line_height) / 2;
|
||||
// X/Y
|
||||
self->create->y = self->back->y = super->height - bottom_padding - height;
|
||||
self->create->x = self->game_mode->x = (super->width / 2) - inner_padding - width;
|
||||
self->back->x = (super->width / 2) + inner_padding;
|
||||
int seed_x = self->back->x;
|
||||
int name_x = (super->width / 2) - (name_width / 2);
|
||||
int name_y = center_y - inner_padding - height;
|
||||
self->game_mode->y = center_y + inner_padding;
|
||||
int seed_y = self->game_mode->y;
|
||||
self->data.create->y = self->data.back->y = super->height - bottom_padding - height;
|
||||
self->data.create->x = self->data.game_mode->x = (super->width / 2) - inner_padding - width;
|
||||
self->data.back->x = (super->width / 2) + inner_padding;
|
||||
const int seed_x = self->data.back->x;
|
||||
const int name_x = (super->width / 2) - (name_width / 2);
|
||||
const int name_y = center_y - inner_padding - height;
|
||||
self->data.game_mode->y = center_y + inner_padding;
|
||||
const int seed_y = self->data.game_mode->y;
|
||||
// Update Text Boxes
|
||||
self->name->setSize(name_x, name_y, name_width, text_box_height);
|
||||
self->seed->setSize(seed_x, seed_y, seed_width, text_box_height);
|
||||
self->data.name->setSize(name_x, name_y, name_width, text_box_height);
|
||||
self->data.seed->setSize(seed_x, seed_y, seed_width, text_box_height);
|
||||
};
|
||||
// ESC
|
||||
vtable->handleBackEvent = [](Screen *super, bool do_nothing) {
|
||||
vtable->handleBackEvent = [](Screen *super, const bool do_nothing) {
|
||||
if (!do_nothing) {
|
||||
super->minecraft->screen_chooser.setScreen(5);
|
||||
}
|
||||
@ -134,16 +134,16 @@ CUSTOM_VTABLE(create_world_screen, Screen) {
|
||||
// Button Click
|
||||
vtable->buttonClicked = [](Screen *super, Button *button) {
|
||||
CreateWorldScreen *self = (CreateWorldScreen *) super;
|
||||
bool is_creative = self->game_mode->text == CREATIVE_STR;
|
||||
if (button == self->game_mode) {
|
||||
const bool is_creative = self->data.game_mode->text == CREATIVE_STR;
|
||||
if (button == self->data.game_mode) {
|
||||
// Toggle Game Mode
|
||||
self->game_mode->text = is_creative ? SURVIVAL_STR : CREATIVE_STR;
|
||||
} else if (button == self->back) {
|
||||
self->data.game_mode->text = is_creative ? SURVIVAL_STR : CREATIVE_STR;
|
||||
} else if (button == self->data.back) {
|
||||
// Back
|
||||
super->handleBackEvent(false);
|
||||
} else if (button == self->create) {
|
||||
} else if (button == self->data.create) {
|
||||
// Create
|
||||
create_world(super->minecraft, self->name->getText(), is_creative, self->seed->getText());
|
||||
create_world(super->minecraft, self->data.name->getText(), is_creative, self->data.seed->getText());
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -151,10 +151,10 @@ static Screen *create_create_world_screen() {
|
||||
// Construct
|
||||
CreateWorldScreen *screen = new CreateWorldScreen;
|
||||
ALLOC_CHECK(screen);
|
||||
screen->super.super.constructor();
|
||||
screen->super()->constructor();
|
||||
|
||||
// Set VTable
|
||||
screen->super.super.vtable = get_create_world_screen_vtable();
|
||||
screen->super()->vtable = get_create_world_screen_vtable();
|
||||
|
||||
// Return
|
||||
return (Screen *) screen;
|
||||
@ -170,7 +170,7 @@ static std::string getUniqueLevelName(LevelStorageSource *source, const std::str
|
||||
maps.insert(ls.folder);
|
||||
}
|
||||
std::string out = in;
|
||||
while (maps.find(out) != maps.end()) {
|
||||
while (maps.contains(out)) {
|
||||
out += "-";
|
||||
}
|
||||
return out;
|
||||
@ -192,14 +192,14 @@ int get_seed_from_string(std::string str) {
|
||||
}
|
||||
return seed;
|
||||
}
|
||||
static void create_world(Minecraft *minecraft, std::string name, bool is_creative, std::string seed_str) {
|
||||
static void create_world(Minecraft *minecraft, std::string name, const bool is_creative, std::string seed_str) {
|
||||
// Get Seed
|
||||
int seed = get_seed_from_string(std::move(seed_str));
|
||||
const int seed = get_seed_from_string(std::move(seed_str));
|
||||
|
||||
// Get Folder Name
|
||||
name = Util::stringTrim(name);
|
||||
std::string folder = "";
|
||||
for (char c : name) {
|
||||
for (const char c : name) {
|
||||
if (
|
||||
c >= ' ' && c <= '~' &&
|
||||
c != '/' &&
|
||||
@ -233,7 +233,7 @@ static void create_world(Minecraft *minecraft, std::string name, bool is_creativ
|
||||
minecraft->hostMultiplayer(19132);
|
||||
|
||||
// Open ProgressScreen
|
||||
ProgressScreen *screen = new ProgressScreen;
|
||||
ProgressScreen *screen = ProgressScreen::allocate();
|
||||
ALLOC_CHECK(screen);
|
||||
screen = screen->constructor();
|
||||
minecraft->setScreen((Screen *) screen);
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include "input-internal.h"
|
||||
|
||||
// Translator
|
||||
static int32_t sdl_key_to_minecraft_key_injection(Common_sdl_key_to_minecraft_key_t original, int32_t sdl_key) {
|
||||
static int32_t sdl_key_to_minecraft_key_injection(Common_sdl_key_to_minecraft_key_t original, const int32_t sdl_key) {
|
||||
switch (sdl_key) {
|
||||
#define KEY(name, value) case SDLK_##name: return MC_KEY_##name;
|
||||
#include <mods/input/key-list.h>
|
||||
|
@ -23,7 +23,7 @@ static void _handle_back(Minecraft *minecraft) {
|
||||
}
|
||||
|
||||
// Fix OptionsScreen Ignoring The Back Button
|
||||
static bool OptionsScreen_handleBackEvent_injection(OptionsScreen *screen, bool do_nothing) {
|
||||
static bool OptionsScreen_handleBackEvent_injection(OptionsScreen *screen, const bool do_nothing) {
|
||||
if (!do_nothing) {
|
||||
Minecraft *minecraft = screen->minecraft;
|
||||
minecraft->setScreen(nullptr);
|
||||
@ -59,7 +59,7 @@ static bool Gui_tickItemDrop_Minecraft_isCreativeMode_call_injection(Minecraft *
|
||||
}
|
||||
|
||||
// Block UI Interaction When Mouse Is Locked
|
||||
static void Gui_handleClick_injection(Gui_handleClick_t original, Gui *gui, int32_t param_2, int32_t param_3, int32_t param_4) {
|
||||
static void Gui_handleClick_injection(Gui_handleClick_t original, Gui *gui, const int32_t param_2, const int32_t param_3, const int32_t param_4) {
|
||||
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF) {
|
||||
// Call Original Method
|
||||
original(gui, param_2, param_3, param_4);
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include <mods/misc/misc.h>
|
||||
|
||||
// Handle Toggle Options
|
||||
static bool _handle_toggle_options(Minecraft *minecraft, int key) {
|
||||
static bool _handle_toggle_options(Minecraft *minecraft, const int key) {
|
||||
Options *options = &minecraft->options;
|
||||
if (key == MC_KEY_F1) {
|
||||
// Toggle Hide GUI
|
||||
@ -49,13 +49,13 @@ static void revert_rotation(Entity *entity) {
|
||||
}
|
||||
static bool is_front_facing = false;
|
||||
static LocalPlayer *stored_player = nullptr;
|
||||
static void GameRenderer_setupCamera_injection(GameRenderer_setupCamera_t original, GameRenderer *game_renderer, float param_1, int param_2) {
|
||||
static void GameRenderer_setupCamera_injection(GameRenderer_setupCamera_t original, GameRenderer *game_renderer, const float param_1, const int param_2) {
|
||||
// Get Objects
|
||||
Minecraft *minecraft = game_renderer->minecraft;
|
||||
stored_player = minecraft->player;
|
||||
|
||||
// Check If In Third-Person
|
||||
Options *options = &minecraft->options;
|
||||
const Options *options = &minecraft->options;
|
||||
is_front_facing = (options->third_person == 2);
|
||||
|
||||
// Invert Rotation
|
||||
@ -71,7 +71,7 @@ static void GameRenderer_setupCamera_injection(GameRenderer_setupCamera_t origin
|
||||
revert_rotation((Entity *) stored_player);
|
||||
}
|
||||
}
|
||||
static void ParticleEngine_render_injection(ParticleEngine_render_t original, ParticleEngine *particle_engine, Entity *entity, float param_2) {
|
||||
static void ParticleEngine_render_injection(ParticleEngine_render_t original, ParticleEngine *particle_engine, Entity *entity, const float param_2) {
|
||||
// Invert Rotation
|
||||
if (is_front_facing && (Entity *) stored_player == entity) {
|
||||
invert_rotation((Entity *) stored_player);
|
||||
|
@ -55,7 +55,7 @@ void misc_run_on_update(const std::function<void(Minecraft *)> &func) {
|
||||
});
|
||||
}
|
||||
void misc_run_on_tick(const std::function<void(Minecraft *)> &func) {
|
||||
overwrite_calls(Minecraft_tick, [func](Minecraft_tick_t original, Minecraft *self, int tick, int max_ticks) {
|
||||
overwrite_calls(Minecraft_tick, [func](Minecraft_tick_t original, Minecraft *self, const int tick, const int max_ticks) {
|
||||
original(self, tick, max_ticks);
|
||||
func(self);
|
||||
});
|
||||
@ -93,7 +93,7 @@ void misc_run_on_language_setup(const std::function<void()> &func) {
|
||||
});
|
||||
}
|
||||
void misc_run_on_game_key_press(const std::function<bool(Minecraft *, int)> &func) {
|
||||
overwrite_calls(Gui_handleKeyPressed, [func](Gui_handleKeyPressed_t original, Gui *self, int key) {
|
||||
overwrite_calls(Gui_handleKeyPressed, [func](Gui_handleKeyPressed_t original, Gui *self, const int key) {
|
||||
if (func(self->minecraft, key)) {
|
||||
return;
|
||||
}
|
||||
@ -102,7 +102,7 @@ void misc_run_on_game_key_press(const std::function<bool(Minecraft *, int)> &fun
|
||||
}
|
||||
void misc_run_on_key_press(const std::function<bool(Minecraft *, int)> &func) {
|
||||
misc_run_on_game_key_press(func);
|
||||
overwrite_calls(Screen_keyPressed, [func](Screen_keyPressed_t original, Screen *self, int key) {
|
||||
overwrite_calls(Screen_keyPressed, [func](Screen_keyPressed_t original, Screen *self, const int key) {
|
||||
if (func(self->minecraft, key)) {
|
||||
return;
|
||||
}
|
||||
@ -111,7 +111,7 @@ void misc_run_on_key_press(const std::function<bool(Minecraft *, int)> &func) {
|
||||
}
|
||||
|
||||
// Render Fancy Background
|
||||
void misc_render_background(int color, Minecraft *minecraft, int x, int y, int width, int height) {
|
||||
void misc_render_background(int color, const Minecraft *minecraft, const int x, const int y, const int width, const int height) {
|
||||
// https://github.com/ReMinecraftPE/mcpe/blob/f0d65eaecec1b3fe9c2f2b251e114a890c54ab77/source/client/gui/components/RolledSelectionList.cpp#L169-L179
|
||||
glColor4f(1, 1, 1, 1);
|
||||
minecraft->textures->loadAndBindTexture("gui/background.png");
|
||||
|
@ -114,7 +114,7 @@ static int32_t FurnaceScreen_handleAddItem_injection(FurnaceScreen_handleAddItem
|
||||
}
|
||||
|
||||
// Get Real Selected Slot
|
||||
int32_t misc_get_real_selected_slot(Player *player) {
|
||||
int32_t misc_get_real_selected_slot(const Player *player) {
|
||||
// Get Selected Slot
|
||||
const Inventory *inventory = player->inventory;
|
||||
int32_t selected_slot = inventory->selectedSlot;
|
||||
@ -376,7 +376,7 @@ static void LocalPlayer_tick_injection(LocalPlayer_tick_t original, LocalPlayer
|
||||
const bool synced = self->getSharedFlag(FLAG_SNEAKING);
|
||||
if (real != synced) {
|
||||
// Send To Server
|
||||
PlayerActionPacket *packet = new PlayerActionPacket;
|
||||
PlayerActionPacket *packet = PlayerActionPacket::allocate();
|
||||
Packet_constructor->get(false)((Packet *) packet);
|
||||
packet->vtable = PlayerActionPacket_vtable_base;
|
||||
packet->entity_id = self->id;
|
||||
|
@ -33,7 +33,7 @@ static void Gui_renderHearts_injection(Gui_renderHearts_t original, Gui *gui) {
|
||||
}
|
||||
#define PINK_HEART_FULL 70
|
||||
#define PINK_HEART_HALF 79
|
||||
static void Gui_renderHearts_GuiComponent_blit_overlay_empty_injection(Gui *gui, int32_t x1, int32_t y1, int32_t x2, int32_t y2, int32_t w1, int32_t h1, int32_t w2, int32_t h2) {
|
||||
static void Gui_renderHearts_GuiComponent_blit_overlay_empty_injection(Gui *gui, const int32_t x1, const int32_t y1, const int32_t x2, const int32_t y2, const int32_t w1, const int32_t h1, const int32_t w2, const int32_t h2) {
|
||||
// Call Original Method
|
||||
get_blit_with_classic_hud_offset()((GuiComponent *) gui, x1, y1, x2, y2, w1, h1, w2, h2);
|
||||
// Render The Overlay
|
||||