Fix Creative Mode In Dedicated Server

This commit is contained in:
TheBrokenRail 2020-11-02 15:20:49 -05:00
parent b762fdadef
commit 55c789dab2
3 changed files with 9 additions and 16 deletions

View File

@ -189,19 +189,16 @@ __attribute__((constructor)) static void init() {
Minecraft_setIsCreativeMode_original = overwrite((void *) Minecraft_setIsCreativeMode, Minecraft_setIsCreativeMode_injection);
// Get Default Game Mode
int default_game_mode;
if (is_server) {
default_game_mode = server_get_default_game_mode();
} else {
default_game_mode = !extra_has_feature("Survival Mode");
}
if (!is_server) {
int default_game_mode = !extra_has_feature("Survival Mode");
// Set Default Game Mode
unsigned char default_game_mode_patch[4] = {default_game_mode ? 0x01 : 0x00, 0x30, 0xa0, 0xe3};
patch((void *) 0x3d9b8, default_game_mode_patch);
patch((void *) 0x38a78, default_game_mode_patch);
}
// Disable Item Dropping When Cursor Is Hidden
// Disable Item Dropping Using The Cursor When Cursor Is Hidden
Gui_tickItemDrop_original = overwrite((void *) Gui_tickItemDrop, Gui_tickItemDrop_injection);
// Disable Opening Inventory Using The Cursor When Cursor Is Hidden
Gui_handleClick_original = overwrite((void *) Gui_handleClick, Gui_handleClick_injection);

View File

@ -115,7 +115,7 @@ static void Minecraft_update_injection(unsigned char *minecraft) {
INFO("%s", "Starting Minecraft: Pi Edition Dedicated Server");
LevelSettings settings;
settings.game_type = 0; // Patched By MCPI-Docker
settings.game_type = get_server_properties().get_int("game-mode", DEFAULT_GAME_MODE);;
std::string seed_str = get_server_properties().get_string("seed", DEFAULT_SEED);
int32_t seed = seed_str.length() > 0 ? std::stoi(seed_str) : time(NULL);
settings.seed = seed;
@ -232,9 +232,6 @@ static void exit_handler(__attribute__((unused)) int data) {
const char *server_get_motd() {
return get_server_properties().get_string("motd", DEFAULT_MOTD).c_str();
}
int server_get_default_game_mode() {
return get_server_properties().get_int("game-mode", DEFAULT_GAME_MODE);
}
int server_get_mob_spawning() {
return get_server_properties().get_bool("spawn-mobs", DEFAULT_MOB_SPAWNING);
}

View File

@ -9,7 +9,6 @@ extern "C" {
void server_init();
const char *server_get_motd();
int server_get_default_game_mode();
int server_get_mob_spawning();
#ifdef __cplusplus