Add Cave Generation

This commit is contained in:
TheBrokenRail 2023-02-25 00:26:45 -05:00
parent 7b4729b8ec
commit 06af8c821f
4 changed files with 49 additions and 1 deletions

View File

@ -45,3 +45,4 @@ TRUE Improved Classic Title Screen
FALSE Disable Speed Bridging
FALSE Disable Creative Mode Mining Delay
FALSE Add Biome Colors To Grass
TRUE Generate Caves

View File

@ -373,6 +373,23 @@ static int32_t TallGrass_getColor_injection(unsigned char *tile, unsigned char *
}
}
// Generate Caves
static void RandomLevelSource_buildSurface_injection(unsigned char *random_level_source, int32_t chunk_x, int32_t chunk_y, unsigned char *chunk_data, unsigned char **biomes) {
// Call Original Method
(*RandomLevelSource_buildSurface)(random_level_source, chunk_x, chunk_y, chunk_data, biomes);
// Get Level
unsigned char *level = *(unsigned char **) (random_level_source + RandomLevelSource_level_property_offset);
// Get Cave Feature
unsigned char *cave_feature = random_level_source + RandomLevelSource_cave_feature_property_offset;
unsigned char *cave_feature_vtable = *(unsigned char **) cave_feature;
// Generate
LargeFeature_apply_t LargeCaveFeature_apply = *(LargeFeature_apply_t *) (cave_feature_vtable + LargeFeature_apply_vtable_offset);
(*LargeCaveFeature_apply)(cave_feature, random_level_source, level, chunk_x, chunk_y, chunk_data, 0);
}
// Init
static void nop() {
}
@ -484,6 +501,11 @@ void init_misc() {
patch_address((void *) TallGrass_getColor_vtable_addr, (void *) TallGrass_getColor_injection);
}
// Generate Caves
if (feature_has("Generate Caves", server_auto)) {
overwrite_calls((void *) RandomLevelSource_buildSurface, (void *) RandomLevelSource_buildSurface_injection);
}
// Init C++ And Logging
_init_misc_cpp();
_init_misc_logging();

View File

@ -60,7 +60,8 @@ static ServerProperties &get_server_properties() {
#define DEFAULT_WORLD_NAME "world"
#define DEFAULT_MAX_PLAYERS "4"
#define DEFAULT_WHITELIST "false"
#define DEFAULT_DEATH_MESSAGES "false"
#define DEFAULT_DEATH_MESSAGES "true"
#define DEFAULT_GENERATE_CAVES "true"
// Get World Name
static std::string get_world_name() {
@ -487,6 +488,9 @@ static const char *get_features() {
if (get_server_properties().get_bool("death-messages", DEFAULT_DEATH_MESSAGES)) {
features += "Implement Death Messages|";
}
if (get_server_properties().get_bool("generate-caves", DEFAULT_GENERATE_CAVES)) {
features += "Generate Caves|";
}
}
return features.c_str();
}
@ -536,6 +540,8 @@ static void server_init() {
properties_file_output << "whitelist=" DEFAULT_WHITELIST "\n";
properties_file_output << "# Enable Death Messages\n";
properties_file_output << "death-messages=" DEFAULT_DEATH_MESSAGES "\n";
properties_file_output << "# Generate Caves\n";
properties_file_output << "generate-caves=" DEFAULT_GENERATE_CAVES "\n";
properties_file_output.close();
// Re-Open File
properties_file = std::ifstream(file);

View File

@ -74,6 +74,8 @@ static unsigned char *Options_Option_ANAGLYPH = (unsigned char *) 0x136c08; // O
static bool *Minecraft_useAmbientOcclusion = (bool *) 0x136b90;
static bool *HeavyTile_instaFall = (bool *) 0x180cc0;
// Structures
struct AABB {
@ -883,6 +885,23 @@ static WorkbenchScreen_t WorkbenchScreen = (WorkbenchScreen_t) 0x301cc;
static uint32_t Biome_color_property_offset = 0x2c; // int32_t
static uint32_t Biome_leaf_color_property_offset = 0x34; // int32_t
// LargeFeature
typedef void (*LargeFeature_apply_t)(unsigned char *large_feature, unsigned char *chunk_source, unsigned char *level, int32_t chunk_x, int32_t chunk_y, unsigned char *chunk_data, int32_t unused);
static uint32_t LargeFeature_apply_vtable_offset = 0x8;
// RandomLevelSource
typedef void (*RandomLevelSource_postProcess_t)(unsigned char *random_level_source, unsigned char *chunk_source, int32_t chunk_x, int32_t chunk_y);
static RandomLevelSource_postProcess_t RandomLevelSource_postProcess = (RandomLevelSource_postProcess_t) 0xb2238;
static void *RandomLevelSource_postProcess_vtable_addr = (void *) 0x1105ac;
typedef void (*RandomLevelSource_buildSurface_t)(unsigned char *random_level_source, int32_t chunk_x, int32_t chunk_y, unsigned char *chunk_data, unsigned char **biomes);
static RandomLevelSource_buildSurface_t RandomLevelSource_buildSurface = (RandomLevelSource_buildSurface_t) 0xb32ec;
static uint32_t RandomLevelSource_cave_feature_property_offset = 0x8; // LargeCaveFeature
static uint32_t RandomLevelSource_level_property_offset = 0x72c8; // Level *
// Method That Require C++ Types
#ifdef __cplusplus