Update
All checks were successful
minecraft-pi-docker/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-11-22 14:14:47 -05:00
parent 2f5692afc7
commit 2a01a429ef
4 changed files with 14 additions and 8 deletions

View File

@ -218,6 +218,8 @@ typedef void (*Entity_load_t)(unsigned char *entity, unsigned char *tag);
typedef void (*Entity_moveTo_t)(unsigned char *entity, float param_1, float param_2, float param_3, float param_4, float param_5);
static Entity_moveTo_t Entity_moveTo = (Entity_moveTo_t) 0x7a834;
typedef void (*Entity_die_t)(unsigned char *entity, unsigned char *cause);
// ServerPlayer
static void *ServerPlayer_moveTo_vtable_addr = (void *) 0x109e54;

View File

@ -168,7 +168,7 @@ static void ServerPlayer_moveTo_injection(unsigned char *player, float param_1,
(*Entity_moveTo)(player, param_1, param_2, param_3, param_4, param_5);
// Check If Player Is Spawned
unsigned char *minecraft = *(unsigned char **) (player + 0xc8c);
unsigned char *minecraft = server_internal_get_minecraft(player);
unsigned char *level = server_internal_get_level(minecraft);
std::vector<unsigned char *> players = server_internal_get_players(level);
bool spawned = false;
@ -182,7 +182,7 @@ static void ServerPlayer_moveTo_injection(unsigned char *player, float param_1,
// Load Data
if (!spawned) {
load_player_callback(server_internal_get_player_username(player), player);
load_player_callback(server_internal_get_server_player_username(player), player);
}
}
@ -192,7 +192,7 @@ void playerdata_save(unsigned char *level) {
for (std::size_t i = 0; i < players.size(); i++) {
// Iterate Players
unsigned char *player = players[i];
std::string username = server_internal_get_player_username(player);
std::string username = server_internal_get_server_player_username(player);
save_player_callback(username, player);
}
}
@ -201,7 +201,7 @@ static void ServerSideNetworkHandler_onDisconnect_injection(unsigned char *serve
// Save Player Data
unsigned char *player = (*ServerSideNetworkHandler_getPlayer)(server_side_network_handler, guid);
if (player != NULL) {
std::string username = server_internal_get_player_username(player);
std::string username = server_internal_get_server_player_username(player);
save_player_callback(username, player);
}

View File

@ -147,13 +147,17 @@ std::vector<unsigned char *> server_internal_get_players(unsigned char *level) {
return *(std::vector<unsigned char *> *) (level + 0x60);
}
// Get Player's Username
std::string server_internal_get_player_username(unsigned char *player) {
std::string server_internal_get_server_player_username(unsigned char *player) {
return *(char **) (player + 0xbf4);
}
// Get Level From Minecraft
unsigned char *server_internal_get_level(unsigned char *minecraft) {
return *(unsigned char **) (minecraft + 0x188);
}
// Get minecraft from ServerPlayer
unsigned char *server_internal_get_minecraft(unsigned char *player) {
return *(unsigned char **) (player + 0xc8c);
}
// Find Players With Username And Run Callback
static void find_players(unsigned char *minecraft, std::string target_username, player_callback_t callback, bool all_players) {
@ -163,7 +167,7 @@ static void find_players(unsigned char *minecraft, std::string target_username,
for (std::size_t i = 0; i < players.size(); i++) {
// Iterate Players
unsigned char *player = players[i];
std::string username = server_internal_get_player_username(player);
std::string username = server_internal_get_server_player_username(player);
if (all_players || username == target_username) {
// Run Callback
(*callback)(minecraft, username, player);
@ -218,7 +222,6 @@ static void ban_callback(unsigned char *minecraft, std::string username, unsigne
}
// Kill Player
typedef void (*Entity_die_t)(unsigned char *entity, unsigned char *cause);
static void kill_callback(__attribute__((unused)) unsigned char *minecraft, __attribute__((unused)) std::string username, unsigned char *player) {
unsigned char *player_vtable = *(unsigned char **) player;
Entity_die_t Entity_die = *(Entity_die_t *) (player_vtable + 0x130);

View File

@ -8,6 +8,7 @@
std::string server_internal_get_world_name();
unsigned char *server_internal_get_level(unsigned char *minecraft);
std::vector<unsigned char *> server_internal_get_players(unsigned char *level);
std::string server_internal_get_player_username(unsigned char *player);
std::string server_internal_get_server_player_username(unsigned char *player);
unsigned char *server_internal_get_minecraft(unsigned char *player);
#endif