Add Animated Water
This commit is contained in:
parent
a39476228e
commit
99aac006f4
30
MODDING.md
30
MODDING.md
@ -37,6 +37,36 @@ __attribute__((constructor)) static void init() {
|
||||
}
|
||||
```
|
||||
|
||||
### ``void overwrite_call(void *start, void *original)``
|
||||
This allows you to overwrite a specific call of a function rather than the function itself. This allows you to call the original function. However, this does not effect VTables.
|
||||
|
||||
#### Parameters
|
||||
- **start:** The address of the function call to overwrite.
|
||||
- **target:** The function call you are replacing it with.
|
||||
|
||||
#### Return Value
|
||||
None
|
||||
|
||||
#### Warning
|
||||
This method can only be safely used 512 times in total.
|
||||
|
||||
#### Example
|
||||
```c
|
||||
typedef int (*func_t)(int a, int b);
|
||||
static func_t func = (func_t) 0xabcde;
|
||||
static void *func_original = NULL;
|
||||
|
||||
static int func_injection(int a, int b) {
|
||||
(*func)(a, b);
|
||||
|
||||
return a + 4;
|
||||
}
|
||||
|
||||
__attribute__((constructor)) static void init() {
|
||||
overwrite_call((void *) 0xabcd, func_injection);
|
||||
}
|
||||
```
|
||||
|
||||
### ``void overwrite_calls(void *start, void *original)``
|
||||
This allows you to overwrite all calls of a function rather than the function itself. This allows you to call the original function. However, this does not effect VTables.
|
||||
|
||||
|
2
debian/client/common/usr/bin/minecraft-pi
vendored
2
debian/client/common/usr/bin/minecraft-pi
vendored
@ -4,7 +4,7 @@ set -e
|
||||
|
||||
# Ensure Features Are Selected
|
||||
if [ -z "${MCPI_SUBSHELL}" ]; then
|
||||
MCPI_FEATURES="$(zenity --class 'Minecraft - Pi edition' --list --checklist --column 'Enabled' --column 'Feature' TRUE 'Touch GUI' FALSE 'Survival Mode' TRUE 'Fix Bow & Arrow' TRUE 'Fix Attacking' TRUE 'Mob Spawning' TRUE 'Fancy Graphics' TRUE 'Disable Autojump By Default' TRUE 'Fix Sign Placement' TRUE 'Show Block Outlines' FALSE 'Expand Creative Inventory' FALSE 'Peaceful Mode')"
|
||||
MCPI_FEATURES="$(zenity --class 'Minecraft - Pi edition' --list --checklist --column 'Enabled' --column 'Feature' TRUE 'Touch GUI' FALSE 'Survival Mode' TRUE 'Fix Bow & Arrow' TRUE 'Fix Attacking' TRUE 'Mob Spawning' TRUE 'Fancy Graphics' TRUE 'Disable Autojump By Default' TRUE 'Fix Sign Placement' TRUE 'Show Block Outlines' FALSE 'Expand Creative Inventory' FALSE 'Peaceful Mode' TRUE 'Animated Water')"
|
||||
MCPI_USERNAME="$(zenity --class 'Minecraft - Pi edition' --entry --text 'Minecraft Username:' --entry-text 'StevePi')"
|
||||
fi
|
||||
export MCPI_FEATURES
|
||||
|
@ -29,6 +29,9 @@ extern "C" {
|
||||
\
|
||||
__attribute__((__used__)) return_type name args
|
||||
|
||||
void _overwrite_call(const char *file, int line, void *start, void *target);
|
||||
#define overwrite_call(start, target) _overwrite_call(__FILE__, __LINE__, start, target);
|
||||
|
||||
void _overwrite_calls(const char *file, int line, void *start, void *target);
|
||||
#define overwrite_calls(start, target) _overwrite_calls(__FILE__, __LINE__, start, target);
|
||||
|
||||
|
@ -101,8 +101,7 @@ static unsigned char *code_block = NULL;
|
||||
#define CODE_SIZE 8
|
||||
static int code_block_remaining = CODE_BLOCK_SIZE;
|
||||
|
||||
// Overwrite Function Calls
|
||||
void _overwrite_calls(const char *file, int line, void *start, void *target) {
|
||||
static void update_code_block(void *target) {
|
||||
// BL Instructions Can Only Access A Limited Portion of Memory, So This Allocates Memory Closer To The Original Instruction, That When Run, Will Jump Into The Actual Target
|
||||
if (code_block == NULL) {
|
||||
code_block = mmap((void *) 0x200000, CODE_BLOCK_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
@ -115,6 +114,19 @@ void _overwrite_calls(const char *file, int line, void *start, void *target) {
|
||||
ERR("%s", "Maximum Amount Of overwrite_calls() Uses Reached");
|
||||
}
|
||||
_overwrite(NULL, -1, code_block, target);
|
||||
}
|
||||
|
||||
// Overwrite Specific BL Instruction
|
||||
void _overwrite_call(const char *file, int line, void *start, void *target) {
|
||||
update_code_block(target);
|
||||
|
||||
uint32_t new_instruction = generate_bl_instruction(start, code_block);
|
||||
_patch(file, line, start, (unsigned char *) &new_instruction);
|
||||
}
|
||||
|
||||
// Overwrite Function Calls
|
||||
void _overwrite_calls(const char *file, int line, void *start, void *target) {
|
||||
update_code_block(target);
|
||||
|
||||
struct overwrite_data data;
|
||||
data.file = file;
|
||||
|
@ -93,7 +93,6 @@ extern "C" {
|
||||
}
|
||||
|
||||
// Items
|
||||
static unsigned char **item_sign = (unsigned char **) 0x17bba4;
|
||||
static unsigned char **item_flintAndSteel = (unsigned char **) 0x17ba70;
|
||||
static unsigned char **item_snowball = (unsigned char **) 0x17bbb0;
|
||||
static unsigned char **item_shears = (unsigned char **) 0x17bbf0;
|
||||
@ -113,8 +112,6 @@ extern "C" {
|
||||
// Call Original
|
||||
int32_t ret = (*FillingContainer_addItem)(filling_container, item_instance);
|
||||
|
||||
// Add After Sign
|
||||
if (*(int32_t *) (item_instance + 0x4) == *(int32_t *) (*item_sign + 0x4)) {
|
||||
// Add Items
|
||||
inventory_add_item(filling_container, *item_flintAndSteel, false);
|
||||
inventory_add_item(filling_container, *item_snowball, false);
|
||||
@ -134,11 +131,27 @@ extern "C" {
|
||||
inventory_add_item(filling_container, *tile_topSnow, true);
|
||||
inventory_add_item(filling_container, *tile_ice, true);
|
||||
inventory_add_item(filling_container, *tile_invisible_bedrock, true);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
typedef void (*Minecraft_tick_t)(unsigned char *minecraft, int32_t param_1, int32_t param_2);
|
||||
static Minecraft_tick_t Minecraft_tick = (Minecraft_tick_t) 0x16934;
|
||||
|
||||
typedef void (*Textures_tick_t)(unsigned char *textures, bool param_1);
|
||||
static Textures_tick_t Textures_tick = (Textures_tick_t) 0x531c4;
|
||||
|
||||
static void Minecraft_tick_injection(unsigned char *minecraft, int32_t param_1, int32_t param_2) {
|
||||
// Call Original Method
|
||||
(*Minecraft_tick)(minecraft, param_1, param_2);
|
||||
|
||||
// Tick Dynamic Textures
|
||||
unsigned char *textures = *(unsigned char **) (minecraft + 0x164);
|
||||
if (textures != NULL) {
|
||||
(*Textures_tick)(textures, true);
|
||||
}
|
||||
}
|
||||
|
||||
__attribute((constructor)) static void init() {
|
||||
// Implement AppPlatform::AppPlatform_AppPlatform_readAssetFile So Translations Work
|
||||
overwrite((void *) 0x12b10, (void *) AppPlatform_readAssetFile);
|
||||
@ -149,10 +162,14 @@ extern "C" {
|
||||
patch_address((void *) 0x10531c, (void *) Screen_updateEvents_injection);
|
||||
}
|
||||
|
||||
int is_server = extra_get_mode() == 2;
|
||||
if (!is_server && extra_has_feature("Expand Creative Inventory")) {
|
||||
// Add Extra Items To Creative Inventory
|
||||
overwrite_calls((void *) FillingContainer_addItem, (void *) FillingContainer_addItem_injection);
|
||||
if (extra_has_feature("Expand Creative Inventory")) {
|
||||
// Add Extra Items To Creative Inventory (Only Replace Specific Function Call)
|
||||
overwrite_call((void *) 0x8e0fc, (void *) FillingContainer_addItem_injection);
|
||||
}
|
||||
|
||||
if (extra_has_feature("Animated Watter")) {
|
||||
// Tick Dynamic Textures (Animated Water)
|
||||
overwrite_calls((void *) Minecraft_tick, (void *) Minecraft_tick_injection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user