Fix Particles In Front-Facing View

This commit is contained in:
TheBrokenRail 2022-09-21 23:06:58 -04:00
parent 16ce586e9c
commit 02c73176a5
4 changed files with 46 additions and 14 deletions

View File

@ -32,7 +32,7 @@ TRUE Disable V-Sync
TRUE Fix Options Screen
TRUE Force Touch GUI Inventory
TRUE Fix Pause Menu
TRUE Improved Title Screen Background
TRUE Add Title Screen Background
TRUE Force Touch GUI Button Behavior
TRUE Improved Button Hover Behavior
TRUE Implement Create World Dialog

View File

@ -42,32 +42,58 @@ static void _handle_toggle_options(unsigned char *minecraft) {
}
// Font-Facing View
static void invert_rotation(unsigned char *entity) {
if (entity != NULL) {
*(float *) (entity + Entity_yaw_property_offset) = 180.f + (*(float *) (entity + Entity_yaw_property_offset));
*(float *) (entity + Entity_old_yaw_property_offset) = 180.f + (*(float *) (entity + Entity_old_yaw_property_offset));
*(float *) (entity + Entity_pitch_property_offset) = -(*(float *) (entity + Entity_pitch_property_offset));
*(float *) (entity + Entity_old_pitch_property_offset) = -(*(float *) (entity + Entity_old_pitch_property_offset));
}
}
static void revert_rotation(unsigned char *entity) {
if (entity != NULL) {
*(float *) (entity + Entity_yaw_property_offset) = -180.f + (*(float *) (entity + Entity_yaw_property_offset));
*(float *) (entity + Entity_old_yaw_property_offset) = -180.f + (*(float *) (entity + Entity_old_yaw_property_offset));
*(float *) (entity + Entity_pitch_property_offset) = -(*(float *) (entity + Entity_pitch_property_offset));
*(float *) (entity + Entity_old_pitch_property_offset) = -(*(float *) (entity + Entity_old_pitch_property_offset));
}
}
static int is_front_facing = 0;
static unsigned char *stored_player = NULL;
static void GameRenderer_setupCamera_injection(unsigned char *game_renderer, float param_1, int param_2) {
// Get Objects
unsigned char *minecraft = *(unsigned char **) (game_renderer + GameRenderer_minecraft_property_offset);
unsigned char *player = *(unsigned char **) (minecraft + Minecraft_player_property_offset);
stored_player = *(unsigned char **) (minecraft + Minecraft_player_property_offset);
// Check If In Third-Person
unsigned char *options = minecraft + Minecraft_options_property_offset;
int is_font_facing = (*(options + Options_third_person_property_offset) == 2);
is_front_facing = (*(options + Options_third_person_property_offset) == 2);
// Invert Rotation
if (is_font_facing && player != NULL) {
*(float *) (player + Entity_yaw_property_offset) = 180.f + (*(float *) (player + Entity_yaw_property_offset));
*(float *) (player + Entity_old_yaw_property_offset) = 180.f + (*(float *) (player + Entity_old_yaw_property_offset));
*(float *) (player + Entity_pitch_property_offset) = -(*(float *) (player + Entity_pitch_property_offset));
*(float *) (player + Entity_old_pitch_property_offset) = -(*(float *) (player + Entity_old_pitch_property_offset));
if (is_front_facing) {
invert_rotation(stored_player);
}
// Call Original Method
(*GameRenderer_setupCamera)(game_renderer, param_1, param_2);
// Revert
if (is_font_facing && player != NULL) {
*(float *) (player + Entity_yaw_property_offset) = -180.f + (*(float *) (player + Entity_yaw_property_offset));
*(float *) (player + Entity_old_yaw_property_offset) = -180.f + (*(float *) (player + Entity_old_yaw_property_offset));
*(float *) (player + Entity_pitch_property_offset) = -(*(float *) (player + Entity_pitch_property_offset));
*(float *) (player + Entity_old_pitch_property_offset) = -(*(float *) (player + Entity_old_pitch_property_offset));
if (is_front_facing) {
revert_rotation(stored_player);
}
}
static void ParticleEngine_render_injection(unsigned char *particle_engine, unsigned char *entity, float param_2) {
// Invert Rotation
if (is_front_facing && stored_player == entity) {
invert_rotation(stored_player);
}
// Call Original Method
(*ParticleEngine_render)(particle_engine, entity, param_2);
// Revert
if (is_front_facing && stored_player == entity) {
revert_rotation(stored_player);
}
}
@ -79,5 +105,6 @@ void _init_toggle() {
// Font-Facing View
if (enable_toggles) {
overwrite_calls((void *) GameRenderer_setupCamera, (void *) GameRenderer_setupCamera_injection);
overwrite_calls((void *) ParticleEngine_render, (void *) ParticleEngine_render_injection);
}
}

View File

@ -45,7 +45,7 @@ static void StartMenuScreen_buttonClicked_injection(unsigned char *screen, unsig
// Init
void init_title_screen() {
// Improved Title Screen Background
if (feature_has("Improved Title Screen Background", server_disabled)) {
if (feature_has("Add Title Screen Background", server_disabled)) {
// Switch Background
overwrite_call((void *) 0x39528, (void *) StartMenuScreen_render_Screen_renderBackground_injection);
overwrite_call((void *) 0x3dee0, (void *) StartMenuScreen_render_Screen_renderBackground_injection);

View File

@ -226,6 +226,11 @@ static GameRenderer_setupCamera_t GameRenderer_setupCamera = (GameRenderer_setup
static uint32_t GameRenderer_minecraft_property_offset = 0x4; // Minecraft *
// ParticleEngine
typedef void (*ParticleEngine_render_t)(unsigned char *particle_engine, unsigned char *entity, float param_2);
static ParticleEngine_render_t ParticleEngine_render = (ParticleEngine_render_t) 0x43060;
// Mouse
typedef int (*Mouse_get_t)();