2.4.9
minecraft-pi-reborn/pipeline/head This commit looks good Details
Build / build (push) Successful in 2h38m15s Details

This commit is contained in:
TheBrokenRail 2023-09-17 15:51:35 -04:00
parent 9e517f5e60
commit da9edee160
9 changed files with 104 additions and 2 deletions

View File

@ -1 +1 @@
2.4.8
2.4.9

View File

@ -1,5 +1,11 @@
# Changelog
**2.4.9**
* Allow Overriding GUI Scale With ``MCPI_GUI_SCALE`` Environmental Variable
* Add ``Disable Block Tinting`` Feature Flag (Disabled By Default)
* Add ``Disable Hostile AI In Creative Mode`` Feature Flag (Enabled By Default)
* Allow Accessing Configuration At Runtime (Useful For Mods That Need To Support Multiple Versions)
**2.4.8**
* Fix Bug In ``extract_from_bl_instruction``
* Update LIEF And GLFW

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 KiB

After

Width:  |  Height:  |  Size: 162 KiB

View File

@ -46,3 +46,5 @@ FALSE Disable Speed Bridging
FALSE Disable Creative Mode Mining Delay
FALSE Add Biome Colors To Grass
TRUE Generate Caves
FALSE Disable Block Tinting
TRUE Disable Hostile AI In Creative Mode

View File

@ -45,6 +45,11 @@ int is_progress_difference_significant(int32_t new_val, int32_t old_val);
int lock_file(const char *file);
void unlock_file(const char *file, int fd);
// Access Configuration At Runtime
const char *reborn_get_version();
int reborn_is_headless();
int reborn_is_server();
#ifdef __cplusplus
}
#endif

View File

@ -2,6 +2,7 @@
#include <sys/file.h>
#include <libreborn/util.h>
#include <libreborn/config.h>
// Safe Version Of pipe()
void safe_pipe2(int pipefd[2], int flags) {
@ -43,3 +44,22 @@ void unlock_file(const char *file, int fd) {
}
close(fd);
}
// Access Configuration At Runtime
const char *reborn_get_version() {
return MCPI_VERSION;
}
int reborn_is_headless() {
#ifdef MCPI_HEADLESS_MODE
return 1;
#else
return 0;
#endif
}
int reborn_is_server() {
#ifdef MCPI_SERVER_MODE
return 1;
#else
return 0;
#endif
}

View File

@ -390,6 +390,31 @@ static void RandomLevelSource_buildSurface_injection(unsigned char *random_level
(*LargeCaveFeature_apply)(cave_feature, random_level_source, level, chunk_x, chunk_y, chunk_data, 0);
}
// No Block Tinting
static int32_t Tile_getColor_injection() {
return 0xffffff;
}
// Disable Hostile AI In Creative Mode
static unsigned char *PathfinderMob_findAttackTarget_injection(unsigned char *mob) {
// Call Original Method
unsigned char *mob_vtable = *(unsigned char **) mob;
PathfinderMob_findAttackTarget_t PathfinderMob_findAttackTarget = *(PathfinderMob_findAttackTarget_t *) (mob_vtable + PathfinderMob_findAttackTarget_vtable_offset);
unsigned char *target = (*PathfinderMob_findAttackTarget)(mob);
// Check If Creative Mode
if (target != NULL) {
unsigned char *inventory = *(unsigned char **) (target + Player_inventory_property_offset);
bool is_creative = *(bool *) (inventory + FillingContainer_is_creative_property_offset);
if (is_creative) {
target = NULL;
}
}
// Return
return target;
}
// Init
static void nop() {
}
@ -506,6 +531,32 @@ void init_misc() {
overwrite_calls((void *) RandomLevelSource_buildSurface, (void *) RandomLevelSource_buildSurface_injection);
}
// Disable Block Tinting
if (feature_has("Disable Block Tinting", server_disabled)) {
patch_address((void *) GrassTile_getColor_vtable_addr, (void *) Tile_getColor_injection);
patch_address((void *) TallGrass_getColor_vtable_addr, (void *) Tile_getColor_injection);
patch_address((void *) StemTile_getColor_vtable_addr, (void *) Tile_getColor_injection);
patch_address((void *) LeafTile_getColor_vtable_addr, (void *) Tile_getColor_injection);
overwrite((void *) LiquidTile_getColor, (void *) Tile_getColor_injection);
}
// Custom GUI Scale
const char *gui_scale_str = getenv("MCPI_GUI_SCALE");
if (gui_scale_str != NULL) {
unsigned char nop_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop"
patch((void *) 0x173e8, nop_patch);
patch((void *) 0x173f0, nop_patch);
float gui_scale = strtof(gui_scale_str, NULL);
uint32_t gui_scale_raw;
memcpy(&gui_scale_raw, &gui_scale, sizeof (gui_scale_raw));
patch_address((void *) 0x17520, (void *) gui_scale_raw);
}
// Disable Hostile AI In Creative Mode
if (feature_has("Disable Hostile AI In Creative Mode", server_enabled)) {
overwrite_call((void *) 0x83b8c, (void *) PathfinderMob_findAttackTarget_injection);
}
// Init C++ And Logging
_init_misc_cpp();
_init_misc_logging();

View File

@ -9,7 +9,7 @@ char *version_get() {
static char *version = NULL;
// Load
if (version == NULL) {
safe_asprintf(&version, "%s / Reborn v" MCPI_VERSION, *minecraft_pi_version);
safe_asprintf(&version, "%s / Reborn v%s", *minecraft_pi_version, reborn_get_version());
}
// Return
return version;

View File

@ -144,6 +144,18 @@ static void *GrassTile_getColor_vtable_addr = (void *) 0x111660;
static Tile_getColor_t TallGrass_getColor = (Tile_getColor_t) 0xc25fc;
static void *TallGrass_getColor_vtable_addr = (void *) 0x1121f0;
// StemTile
static void *StemTile_getColor_vtable_addr = (void *) 0x111088;
// LeafTile
static void *LeafTile_getColor_vtable_addr = (void *) 0x112980;
// LiquidTile
static Tile_getColor_t LiquidTile_getColor = (Tile_getColor_t) 0xc8774;
// TileRenderer
typedef void (*TileRenderer_tesselateBlockInWorld_t)(unsigned char *tile_renderer, unsigned char *tile, int32_t x, int32_t y, int32_t z);
@ -432,6 +444,11 @@ static uint32_t Mob_die_vtable_offset = 0x130;
static uint32_t Mob_health_property_offset = 0xec; // int32_t
// PathfinderMob
typedef unsigned char *(*PathfinderMob_findAttackTarget_t)(unsigned char *mob);
static uint32_t PathfinderMob_findAttackTarget_vtable_offset = 0x204;
// Player
typedef int (*Player_isUsingItem_t)(unsigned char *player);
@ -690,6 +707,7 @@ static FillingContainer_compressLinkedSlotList_t FillingContainer_compressLinked
static uint32_t FillingContainer_linked_slots_property_offset = 0xc; // int32_t[]
static uint32_t FillingContainer_linked_slots_length_property_offset = 0x14; // int32_t
static uint32_t FillingContainer_is_creative_property_offset = 0x24; // bool
// RakNet::RakString