Use New Method Call Style

This commit is contained in:
TheBrokenRail 2024-05-15 05:02:19 -04:00
parent 73454adc22
commit 51bbad15f4
54 changed files with 256 additions and 212 deletions

@ -1 +1 @@
Subproject commit 9697b35de4d783282afdd3a4c643951ce49a0158
Subproject commit eca52455c3d8a520aba30b81d17031340b76ff88

View File

@ -14,13 +14,6 @@ void reborn_init_patch();
void _overwrite_call(const char *file, int line, void *start, void *target);
#define overwrite_call(start, target) _overwrite_call(__FILE__, __LINE__, start, target)
#define _check_if_method_is_new(name) \
{ \
if (!__is_new_method_##name()) { \
ERR("Method Is Not \"New\""); \
} \
}
#define _setup_fancy_overwrite(start, name, target) \
static name##_t _original_for_##target = start; \
static name##_t _helper_for_##target = __overwrite_helper_for_##name(target, _original_for_##target)
@ -35,6 +28,12 @@ void *_overwrite_calls(const char *file, int line, void *start, void *target);
}
// Replace All Calls To Virtual Method start With target
#define _check_if_method_is_new(name) \
{ \
if (!__is_new_method_##name()) { \
ERR("Method Is Not \"New\""); \
} \
}
#define overwrite_virtual_calls(start, target) \
{ \
_check_if_method_is_new(start); \

View File

@ -15,10 +15,10 @@ static void ItemRenderer_renderGuiItemCorrect_injection(ItemRenderer_renderGuiIt
bool use_carried = false;
if (item_instance != nullptr) {
if (item_instance->id == leaves_id) {
ItemInstance_constructor_tile_extra(&carried_item_instance, Tile_leaves_carried, item_instance->count, item_instance->auxiliary);
carried_item_instance.constructor_tile_extra(Tile_leaves_carried, item_instance->count, item_instance->auxiliary);
use_carried = true;
} else if (item_instance->id == grass_id) {
ItemInstance_constructor_tile_extra(&carried_item_instance, Tile_grass_carried, item_instance->count, item_instance->auxiliary);
carried_item_instance.constructor_tile_extra(Tile_grass_carried, item_instance->count, item_instance->auxiliary);
use_carried = true;
}
}
@ -64,12 +64,12 @@ static void Tesselator_begin_injection(Tesselator_begin_t original, Tesselator *
// Fix Furnace UI
if (item_color_fix_mode != 0) {
// Implict Translucent
Tesselator_color(tesselator, 0xff, 0xff, 0xff, 0xff);
tesselator->color(0xff, 0xff, 0xff, 0xff);
}
}
static void InventoryPane_renderBatch_Tesselator_color_injection(Tesselator *tesselator, int32_t r, int32_t g, int32_t b) {
// Call Original Method
Tesselator_color(tesselator, r, g, b, 0xff);
tesselator->color(r, g, b, 0xff);
// Enable Item Color Fix
item_color_fix_mode = 2;
@ -86,7 +86,7 @@ static void FurnaceScreen_render_ItemRenderer_renderGuiItem_one_injection(Font *
item_color_fix_mode = 1;
// Call Original Method
ItemRenderer_renderGuiItem_one(font, textures, item_instance, param_1, param_2, param_3);
ItemRenderer::renderGuiItem_one(font, textures, item_instance, param_1, param_2, param_3);
}
// Init
@ -107,3 +107,4 @@ void init_atlas() {
overwrite_call((void *) 0x1e21c, (void *) InventoryPane_renderBatch_Tesselator_color_injection);
}
}

View File

@ -32,18 +32,18 @@ static void start_world(Minecraft *minecraft) {
settings.seed = BENCHMARK_SEED;
// Delete World If It Already Exists
LevelStorageSource *level_source = Minecraft_getLevelSource(minecraft);
LevelStorageSource *level_source = minecraft->getLevelSource();
std::string name = BENCHMARK_WORLD_NAME;
level_source->vtable->deleteLevel(level_source, &name);
level_source->deleteLevel(&name);
// Select Level
minecraft->vtable->selectLevel(minecraft, &name, &name, &settings);
minecraft->selectLevel(&name, &name, &settings);
// Open ProgressScreen
ProgressScreen *screen = alloc_ProgressScreen();
ALLOC_CHECK(screen);
screen = ProgressScreen_constructor(screen);
Minecraft_setScreen(minecraft, (Screen *) screen);
screen = screen->constructor();
minecraft->setScreen((Screen *) screen);
}
// Track Frames
@ -93,7 +93,7 @@ static void Minecraft_update_injection(Minecraft *minecraft) {
}
// Detect World Loaded
if (!world_loaded && Minecraft_isLevelGenerated(minecraft)) {
if (!world_loaded && minecraft->isLevelGenerated()) {
world_loaded = 1;
world_loaded_time = get_time();
#ifndef MCPI_HEADLESS_MODE
@ -171,3 +171,4 @@ void init_benchmark() {
media_disable_vsync();
}
}

View File

@ -45,7 +45,7 @@ static bool fill_bucket(ItemInstance *item_instance, Player *player, int new_aux
new_item.count = 1;
new_item.auxiliary = new_auxiliary;
Inventory *inventory = player->inventory;
if (inventory->vtable->add(inventory, &new_item)) {
if (inventory->add(&new_item)) {
// Added To Inventory
success = true;
item_instance->count -= 1;
@ -62,7 +62,7 @@ static int32_t BucketItem_useOn(__attribute__((unused)) FoodItem *item, ItemInst
} else if (item_instance->auxiliary == 0) {
// Empty Bucket
int32_t new_auxiliary = 0;
int32_t tile = level->vtable->getTile(level, x, y, z);
int32_t tile = level->getTile(x, y, z);
if (tile == Tile_calmWater->id) {
new_auxiliary = Tile_water->id;
} else if (tile == Tile_calmLava->id) {
@ -71,7 +71,7 @@ static int32_t BucketItem_useOn(__attribute__((unused)) FoodItem *item, ItemInst
if (new_auxiliary != 0) {
// Valid
if (fill_bucket(item_instance, player, new_auxiliary)) {
Level_setTileAndData(level, x, y, z, 0, 0);
level->setTileAndData(x, y, z, 0, 0);
return 1;
} else {
return 0;
@ -110,15 +110,15 @@ static int32_t BucketItem_useOn(__attribute__((unused)) FoodItem *item, ItemInst
}
// Get Current Tile
bool valid = false;
Material *material = level->vtable->getMaterial(level, x, y, z);
Material *material = level->getMaterial(x, y, z);
if (material != nullptr) {
valid = !material->vtable->isSolid(material);
valid = !material->isSolid();
}
if (item_instance->auxiliary != Tile_water->id && item_instance->auxiliary != Tile_lava->id) {
valid = false;
}
if (valid) {
Level_setTileAndData(level, x, y, z, item_instance->auxiliary, 0);
level->setTileAndData(x, y, z, item_instance->auxiliary, 0);
item_instance->auxiliary = 0;
return 1;
} else {
@ -188,14 +188,14 @@ static FoodItem *create_bucket(int32_t id, int32_t texture_x, int32_t texture_y,
// Construct
FoodItem *item = alloc_FoodItem();
ALLOC_CHECK(item);
Item_constructor((Item *) item, id);
Item_constructor((Item *) item, id); // FoodItem's Constructor Was Inlined
// Set VTable
item->vtable = get_bucket_vtable();
// Setup
item->vtable->setIcon(item, texture_x, texture_y);
item->vtable->setDescriptionId(item, &name);
item->setIcon(texture_x, texture_y);
item->setDescriptionId(&name);
item->is_stacked_by_data = 1;
item->category = 2;
item->max_damage = 0;
@ -224,7 +224,7 @@ static int32_t ItemInstance_getMaxStackSize_injection(ItemInstance_getMaxStackSi
// Milking
bool Cow_interact_injection(Cow_interact_t original, Cow *self, Player *player) {
ItemInstance *item = Inventory_getSelected(player->inventory);
ItemInstance *item = player->inventory->getSelected();
if (item && item->id == bucket->id && item->auxiliary == 0) {
// Fill with milk
fill_bucket(item, player, 1);
@ -237,8 +237,8 @@ bool Cow_interact_injection(Cow_interact_t original, Cow *self, Player *player)
static void inventory_add_item(FillingContainer *inventory, FoodItem *item, int32_t auxiliary) {
ItemInstance *item_instance = new ItemInstance;
ALLOC_CHECK(item_instance);
item_instance = ItemInstance_constructor_item_extra(item_instance, (Item *) item, 1, auxiliary);
FillingContainer_addItem(inventory, item_instance);
item_instance = item_instance->constructor_item_extra((Item *) item, 1, auxiliary);
inventory->addItem(item_instance);
}
static void Inventory_setupDefault_FillingContainer_addItem_call_injection(FillingContainer *filling_container) {
inventory_add_item(filling_container, bucket, 0);
@ -251,7 +251,7 @@ static void Inventory_setupDefault_FillingContainer_addItem_call_injection(Filli
static bool is_holding_bucket = false;
static HitResult Mob_pick_Level_clip_injection(Level *level, unsigned char *param_1, unsigned char *param_2, __attribute__((unused)) bool clip_liquids, bool param_3) {
// Call Original Method
return Level_clip(level, param_1, param_2, is_holding_bucket, param_3);
return level->clip(param_1, param_2, is_holding_bucket, param_3);
}
static void handle_tick(Minecraft *minecraft) {
LocalPlayer *player = minecraft->player;
@ -261,7 +261,7 @@ static void handle_tick(Minecraft *minecraft) {
Inventory *inventory = player->inventory;
// Get Item
ItemInstance *inventory_item = inventory->vtable->getItem(inventory, selected_slot);
ItemInstance *inventory_item = inventory->getItem(selected_slot);
// Check
is_holding_bucket = inventory_item != nullptr && inventory_item->id == bucket->id && inventory_item->auxiliary == 0;
}
@ -284,7 +284,7 @@ static void Minecraft_handleMouseDown_injection(Minecraft_handleMouseDown_t orig
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->vtable->getTile(level, x, y, z);
int32_t tile = level->getTile(x, y, z);
if (is_calm_liquid(tile)) {
can_destroy = false;
}
@ -315,7 +315,7 @@ static void Recipes_injection(Recipes *recipes) {
std::string line1 = "# #";
std::string line2 = " # ";
std::vector<Recipes_Type> types = {type1};
Recipes_addShapedRecipe_2(recipes, &result, &line1, &line2, &types);
recipes->addShapedRecipe_2(&result, &line1, &line2, &types);
}
// Custom Furnace Fuel
@ -372,3 +372,4 @@ void init_bucket() {
misc_run_on_language_setup(Language_injection);
}
}

View File

@ -31,7 +31,7 @@ static int Cake_getTexture2(__attribute__((unused)) Tile *tile, int face, __attr
static int Cake_getTexture3(__attribute__((unused)) Tile *tile, LevelSource *level, int x, int y, int z, int face) {
// Eaten face
if (face == 3) {
int data = level->vtable->getData(level, x, y, z);
int data = level->getData(x, y, z);
if (data != 0 && data < 6) {
// Sliced texture
return 123;
@ -59,8 +59,7 @@ static bool Cake_isCubeShaped(__attribute__((unused)) Tile *tile) {
// Size
static void Cake_updateDefaultShape(Tile *tile) {
// Set the default shape
tile->vtable->setShape(
tile,
tile->setShape(
CAKE_LEN, 0.0, CAKE_LEN,
1.0 - CAKE_LEN, 0.5, 1.0 - CAKE_LEN
);
@ -68,7 +67,7 @@ static void Cake_updateDefaultShape(Tile *tile) {
static AABB *Cake_getAABB(Tile *tile, Level *level, int x, int y, int z) {
// Get the size of the slices
int data = level->vtable->getData(level, x, y, z);
int data = level->getData(x, y, z);
if (data >= 6) data = 0;
float slice_size = (1.0 / 7.0) * (float) data;
@ -88,12 +87,11 @@ static AABB *Cake_getAABB(Tile *tile, Level *level, int x, int y, int z) {
static void Cake_updateShape(Tile *tile, LevelSource *level, int x, int y, int z) {
// Set cake
int data = level->vtable->getData(level, x, y, 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;
tile->vtable->setShape(
tile,
tile->setShape(
CAKE_LEN, 0.0, CAKE_LEN,
1.0 - CAKE_LEN, 0.5, (1.0 - CAKE_LEN) - slice_size
);
@ -102,15 +100,15 @@ static void Cake_updateShape(Tile *tile, LevelSource *level, int x, int y, int z
// Eating
static int Cake_use(__attribute__((unused)) Tile *tile, Level *level, int x, int y, int z, Player *player) {
// Eat
SimpleFoodData_eat(&player->foodData, 3);
player->foodData.eat(3);
// Set the new tile
int data = level->vtable->getData(level, x, y, z);
int data = level->getData(x, y, z);
if (data >= 5) {
// Remove the cake, it has been completely gobbled up
Level_setTileAndData(level, x, y, z, 0, 0);
level->setTileAndData(x, y, z, 0, 0);
} else {
// Remove a slice
Level_setTileAndData(level, x, y, z, 92, data + 1);
level->setTileAndData(x, y, z, 92, data + 1);
}
return 1;
}
@ -121,7 +119,7 @@ static void make_cake() {
cake = alloc_Tile();
ALLOC_CHECK(cake);
int texture = 122;
Tile_constructor(cake, 92, texture, Material_dirt);
cake->constructor(92, texture, Material_dirt);
cake->texture = texture;
// Set VTable
@ -129,8 +127,7 @@ static void make_cake() {
ALLOC_CHECK(cake->vtable);
// Set shape
cake->vtable->setShape(
cake,
cake->setShape(
CAKE_LEN, 0.0, CAKE_LEN,
1.0 - CAKE_LEN, 0.5, 1.0 - CAKE_LEN
);
@ -148,12 +145,12 @@ static void make_cake() {
cake->vtable->use = Cake_use;
// Init
Tile_init(cake);
cake->vtable->setDestroyTime(cake, 1.0f);
cake->vtable->setExplodeable(cake, 20.0f);
cake->init();
cake->setDestroyTime(1.0f);
cake->setExplodeable(20.0f);
cake->category = 4;
std::string name = "Cake";
cake->vtable->setDescriptionId(cake, &name);
cake->setDescriptionId(&name);
}
static void Tile_initTiles_injection(__attribute__((unused)) void *null) {
@ -167,7 +164,7 @@ static void Inventory_setupDefault_FillingContainer_addItem_call_injection(Filli
cake_instance->count = 255;
cake_instance->auxiliary = 0;
cake_instance->id = 92;
FillingContainer_addItem(filling_container, cake_instance);
filling_container->addItem(cake_instance);
}
// Recipe (only when buckets are enabled)
@ -227,7 +224,7 @@ static void Recipes_injection(Recipes *recipes) {
std::string line2 = "ses";
std::string line3 = "www";
std::vector<Recipes_Type> ingredients = {milk, sugar, wheat, eggs};
Recipes_addShapedRecipe_3(recipes, &cake_item, &line1, &line2, &line3, &ingredients);
recipes->addShapedRecipe_3(&cake_item, &line1, &line2, &line3, &ingredients);
}
void init_cake() {
@ -241,3 +238,4 @@ void init_cake() {
}
}
}

View File

@ -21,8 +21,8 @@ static EntityRenderDispatcher *EntityRenderDispatcher_injection(EntityRenderDisp
// Register TripodCameraRenderer
TripodCameraRenderer *renderer = alloc_TripodCameraRenderer();
ALLOC_CHECK(renderer);
TripodCameraRenderer_constructor(renderer);
EntityRenderDispatcher_assign(dispatcher, (unsigned char) 0x5, (EntityRenderer *) renderer);
renderer->constructor();
dispatcher->assign((unsigned char) 0x5, (EntityRenderer *) renderer);
return dispatcher;
}
@ -30,7 +30,7 @@ static EntityRenderDispatcher *EntityRenderDispatcher_injection(EntityRenderDisp
// Display Smoke From TripodCamera Higher
static void TripodCamera_tick_Level_addParticle_call_injection(Level *level, std::string *particle, float x, float y, float z, float deltaX, float deltaY, float deltaZ, int count) {
// Call Original Method
Level_addParticle(level, particle, x, y + 0.5, z, deltaX, deltaY, deltaZ, count);
level->addParticle(particle, x, y + 0.5, z, deltaX, deltaY, deltaZ, count);
}
// Init
@ -46,3 +46,4 @@ void init_camera() {
overwrite_call((void *) 0x87dc4, (void *) TripodCamera_tick_Level_addParticle_call_injection);
}
}

View File

@ -19,7 +19,7 @@ std::string chat_send_api_command(Minecraft *minecraft, std::string str) {
client.time = 0;
CommandServer *command_server = minecraft->command_server;
if (command_server != nullptr) {
return CommandServer_parse(command_server, &client, &str);
return command_server->parse(&client, &str);
} else {
return "";
}
@ -43,19 +43,19 @@ void chat_send_message(ServerSideNetworkHandler *server_side_network_handler, ch
sanitize_string(&full_message, MAX_CHAT_MESSAGE_LENGTH, 0);
std::string cpp_string = full_message;
free(full_message);
ServerSideNetworkHandler_displayGameMessage(server_side_network_handler, &cpp_string);
server_side_network_handler->displayGameMessage(&cpp_string);
}
// Handle Chat packet Send
void chat_handle_packet_send(Minecraft *minecraft, ChatPacket *packet) {
RakNetInstance *rak_net_instance = minecraft->rak_net_instance;
if (rak_net_instance->vtable->isServer(rak_net_instance)) {
if (rak_net_instance->isServer()) {
// Hosting Multiplayer
const char *message = packet->message.c_str();
ServerSideNetworkHandler *server_side_network_handler = (ServerSideNetworkHandler *) minecraft->network_handler;
chat_send_message(server_side_network_handler, Strings_default_username, (char *) message);
} else {
// Client
rak_net_instance->vtable->send(rak_net_instance, (Packet *) packet);
rak_net_instance->send((Packet *) packet);
}
}
@ -69,7 +69,7 @@ static void CommandServer_parse_CommandServer_dispatchPacket_injection(CommandSe
// Handle ChatPacket Server-Side
static void ServerSideNetworkHandler_handle_ChatPacket_injection(ServerSideNetworkHandler *server_side_network_handler, RakNet_RakNetGUID *rak_net_guid, ChatPacket *chat_packet) {
Player *player = ServerSideNetworkHandler_getPlayer(server_side_network_handler, rak_net_guid);
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();
@ -99,3 +99,4 @@ void init_chat() {
patch((void *) 0x6b4c0, message_limit_patch);
}
}

View File

@ -51,15 +51,15 @@ CUSTOM_VTABLE(chat_screen, Screen) {
is_in_chat = false;
ChatScreen *self = (ChatScreen *) super;
delete self->chat;
self->send->vtable->destructor_deleting(self->send);
self->send->destructor_deleting();
};
// Rendering
static Screen_render_t original_render = vtable->render;
vtable->render = [](Screen *super, int x, int y, float param_1) {
// Background
super->vtable->renderBackground(super);
super->renderBackground();
// Render Chat
Gui_renderChatMessages(&super->minecraft->gui, super->height, 20, true, super->font);
super->minecraft->gui.renderChatMessages(super->height, 20, true, super->font);
// Call Original Method
original_render(super, x, y, param_1);
};
@ -91,7 +91,7 @@ CUSTOM_VTABLE(chat_screen, Screen) {
}
_chat_send_message(super->minecraft, text.c_str());
}
Minecraft_setScreen(super->minecraft, nullptr);
super->minecraft->setScreen(nullptr);
} else if (key == 0x26) {
// Up
local_history.at(self->history_pos) = self->chat->getText();
@ -120,7 +120,7 @@ CUSTOM_VTABLE(chat_screen, Screen) {
if (button == self->send) {
// Send
self->chat->setFocused(true);
super->vtable->keyPressed(super, 0x0d);
super->keyPressed(0x0d);
} else {
// Call Original Method
original_buttonClicked(super, button);
@ -131,7 +131,7 @@ static Screen *create_chat_screen() {
// Construct
ChatScreen *screen = new ChatScreen;
ALLOC_CHECK(screen);
Screen_constructor(&screen->super.super);
screen->super.super.constructor();
// Set VTable
screen->super.super.vtable = get_chat_screen_vtable();
@ -145,7 +145,7 @@ void _init_chat_ui() {
misc_run_on_game_key_press([](Minecraft *minecraft, int key) {
if (key == 0x54) {
if (Minecraft_isLevelGenerated(minecraft) && minecraft->screen == nullptr) {
Minecraft_setScreen(minecraft, create_chat_screen());
minecraft->setScreen(create_chat_screen());
}
return true;
} else {
@ -153,3 +153,4 @@ void _init_chat_ui() {
}
});
}

View File

@ -17,3 +17,4 @@ void _patch_bcm_host_calls() {
overwrite_call((void *) 0x12618, (void *) do_nothing); // vc_dispmanx_element_add
overwrite_call((void *) 0x12624, (void *) do_nothing); // vc_dispmanx_update_submit_sync
}

View File

@ -140,3 +140,4 @@ void compat_request_exit() {
// Request
exit_requested = 1;
}

View File

@ -38,3 +38,4 @@ void _patch_egl_calls() {
patch((void *) 0x12504, nop_patch); // eglDestroySurface #2
overwrite_call((void *) 0x12594, (void *) eglCreateContext_injection); // eglCreateContext
}

View File

@ -27,3 +27,4 @@ void _patch_x11_calls() {
overwrite_call((void *) 0x132a4, (void *) XGetWindowAttributes_injection); // XGetWindowAttributes
overwrite_call((void *) 0x132d4, (void *) XTranslateCoordinates_injection); // XTranslateCoordinates
}

View File

@ -11,14 +11,14 @@
static void inventory_add_item(FillingContainer *inventory, Item *item) {
ItemInstance *item_instance = new ItemInstance;
ALLOC_CHECK(item_instance);
item_instance = ItemInstance_constructor_item(item_instance, item);
FillingContainer_addItem(inventory, item_instance);
item_instance = item_instance->constructor_item(item);
inventory->addItem(item_instance);
}
static void inventory_add_item(FillingContainer *inventory, Tile *item) {
ItemInstance *item_instance = new ItemInstance;
ALLOC_CHECK(item_instance);
item_instance = ItemInstance_constructor_tile(item_instance, item);
FillingContainer_addItem(inventory, item_instance);
item_instance = item_instance->constructor_tile(item);
inventory->addItem(item_instance);
}
// Expand Creative Inventory
@ -36,8 +36,8 @@ static void Inventory_setupDefault_FillingContainer_addItem_call_injection(Filli
}
ItemInstance *new_item_instance = new ItemInstance;
ALLOC_CHECK(new_item_instance);
new_item_instance = ItemInstance_constructor_item_extra(new_item_instance, Item_dye_powder, 1, i);
FillingContainer_addItem(filling_container, new_item_instance);
new_item_instance = new_item_instance->constructor_item_extra(Item_dye_powder, 1, i);
filling_container->addItem(new_item_instance);
}
inventory_add_item(filling_container, Item_camera);
// Add Tiles
@ -61,8 +61,8 @@ static void Inventory_setupDefault_FillingContainer_addItem_call_injection(Filli
}
ItemInstance *new_item_instance = new ItemInstance;
ALLOC_CHECK(new_item_instance);
new_item_instance = ItemInstance_constructor_tile_extra(new_item_instance, Tile_netherReactor, 1, i);
FillingContainer_addItem(filling_container, new_item_instance);
new_item_instance = new_item_instance->constructor_tile_extra(Tile_netherReactor, 1, i);
filling_container->addItem(new_item_instance);
}
// Tall Grass
for (int i = 0; i < 4; i++) {
@ -72,15 +72,15 @@ static void Inventory_setupDefault_FillingContainer_addItem_call_injection(Filli
}
ItemInstance *new_item_instance = new ItemInstance;
ALLOC_CHECK(new_item_instance);
new_item_instance = ItemInstance_constructor_tile_extra(new_item_instance, Tile_tallgrass, 1, i);
FillingContainer_addItem(filling_container, new_item_instance);
new_item_instance = new_item_instance->constructor_tile_extra(Tile_tallgrass, 1, i);
filling_container->addItem(new_item_instance);
}
// Smooth Stone Slab
{
ItemInstance *new_item_instance = new ItemInstance;
ALLOC_CHECK(new_item_instance);
new_item_instance = ItemInstance_constructor_tile_extra(new_item_instance, Tile_stoneSlab, 1, 6);
FillingContainer_addItem(filling_container, new_item_instance);
new_item_instance = new_item_instance->constructor_tile_extra(Tile_stoneSlab, 1, 6);
filling_container->addItem(new_item_instance);
}
}
#endif
@ -88,7 +88,7 @@ static void Inventory_setupDefault_FillingContainer_addItem_call_injection(Filli
// Hook Specific TileItem Constructor
static TileItem *Tile_initTiles_TileItem_injection(TileItem *tile_item, int32_t id) {
// Call Original Method
TileItem_constructor(tile_item, id);
tile_item->constructor(id);
// Switch VTable
tile_item->vtable = (TileItem_vtable *) AuxDataTileItem_vtable_base;
@ -173,3 +173,4 @@ void init_creative() {
patch((void *) 0x8e104, maximize_stack_patch);
}
}

View File

@ -13,10 +13,10 @@ std::string get_death_message(Player *player, Entity *cause, bool was_shot = fal
std::string message = player->username;
if (cause) {
// Entity cause
int type_id = cause->vtable->getEntityTypeId(cause);
int aux = cause->vtable->getAuxData(cause);
bool is_player = cause->vtable->isPlayer(cause);
if (cause->vtable->getCreatureBaseType(cause) != 0 || is_player) {
int type_id = cause->getEntityTypeId();
int aux = cause->getAuxData();
bool is_player = cause->isPlayer();
if (cause->getCreatureBaseType() != 0 || is_player) {
// Killed by a creature
if (was_shot) {
message += " was shot by ";
@ -38,12 +38,12 @@ std::string get_death_message(Player *player, Entity *cause, bool was_shot = fal
} else if (aux) {
// Killed by a throwable with owner
Level *level = player->level;
Entity *shooter = Level_getEntity(level, aux);
Entity *shooter = level->getEntity(aux);
return get_death_message(player, shooter, true);
} else if (type_id == 65) {
// Blown up by TNT
return message + " was blown apart";
} else if (cause->vtable->isHangingEntity(cause)) {
} else if (cause->isHangingEntity()) {
// Painting?
return message + " admired too much art";
}
@ -81,13 +81,13 @@ static bool Mob_hurt_injection(Mob_hurt_t original, Mob *mob, Entity *source, in
/* Get Variable */ \
RakNetInstance *rak_net_instance = player->minecraft->rak_net_instance; \
/* Only Run On Server-Side */ \
if (rak_net_instance->vtable->isServer(rak_net_instance)) { \
if (rak_net_instance->isServer()) { \
/* Get Death Message */ \
std::string message = get_death_message((Player *) player, cause); \
\
/* Post Death Message */ \
ServerSideNetworkHandler *server_side_network_handler = (ServerSideNetworkHandler *) player->minecraft->network_handler; \
ServerSideNetworkHandler_displayGameMessage(server_side_network_handler, &message); \
server_side_network_handler->displayGameMessage(&message); \
} \
}
#define Player_actuallyHurt_injections(type) \
@ -105,7 +105,7 @@ static bool Mob_hurt_injection(Mob_hurt_t original, Mob *mob, Entity *source, in
/* Get Variables */ \
RakNetInstance *rak_net_instance = player->minecraft->rak_net_instance; \
/* Only Run On Server-Side */ \
if (rak_net_instance->vtable->isServer(rak_net_instance)) { \
if (rak_net_instance->isServer()) { \
/* Check Health */ \
if (new_health < 1 && old_health >= 1) { \
/* Get Death Message */ \
@ -113,7 +113,7 @@ static bool Mob_hurt_injection(Mob_hurt_t original, Mob *mob, Entity *source, in
\
/* Post Death Message */ \
ServerSideNetworkHandler *server_side_network_handler = (ServerSideNetworkHandler *) player->minecraft->network_handler; \
ServerSideNetworkHandler_displayGameMessage(server_side_network_handler, &message); \
server_side_network_handler->displayGameMessage(&message); \
} \
} \
}
@ -144,3 +144,4 @@ void init_death() {
unsigned char ldr_r0_24_patch[4] = {0x24, 0x00, 0x90, 0xe5}; // "ldr r0, [r0, #0x24]"
patch((void *) 0x8799c, ldr_r0_24_patch);
}

View File

@ -27,3 +27,4 @@ bool _feature_has(const char *name) {
// Return
return ret;
}

View File

@ -52,3 +52,4 @@ void init_fps() {
misc_run_on_tick(print_fps);
}
}

View File

@ -76,3 +76,4 @@ void init_game_mode() {
patch((void *) 0x6dc70, server_patch);
}
}

View File

@ -70,9 +70,9 @@ CUSTOM_VTABLE(create_world_screen, Screen) {
CreateWorldScreen *self = (CreateWorldScreen *) super;
delete self->name;
delete self->seed;
self->game_mode->vtable->destructor_deleting(self->game_mode);
self->back->vtable->destructor_deleting(self->back);
self->create->vtable->destructor_deleting(self->create);
self->game_mode->destructor_deleting();
self->back->destructor_deleting();
self->create->destructor_deleting();
};
// Rendering
static Screen_render_t original_render = vtable->render;
@ -125,7 +125,7 @@ CUSTOM_VTABLE(create_world_screen, Screen) {
// ESC
vtable->handleBackEvent = [](Screen *super, bool do_nothing) {
if (!do_nothing) {
ScreenChooser_setScreen(&super->minecraft->screen_chooser, 5);
super->minecraft->screen_chooser.setScreen(5);
}
return true;
};
@ -138,7 +138,7 @@ CUSTOM_VTABLE(create_world_screen, Screen) {
self->game_mode->text = is_creative ? SURVIVAL_STR : CREATIVE_STR;
} else if (button == self->back) {
// Back
super->vtable->handleBackEvent(super, false);
super->handleBackEvent(false);
} else if (button == self->create) {
// Create
create_world(super->minecraft, self->name->getText(), is_creative, self->seed->getText());
@ -149,7 +149,7 @@ static Screen *create_create_world_screen() {
// Construct
CreateWorldScreen *screen = new CreateWorldScreen;
ALLOC_CHECK(screen);
Screen_constructor(&screen->super.super);
screen->super.super.constructor();
// Set VTable
screen->super.super.vtable = get_create_world_screen_vtable();
@ -162,7 +162,7 @@ static Screen *create_create_world_screen() {
static std::string getUniqueLevelName(LevelStorageSource *source, const std::string &in) {
std::set<std::string> maps;
std::vector<LevelSummary> vls;
source->vtable->getLevelList(source, &vls);
source->getLevelList(&vls);
for (int i = 0; i < int(vls.size()); i++) {
const LevelSummary &ls = vls[i];
maps.insert(ls.folder);
@ -178,20 +178,20 @@ static std::string getUniqueLevelName(LevelStorageSource *source, const std::str
static void create_world(Minecraft *minecraft, std::string name, bool is_creative, std::string seed_str) {
// Get Seed
int seed;
seed_str = Util_stringTrim(&seed_str);
seed_str = Util::stringTrim(&seed_str);
if (!seed_str.empty()) {
int num;
if (sscanf(seed_str.c_str(), "%d", &num) > 0) {
seed = num;
} else {
seed = Util_hashCode(&seed_str);
seed = Util::hashCode(&seed_str);
}
} else {
seed = Common_getEpochTimeS();
seed = Common::getEpochTimeS();
}
// Get Folder Name
name = Util_stringTrim(&name);
name = Util::stringTrim(&name);
std::string folder = "";
for (char c : name) {
if (
@ -221,16 +221,16 @@ static void create_world(Minecraft *minecraft, std::string name, bool is_creativ
settings.seed = seed;
// Create World
minecraft->vtable->selectLevel(minecraft, &folder, &name, &settings);
minecraft->selectLevel(&folder, &name, &settings);
// Multiplayer
Minecraft_hostMultiplayer(minecraft, 19132);
minecraft->hostMultiplayer(19132);
// Open ProgressScreen
ProgressScreen *screen = alloc_ProgressScreen();
ALLOC_CHECK(screen);
screen = ProgressScreen_constructor(screen);
Minecraft_setScreen(minecraft, (Screen *) screen);
screen = screen->constructor();
minecraft->setScreen((Screen *) screen);
}
// Redirect Create World Button
@ -238,7 +238,7 @@ static void create_world(Minecraft *minecraft, std::string name, bool is_creativ
static void prefix##SelectWorldScreen_tick_injection(prefix##SelectWorldScreen_tick_t original, prefix##SelectWorldScreen *screen) { \
if (screen->should_create_world) { \
/* Open Screen */ \
Minecraft_setScreen(screen->minecraft, create_create_world_screen()); \
screen->minecraft->setScreen(create_create_world_screen()); \
/* Finish */ \
screen->should_create_world = false; \
} else { \
@ -254,4 +254,4 @@ void _init_game_mode_ui() {
// Hijack Create World Button
overwrite_virtual_calls(SelectWorldScreen_tick, SelectWorldScreen_tick_injection);
overwrite_virtual_calls(Touch_SelectWorldScreen_tick, Touch_SelectWorldScreen_tick_injection);
}
}

View File

@ -31,3 +31,4 @@ void init_home() {
unsigned char nop_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop"
patch((void *) 0xe0ac, nop_patch);
}

View File

@ -40,3 +40,4 @@ __attribute__((constructor)) static void init() {
init_benchmark();
#endif
}

View File

@ -39,7 +39,7 @@ static int32_t MouseBuildInput_tickBuild_injection(MouseBuildInput_tickBuild_t o
static bool last_player_attack_successful = false;
static bool Player_attack_Entity_hurt_injection(Entity *entity, Entity *attacker, int32_t damage) {
// Call Original Method
last_player_attack_successful = entity->vtable->hurt(entity, attacker, damage);
last_player_attack_successful = entity->hurt(attacker, damage);
return last_player_attack_successful;
}
static ItemInstance *Player_attack_Inventory_getSelected_injection(Inventory *inventory) {
@ -49,7 +49,7 @@ static ItemInstance *Player_attack_Inventory_getSelected_injection(Inventory *in
}
// Call Original Method
return Inventory_getSelected(inventory);
return inventory->getSelected();
}
// Init
@ -63,3 +63,4 @@ void _init_attack() {
overwrite_call((void *) 0x8fc24, (void *) Player_attack_Inventory_getSelected_injection);
}
}

View File

@ -20,7 +20,7 @@ static void _handle_bow(Minecraft *minecraft) {
GameMode *game_mode = minecraft->game_mode;
LocalPlayer *player = minecraft->player;
if (player != nullptr && game_mode != nullptr && player->isUsingItem()) {
game_mode->vtable->releaseUsingItem(game_mode, (Player *) player);
game_mode->releaseUsingItem((Player *) player);
}
}
}
@ -31,3 +31,4 @@ void _init_bow() {
fix_bow = feature_has("Fix Bow & Arrow", server_disabled);
input_run_on_tick(_handle_bow);
}

View File

@ -18,8 +18,8 @@ static void _handle_open_crafting(Minecraft *minecraft) {
if (!creative_is_restricted() || !Minecraft_isCreativeMode(minecraft)) {
WorkbenchScreen *screen = alloc_WorkbenchScreen();
ALLOC_CHECK(screen);
screen = WorkbenchScreen_constructor(screen, 0);
Minecraft_setScreen(minecraft, (Screen *) screen);
screen = screen->constructor(0);
minecraft->setScreen((Screen *) screen);
}
}
}
@ -28,3 +28,4 @@ static void _handle_open_crafting(Minecraft *minecraft) {
void _init_crafting() {
input_run_on_tick(_handle_open_crafting);
}

View File

@ -34,7 +34,7 @@ static void _handle_drop(Minecraft *minecraft) {
Inventory *inventory = player->inventory;
// Get Item
ItemInstance *inventory_item = inventory->vtable->getItem(inventory, selected_slot);
ItemInstance *inventory_item = inventory->getItem(selected_slot);
// Check
if (inventory_item != nullptr && inventory_item->count > 0) {
// Copy
@ -64,7 +64,7 @@ static void _handle_drop(Minecraft *minecraft) {
}
// Drop
player->vtable->drop(player, dropped_item, false);
player->drop(dropped_item, false);
}
}
}
@ -78,3 +78,4 @@ void _init_drop() {
enable_drop = feature_has("Bind \"Q\" Key To Item Dropping", server_disabled);
input_run_on_tick(_handle_drop);
}

View File

@ -57,3 +57,4 @@ void init_input() {
media_set_raw_mouse_motion_enabled(0);
}
}

View File

@ -29,7 +29,7 @@ static void _handle_back(Minecraft *minecraft) {
}
// Send Event
for (int i = 0; i < back_button_presses; i++) {
minecraft->vtable->handleBack(minecraft, 0);
minecraft->handleBack(0);
}
back_button_presses = 0;
}
@ -38,7 +38,7 @@ static void _handle_back(Minecraft *minecraft) {
static bool OptionsScreen_handleBackEvent_injection(OptionsScreen *screen, bool do_nothing) {
if (!do_nothing) {
Minecraft *minecraft = screen->minecraft;
Minecraft_setScreen(minecraft, nullptr);
minecraft->setScreen(nullptr);
}
return true;
}
@ -48,11 +48,11 @@ static bool InBedScreen_handleBackEvent_injection(InBedScreen *screen, bool do_n
if (!do_nothing) {
// Close Screen
Minecraft *minecraft = screen->minecraft;
Minecraft_setScreen(minecraft, nullptr);
minecraft->setScreen(nullptr);
// Stop Sleeping
LocalPlayer *player = minecraft->player;
if (player != nullptr) {
player->vtable->stopSleepInBed(player, 1, 1, 1);
player->stopSleepInBed(1, 1, 1);
}
}
return true;
@ -68,10 +68,10 @@ void input_set_mouse_grab_state(int state) {
static void _handle_mouse_grab(Minecraft *minecraft) {
if (mouse_grab_state == -1) {
// Grab
Minecraft_grabMouse(minecraft);
minecraft->grabMouse();
} else if (mouse_grab_state == 1) {
// Un-Grab
Minecraft_releaseMouse(minecraft);
minecraft->releaseMouse();
}
mouse_grab_state = 0;
}
@ -83,7 +83,7 @@ static bool Gui_tickItemDrop_Minecraft_isCreativeMode_call_injection(Minecraft *
bool is_in_game = minecraft->screen == nullptr || minecraft->screen->vtable == (Screen_vtable *) Touch_IngameBlockSelectionScreen_vtable_base;
if (!enable_misc || (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF && is_in_game)) {
// Call Original Method
return creative_is_restricted() && Minecraft_isCreativeMode(minecraft);
return creative_is_restricted() && minecraft->isCreativeMode();
} else {
// Disable Item Drop Ticking
return 1;
@ -115,3 +115,4 @@ void _init_misc() {
input_run_on_tick(_handle_back);
input_run_on_tick(_handle_mouse_grab);
}

View File

@ -97,3 +97,4 @@ void _init_toggle() {
overwrite_calls(ParticleEngine_render, ParticleEngine_render_injection);
}
}

View File

@ -82,7 +82,7 @@ SETUP_CALLBACK(creative_inventory_setup, FillingContainer);
// Handle Custom Creative Inventory Setup Behavior
static void Inventory_setupDefault_FillingContainer_addItem_call_injection(FillingContainer *filling_container, ItemInstance *item_instance) {
// Call Original Method
FillingContainer_addItem(filling_container, item_instance);
filling_container->addItem(item_instance);
// Run Functions
handle_misc_creative_inventory_setup(filling_container);
@ -183,3 +183,4 @@ void _init_misc_api() {
// Handle Key Presses
overwrite_calls(Gui_handleKeyPressed, Gui_handleKeyPressed_injection);
}

View File

@ -43,7 +43,7 @@ static void Gui_addMessage_injection(Gui_addMessage_t original, Gui *gui, std::s
static int last_progress = -1;
static const char *last_message = nullptr;
static void print_progress(Minecraft *minecraft) {
const char *message = Minecraft_getProgressMessage(minecraft);
const char *message = minecraft->getProgressMessage();
int32_t progress = minecraft->progress;
if (Minecraft_isLevelGenerated(minecraft)) {
message = "Ready";
@ -97,3 +97,4 @@ void _init_misc_logging() {
// Disable stdout Buffering
setvbuf(stdout, nullptr, _IONBF, 0);
}

View File

@ -75,10 +75,10 @@ static void Gui_renderHearts_injection(Gui_renderHearts_t original, Gui *gui) {
heal_amount = heal_amount_drawing = 0;
Inventory *inventory = gui->minecraft->player->inventory;
ItemInstance *held_ii = Inventory_getSelected(inventory);
ItemInstance *held_ii = inventory->getSelected();
if (held_ii) {
Item *held = Item_items[held_ii->id];
if (held->vtable->isFood(held) && held_ii->id) {
if (held->isFood() && held_ii->id) {
int nutrition = ((FoodItem *) held)->nutrition;
int cur_health = gui->minecraft->player->health;
int heal_num = fmin(cur_health + nutrition, 20) - cur_health;
@ -151,7 +151,7 @@ static void Gui_renderChatMessages_injection(Gui_renderChatMessages_t original,
int32_t screen_width = minecraft->screen_width;
float scale = ((float) screen_width) * Gui_InvGuiScale;
// Render Selected Item Text
Gui_renderOnSelectItemNameText(gui, (int32_t) scale, font, y_offset - 0x13);
gui->renderOnSelectItemNameText((int32_t) scale, font, y_offset - 0x13);
}
}
// Reset Selected Item Text Timer On Slot Select
@ -235,7 +235,7 @@ static void LoginPacket_read_injection(LoginPacket_read_t original, LoginPacket
ALLOC_CHECK(new_username);
sanitize_string(&new_username, MAX_USERNAME_LENGTH, 0);
// Set New Username
RakNet_RakString_Assign(rak_string, new_username);
rak_string->Assign(new_username);
// Free
free(new_username);
}
@ -272,7 +272,7 @@ static const char *RAKNET_ERROR_NAMES[] = {
#endif
static RakNet_StartupResult RakNetInstance_host_RakNet_RakPeer_Startup_injection(RakNet_RakPeer *rak_peer, unsigned short maxConnections, unsigned char *socketDescriptors, uint32_t socketDescriptorCount, int32_t threadPriority) {
// Call Original Method
RakNet_StartupResult result = rak_peer->vtable->Startup(rak_peer, maxConnections, socketDescriptors, socketDescriptorCount, threadPriority);
RakNet_StartupResult result = rak_peer->Startup(maxConnections, socketDescriptors, socketDescriptorCount, threadPriority);
// Print Error
if (result != RAKNET_STARTED) {
@ -297,7 +297,7 @@ static RakNetInstance *RakNetInstance_injection(RakNetInstance_constructor_t ori
static void LocalPlayer_die_injection(LocalPlayer_die_t original, LocalPlayer *entity, Entity *cause) {
// Close Screen
Minecraft *minecraft = entity->minecraft;
Minecraft_setScreen(minecraft, nullptr);
minecraft->setScreen(nullptr);
// Call Original Method
original(entity, cause);
@ -307,7 +307,7 @@ static void LocalPlayer_die_injection(LocalPlayer_die_t original, LocalPlayer *e
static int32_t FurnaceScreen_handleAddItem_injection(FurnaceScreen_handleAddItem_t original, FurnaceScreen *furnace_screen, int32_t slot, ItemInstance *item) {
// Get Existing Item
FurnaceTileEntity *tile_entity = furnace_screen->tile_entity;
ItemInstance *existing_item = tile_entity->vtable->getItem(tile_entity, slot);
ItemInstance *existing_item = tile_entity->getItem(slot);
// Check Item
int valid;
@ -349,11 +349,11 @@ static void GameRenderer_render_injection(GameRenderer_render_t original, GameRe
// Fix GL Mode
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Get X And Y
float x = Mouse_getX() * Gui_InvGuiScale;
float y = Mouse_getY() * Gui_InvGuiScale;
float x = Mouse::getX() * Gui_InvGuiScale;
float y = Mouse::getY() * Gui_InvGuiScale;
// Render Cursor
Minecraft *minecraft = game_renderer->minecraft;
Common_renderCursor(x, y, minecraft);
Common::renderCursor(x, y, minecraft);
}
}
#endif
@ -410,7 +410,7 @@ HOOK(bind, int, (int sockfd, const struct sockaddr *addr, socklen_t addrlen)) {
// Change Grass Color
static int32_t get_color(LevelSource *level_source, int32_t x, int32_t z) {
Biome *biome = level_source->vtable->getBiome(level_source, x, z);
Biome *biome = level_source->getBiome(x, z);
if (biome == nullptr) {
return 0;
}
@ -459,7 +459,7 @@ static void RandomLevelSource_buildSurface_injection(RandomLevelSource_buildSurf
LargeCaveFeature *cave_feature = &random_level_source->cave_feature;
// Generate
cave_feature->vtable->apply(cave_feature, (ChunkSource *) random_level_source, level, chunk_x, chunk_y, chunk_data, 0);
cave_feature->apply((ChunkSource *) random_level_source, level, chunk_x, chunk_y, chunk_data, 0);
}
// No Block Tinting
@ -471,15 +471,15 @@ static int32_t Tile_getColor_injection(__attribute__((unused)) T original, __att
// Disable Hostile AI In Creative Mode
static Entity *PathfinderMob_findAttackTarget_injection(PathfinderMob *mob) {
// Call Original Method
Entity *target = mob->vtable->findAttackTarget(mob);
Entity *target = mob->findAttackTarget();
// Only modify the AI of monsters
if (mob->vtable->getCreatureBaseType(mob) != 1) {
if (mob->getCreatureBaseType() != 1) {
return target;
}
// Check If Creative Mode
if (target != nullptr && target->vtable->isPlayer(target)) {
if (target != nullptr && target->isPlayer()) {
Player *player = (Player *) target;
Inventory *inventory = player->inventory;
bool is_creative = inventory->is_creative;
@ -499,7 +499,7 @@ static int32_t Tile_getRenderShape_injection(Tile *tile) {
return -1;
} else {
// Call Original Method
return tile->vtable->getRenderShape(tile);
return tile->getRenderShape();
}
}
static ChestTileEntity *ChestTileEntity_injection(ChestTileEntity_constructor_t original, ChestTileEntity *tile_entity) {
@ -518,7 +518,7 @@ static void ModelPart_render_injection(ModelPart *model_part, float scale) {
is_rendering_chest = true;
// Call Original Method
ModelPart_render(model_part, scale);
model_part->render(scale);
// Stop
is_rendering_chest = false;
@ -545,7 +545,7 @@ static ContainerMenu *ContainerMenu_injection(ContainerMenu_constructor_t origin
ChestTileEntity *tile_entity = (ChestTileEntity *) (((unsigned char *) container) - offsetof(ChestTileEntity, container));
bool is_client = tile_entity->is_client;
if (!is_client) {
container->vtable->startOpen(container);
container->startOpen();
}
// Return
@ -557,7 +557,7 @@ static ContainerMenu *ContainerMenu_destructor_injection(ContainerMenu_destructo
ChestTileEntity *tile_entity = (ChestTileEntity *) (((unsigned char *) container) - offsetof(ChestTileEntity, container));
bool is_client = tile_entity->is_client;
if (!is_client) {
container->vtable->stopOpen(container);
container->stopOpen();
}
// Call Original Method
@ -666,7 +666,7 @@ static void PauseScreen_init_injection(PauseScreen_init_t original, PauseScreen
Minecraft *minecraft = screen->minecraft;
RakNetInstance *rak_net_instance = minecraft->rak_net_instance;
if (rak_net_instance != nullptr) {
if (rak_net_instance->vtable->isServer(rak_net_instance)) {
if (rak_net_instance->isServer()) {
// Add Button
std::vector<Button *> *rendered_buttons = &screen->rendered_buttons;
std::vector<Button *> *selectable_buttons = &screen->selectable_buttons;
@ -675,7 +675,7 @@ static void PauseScreen_init_injection(PauseScreen_init_t original, PauseScreen
selectable_buttons->push_back(button);
// Update Button Text
PauseScreen_updateServerVisibilityText(screen);
screen->updateServerVisibilityText();
}
}
}
@ -687,18 +687,18 @@ void PaneCraftingScreen_craftSelectedItem_PaneCraftingScreen_recheckRecipes_inje
for (size_t i = 0; i < item->ingredients.size(); i++) {
ItemInstance requested_item_instance = item->ingredients[i].requested_item;
Item *requested_item = Item_items[requested_item_instance.id];
ItemInstance *craftingRemainingItem = requested_item->vtable->getCraftingRemainingItem(requested_item, &requested_item_instance);
ItemInstance *craftingRemainingItem = requested_item->getCraftingRemainingItem(&requested_item_instance);
if (craftingRemainingItem != nullptr) {
// Add or drop remainder
LocalPlayer *player = self->minecraft->player;
if (!player->inventory->vtable->add(player->inventory, craftingRemainingItem)) {
if (!player->inventory->add(craftingRemainingItem)) {
// Drop
player->vtable->drop(player, craftingRemainingItem, false);
player->drop(craftingRemainingItem, false);
}
}
}
// Call Original Method
PaneCraftingScreen_recheckRecipes(self);
self->recheckRecipes();
}
ItemInstance *Item_getCraftingRemainingItem_injection(__attribute__((unused)) Item_getCraftingRemainingItem_t original, Item *self, ItemInstance *item_instance) {
@ -727,7 +727,7 @@ static void sort_chunks(Chunk **chunks_begin, Chunk **chunks_end, DistanceChunkS
}
for (int i = 0; i < chunks_size; i++) {
Chunk *chunk = chunks_begin[i];
float distance = Chunk_distanceToSqr(chunk, (Entity *) sorter.mob);
float distance = chunk->distanceToSqr((Entity *) sorter.mob);
if ((1024.0 <= distance) && chunk->y < 0x40) {
distance *= 10.0;
}
@ -997,3 +997,4 @@ void init_misc() {
_init_misc_logging();
_init_misc_api();
}

View File

@ -122,7 +122,7 @@ static void RakNetInstance_pingForHosts_injection(RakNetInstance_pingForHosts_t
// Add External Servers
iterate_servers([rak_peer](const char *address, int port) {
rak_peer->vtable->Ping(rak_peer, address, port, 1, 0);
rak_peer->Ping(address, port, 1, 0);
});
}
@ -133,3 +133,4 @@ void init_multiplayer() {
overwrite_virtual_calls(RakNetInstance_pingForHosts, RakNetInstance_pingForHosts_injection);
}
}

View File

@ -255,4 +255,4 @@ Screen *_create_options_info_screen() {
// Return
return screen;
}
}

View File

@ -89,17 +89,17 @@ static bool TileRenderer_tesselateBlockInWorld_injection(TileRenderer_tesselateB
// Hook Last Options::addOptionToSaveOutput Call
static void Options_save_Options_addOptionToSaveOutput_injection(Options *options, std::vector<std::string> *data, std::string option, int32_t value) {
// Call Original Method
Options_addOptionToSaveOutput(options, data, option, value);
options->addOptionToSaveOutput(data, option, value);
// Save Fancy Graphics
Options_addOptionToSaveOutput(options, data, "gfx_fancygraphics", options->fancy_graphics);
options->addOptionToSaveOutput(data, "gfx_fancygraphics", options->fancy_graphics);
// Save 3D Anaglyph
Options_addOptionToSaveOutput(options, data, "gfx_anaglyph", options->anaglyph_3d);
options->addOptionToSaveOutput(data, "gfx_anaglyph", options->anaglyph_3d);
// Save File
OptionsFile *options_file = &options->options_file;
OptionsFile_save(options_file, data);
options_file->save(data);
}
// MCPI's OptionsFile::getOptionStrings is broken, this is the version in v0.7.0
@ -247,3 +247,4 @@ void init_options() {
// UI
_init_options_ui();
}

View File

@ -12,10 +12,10 @@
// The calling function doesn't exist in MCPE v0.6.1, so its name is unknown.
static OptionButton *OptionsPane_unknown_toggle_creating_function_OptionButton_injection(OptionButton *option_button, Options_Option *option) {
// Call Original Method
OptionButton *ret = OptionButton_constructor(option_button, option);
OptionButton *ret = option_button->constructor(option);
// Setup Image
OptionButton_updateImage(option_button, stored_options);
option_button->updateImage(stored_options);
// Return
return ret;
@ -87,7 +87,7 @@ static void OptionButton_toggle_Options_save_injection(Options *self) {
self->game_difficulty = 0;
}
// Call Original Method
Options_save(self);
self->save();
}
// Add "Reborn" Info Button
@ -194,4 +194,4 @@ void _init_options_ui() {
// Cleanup
overwrite_virtual_calls(OptionsScreen_removed, OptionsScreen_removed_injection);
}
}
}

View File

@ -104,3 +104,4 @@ HOOK(fopen64, FILE *, (const char *filename, const char *mode)) {
// Return File
return file;
}

View File

@ -20,3 +20,4 @@ dirent *readdir(DIR *dirp) {
new_dirent.d_type = original->d_type;
return &new_dirent;
}

View File

@ -104,3 +104,4 @@ void screenshot_take(char *home) {
free(screenshots);
free(pixels);
}

View File

@ -84,21 +84,21 @@ static void start_world(Minecraft *minecraft) {
settings.seed = seed;
// Select Level
minecraft->vtable->selectLevel(minecraft, &world_name, &world_name, &settings);
minecraft->selectLevel(&world_name, &world_name, &settings);
// Don't Open Port When Using --only-generate
if (!only_generate) {
// Open Port
int port = get_server_properties().get_int("port", DEFAULT_PORT);
INFO("Listening On: %i", port);
Minecraft_hostMultiplayer(minecraft, port);
minecraft->hostMultiplayer(port);
}
// Open ProgressScreen
ProgressScreen *screen = alloc_ProgressScreen();
ALLOC_CHECK(screen);
screen = ProgressScreen_constructor(screen);
Minecraft_setScreen(minecraft, (Screen *) screen);
screen = screen->constructor();
minecraft->setScreen((Screen *) screen);
}
// Check If Running In Whitelist Mode
@ -156,7 +156,7 @@ static RakNet_RakNetGUID get_rak_net_guid(Player *player) {
}
static RakNet_SystemAddress get_system_address(RakNet_RakPeer *rak_peer, RakNet_RakNetGUID guid) {
// Get SystemAddress
return rak_peer->vtable->GetSystemAddressFromGuid(rak_peer, guid);
return rak_peer->GetSystemAddressFromGuid(guid);
}
static RakNet_RakPeer *get_rak_peer(Minecraft *minecraft) {
return minecraft->rak_net_instance->peer;
@ -164,7 +164,7 @@ static RakNet_RakPeer *get_rak_peer(Minecraft *minecraft) {
static char *get_rak_net_guid_ip(RakNet_RakPeer *rak_peer, RakNet_RakNetGUID guid) {
RakNet_SystemAddress address = get_system_address(rak_peer, guid);
// Get IP
return RakNet_SystemAddress_ToString(&address, false, '|');
return address.ToString(false, '|');
}
// Get IP From Player
@ -199,7 +199,7 @@ static void ban_callback(Minecraft *minecraft, std::string username, Player *pla
// Kill Player
static void kill_callback(__attribute__((unused)) Minecraft *minecraft, __attribute__((unused)) std::string username, Player *player) {
player->vtable->hurt(player, nullptr, INT32_MAX);
player->hurt(nullptr, INT32_MAX);
INFO("Killed: %s", username.c_str());
}
@ -215,9 +215,9 @@ static void handle_server_stop(Minecraft *minecraft) {
// Save And Exit
Level *level = get_level(minecraft);
if (level != nullptr) {
Level_saveLevelData(level);
level->saveLevelData();
}
Minecraft_leaveGame(minecraft, false);
minecraft->leaveGame(false);
// Stop Game
SDL_Event event;
event.type = SDL_QUIT;
@ -325,7 +325,7 @@ static void handle_commands(Minecraft *minecraft) {
char *safe_message = to_cp437(message.c_str());
std::string cpp_string = safe_message;
// Post Message To Chat
ServerSideNetworkHandler_displayGameMessage(server_side_network_handler, &cpp_string);
server_side_network_handler->displayGameMessage(&cpp_string);
// Free
free(safe_message);
} else if (data == list_command) {
@ -373,7 +373,7 @@ static void Minecraft_update_injection(Minecraft *minecraft) {
}
// Handle --only-generate
if (only_generate && Minecraft_isLevelGenerated(minecraft)) {
if (only_generate && minecraft->isLevelGenerated()) {
// Request Exit
compat_request_exit();
// Disable Special Behavior After Requesting Exit
@ -438,7 +438,7 @@ static bool RakNet_RakPeer_IsBanned_injection(__attribute__((unused)) RakNet_Rak
// Log IPs
static Player *ServerSideNetworkHandler_onReady_ClientGeneration_ServerSideNetworkHandler_popPendingPlayer_injection(ServerSideNetworkHandler *server_side_network_handler, RakNet_RakNetGUID *guid) {
// Call Original Method
Player *player = ServerSideNetworkHandler_popPendingPlayer(server_side_network_handler, guid);
Player *player = server_side_network_handler->popPendingPlayer(guid);
// Check If Player Is Null
if (player != nullptr) {
@ -594,3 +594,4 @@ void init_server() {
set_and_print_env("MCPI_RENDER_DISTANCE", "Tiny");
set_and_print_env("MCPI_USERNAME", get_motd().c_str());
}

View File

@ -35,3 +35,4 @@ bool ServerProperties::get_bool(std::string const& name, std::string const& def)
}
return is_true(def);
}

View File

@ -35,8 +35,8 @@ static void LocalPlayer_openTextEdit_injection(LocalPlayer *local_player, TileEn
Minecraft *minecraft = local_player->minecraft;
TextEditScreen *screen = alloc_TextEditScreen();
ALLOC_CHECK(screen);
screen = TextEditScreen_constructor(screen, (SignTileEntity *) sign);
Minecraft_setScreen(minecraft, (Screen *) screen);
screen = screen->constructor((SignTileEntity *) sign);
minecraft->setScreen((Screen *) screen);
}
}
@ -55,3 +55,4 @@ void init_sign() {
// Handle Backspace
overwrite_calls(Common_sdl_key_to_minecraft_key, sdl_key_to_minecraft_key_injection);
}

View File

@ -142,3 +142,4 @@ void _init_skin_loader() {
// Log
DEBUG("Skin Server: %s", get_skin_server().c_str());
}

View File

@ -74,7 +74,7 @@ static int32_t Textures_loadAndBindTexture_injection(Textures *textures, __attri
}
// Call Original Method
return Textures_loadAndBindTexture(textures, &new_texture);
return textures->loadAndBindTexture(&new_texture);
}
// Init
@ -95,3 +95,4 @@ void init_skin() {
_init_skin_loader();
}
}

View File

@ -377,3 +377,4 @@ void _sound_resolve_all() {
}
}
}

View File

@ -125,3 +125,4 @@ void init_sound() {
overwrite_calls(SoundEngine_init, SoundEngine_init_injection);
}
}

View File

@ -20,3 +20,4 @@ void run_tests() {
}
}
}

View File

@ -5,7 +5,7 @@
TextInputBox *TextInputBox::create(const std::string &placeholder, const std::string &text) {
// Construct
TextInputBox *self = new TextInputBox;
GuiComponent_constructor(&self->super);
self->super.constructor();
// Setup
self->m_xPos = 0;
@ -111,7 +111,7 @@ void TextInputBox::keyPressed(int key) {
void TextInputBox::tick() {
if (!m_lastFlashed) {
m_lastFlashed = Common_getTimeMs();
m_lastFlashed = Common::getTimeMs();
}
if (m_bFocused) {
@ -131,7 +131,7 @@ void TextInputBox::setFocused(bool b) {
m_bFocused = b;
if (b) {
m_lastFlashed = Common_getTimeMs();
m_lastFlashed = Common::getTimeMs();
m_bCursorOn = true;
m_insertHead = int(m_text.size());
recalculateScroll();
@ -176,8 +176,8 @@ static std::string get_rendered_text(Font *font, int width, int scroll_pos, std:
static char CURSOR_CHAR = '_';
void TextInputBox::render() {
GuiComponent_fill(&super, m_xPos, m_yPos, m_xPos + m_width, m_yPos + m_height, 0xFFAAAAAA);
GuiComponent_fill(&super, m_xPos + 1, m_yPos + 1, m_xPos + m_width - 1, m_yPos + m_height - 1, 0xFF000000);
super.fill(m_xPos, m_yPos, m_xPos + m_width, m_yPos + m_height, 0xFFAAAAAA);
super.fill(m_xPos + 1, m_yPos + 1, m_xPos + m_width - 1, m_yPos + m_height - 1, 0xFF000000);
int text_color;
int scroll_pos;
@ -194,17 +194,17 @@ void TextInputBox::render() {
rendered_text = get_rendered_text(m_pFont, m_width, scroll_pos, rendered_text);
int textYPos = (m_height - 8) / 2;
GuiComponent_drawString(&super, m_pFont, &rendered_text, m_xPos + PADDING, m_yPos + textYPos, text_color);
super.drawString(m_pFont, &rendered_text, m_xPos + PADDING, m_yPos + textYPos, text_color);
if (m_bCursorOn) {
int cursor_pos = m_insertHead - m_scrollPos;
if (cursor_pos >= 0 && cursor_pos <= int(rendered_text.length())) {
std::string substr = rendered_text.substr(0, cursor_pos);
int xPos = PADDING + Font_width(m_pFont, &substr);
int xPos = PADDING + m_pFont->width(&substr);
std::string str;
str += CURSOR_CHAR;
GuiComponent_drawString(&super, m_pFont, &str, m_xPos + xPos, m_yPos + textYPos + 2, 0xffffff);
super.drawString(m_pFont, &str, m_xPos + xPos, m_yPos + textYPos + 2, 0xffffff);
}
}
}
@ -297,3 +297,4 @@ bool TextInputBox::isFocused() {
void TextInputBox::setMaxLength(int max_length) {
m_maxLength = max_length;
}

View File

@ -54,3 +54,4 @@ void TextInputScreen::setup(Screen_vtable *vtable) {
delete self->m_textInputs;
};
}

View File

@ -21,3 +21,4 @@ void init_textures() {
// Disable Texture Loading
overwrite_virtual_calls(AppPlatform_linux_loadTexture, AppPlatform_linux_loadTexture_injection);
}

View File

@ -82,7 +82,7 @@ static DynamicTexture *create_lava_texture() {
// Construct
LavaTexture *texture = new LavaTexture;
ALLOC_CHECK(texture);
DynamicTexture_constructor(&texture->super, Tile_lava->texture);
texture->super.constructor(Tile_lava->texture);
// Set VTable
texture->super.vtable = get_lava_texture_vtable();
// Setup
@ -146,7 +146,7 @@ static DynamicTexture *create_lava_side_texture() {
// Construct
LavaSideTexture *texture = new LavaSideTexture;
ALLOC_CHECK(texture);
DynamicTexture_constructor(&texture->super, Tile_lava->texture + 1);
texture->super.constructor(Tile_lava->texture + 1);
// Set VTable
texture->super.vtable = get_lava_side_texture_vtable();
// Setup
@ -189,7 +189,7 @@ CUSTOM_VTABLE(fire_texture, DynamicTexture) {
uint32_t x;
uint8_t b[4];
} a;
a.x = Random_genrand_int32(&self->m_random);
a.x = self->m_random.genrand_int32();
self->m_data2[i + j * 16] = 0.2f + (((a.b[3] / 256.0f) * 0.1f) + ((((a.b[0] / 256.0f) * (a.b[1] / 256.0f)) * (a.b[2] / 256.0f)) * 4.0f));
}
}
@ -214,11 +214,11 @@ static DynamicTexture *create_fire_texture(int a2) {
// Construct
FireTexture *texture = new FireTexture;
ALLOC_CHECK(texture);
DynamicTexture_constructor(&texture->super, Tile_fire->texture + (16 * a2));
texture->super.constructor(Tile_fire->texture + (16 * a2));
// Set VTable
texture->super.vtable = get_fire_texture_vtable();
// Setup Random
int seed = Common_getTimeMs();
int seed = Common::getTimeMs();
texture->m_random.seed = seed;
texture->m_random.param_1 = 0x271;
texture->m_random.param_2 = false;
@ -238,17 +238,17 @@ static bool animated_fire = false;
static void Textures_addDynamicTexture_injection(Textures *textures, DynamicTexture *dynamic_texture) {
// Call Original Method
if (animated_water) {
Textures_addDynamicTexture(textures, dynamic_texture);
textures->addDynamicTexture(dynamic_texture);
}
// Add Lava
if (animated_lava) {
Textures_addDynamicTexture(textures, create_lava_texture());
Textures_addDynamicTexture(textures, create_lava_side_texture());
textures->addDynamicTexture(create_lava_texture());
textures->addDynamicTexture(create_lava_side_texture());
}
if (animated_fire) {
Textures_addDynamicTexture(textures, create_fire_texture(0));
Textures_addDynamicTexture(textures, create_fire_texture(1));
textures->addDynamicTexture(create_fire_texture(0));
textures->addDynamicTexture(create_fire_texture(1));
}
}
@ -259,3 +259,4 @@ void _init_textures_lava(bool animated_water_param, bool animated_lava_param, bo
animated_fire = animated_fire_param;
overwrite_call((void *) 0x170b4, (void *) Textures_addDynamicTexture_injection);
}

View File

@ -20,7 +20,7 @@ static void Minecraft_tick_injection(Minecraft *minecraft) {
// Tick Dynamic Textures
Textures *textures = minecraft->textures;
if (textures != nullptr) {
Textures_tick(textures, true);
textures->tick(true);
}
}
@ -236,3 +236,4 @@ void init_textures() {
// Load Textures
overwrite_virtual_calls(AppPlatform_linux_loadTexture, AppPlatform_linux_loadTexture_injection);
}

View File

@ -17,7 +17,7 @@ static void StartMenuScreen_render_Screen_renderBackground_injection(Screen *scr
Minecraft *minecraft = screen->minecraft;
Textures *textures = minecraft->textures;
std::string texture = "gui/titleBG.png";
Textures_loadAndBindTexture(textures, &texture);
textures->loadAndBindTexture(&texture);
screen->blit(0, 0, 0, 0, screen->width, screen->height, 0x100, 0x100);
}
@ -99,9 +99,9 @@ static void StartMenuScreen_render_Screen_render_injection(Screen *screen, int x
glTranslatef(splash_x, splash_y, 0.0f);
glRotatef(-20.0f, 0.0f, 0.0f, 1.0f);
// Scale
int textWidth = Font_width(screen->font, &current_splash);
int textWidth = screen->font->width(&current_splash);
float timeMS = float(Common_getTimeMs() % 1000) / 1000.0f;
float scale = max_scale - Mth_abs(0.1f * Mth_sin(2.0f * float(M_PI) * timeMS));
float scale = max_scale - Mth::abs(0.1f * Mth::sin(2.0f * float(M_PI) * timeMS));
float real_text_width = textWidth * max_scale;
if (real_text_width > max_width) {
scale *= max_width / real_text_width;
@ -166,3 +166,4 @@ void init_title_screen() {
srand(time(nullptr));
}
}

View File

@ -19,8 +19,8 @@ static unsigned char *operator_new_IngameBlockSelectionScreen_injection(__attrib
// Improved Button Hover Behavior
static int32_t Button_hovered_injection(__attribute__((unused)) Button *button, __attribute__((unused)) Minecraft *minecraft, __attribute__((unused)) int32_t click_x, __attribute__((unused)) int32_t click_y) {
// Get Mouse Position
int32_t x = Mouse_getX() * Gui_InvGuiScale;
int32_t y = Mouse_getY() * Gui_InvGuiScale;
int32_t x = Mouse::getX() * Gui_InvGuiScale;
int32_t y = Mouse::getY() * Gui_InvGuiScale;
// Get Button Position
int32_t button_x1 = button->x;
@ -38,25 +38,24 @@ static void LargeImageButton_render_GuiComponent_drawCenteredString_injection(Gu
}
// Call Original Method
GuiComponent_drawCenteredString(component, font, text, x, y, color);
component->drawCenteredString(font, text, x, y, color);
}
// Create Button
int touch_gui = 0;
Button *touch_create_button(int id, std::string text) {
Button *button = nullptr;
if (touch_gui) {
button = (Button *) new Touch_TButton;
} else {
button = new Button;
}
template <typename T>
static Button *create_button(T *(*allocator)(), int id, std::string text) {
T *button = allocator();
ALLOC_CHECK(button);
button->constructor(id, &text);
return (Button *) button;
}
Button *touch_create_button(int id, std::string text) {
if (touch_gui) {
Touch_TButton_constructor((Touch_TButton *) button, id, &text);
return create_button(alloc_Touch_TButton, id, text);
} else {
Button_constructor(button, id, &text);
return create_button(alloc_Button, id, text);
}
return button;
}
// Init
@ -107,3 +106,4 @@ void init_touch() {
unsigned char outline_patch[4] = {(unsigned char) (block_outlines ? !touch_gui : touch_gui), 0x00, 0x50, 0xe3}; // "cmp r0, #0x1" or "cmp r0, #0x0"
patch((void *) 0x4a210, outline_patch);
}

View File

@ -35,3 +35,4 @@ void init_version() {
// Log
INFO("Starting Minecraft: Pi Edition (%s)", version_get());
}