Add Smooth Lighting
This commit is contained in:
parent
cdbb6bac21
commit
1bdb5287e5
10
CREDITS.md
Normal file
10
CREDITS.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Credits
|
||||||
|
| Project | Reason |
|
||||||
|
| --- | --- |
|
||||||
|
| [mhsjlw/mcpilauncher](https://github.com/mhsjlw/mcpilauncher/blob/master/trampoline/trampoline.c) | Information On Getting Minecraft: Pi Eiditon To Run On Desktop Linux |
|
||||||
|
| [Phirel's Survival Patch](https://www.minecraftforum.net/forums/minecraft-editions/minecraft-pi-edition/1960005-survival-mode-patch) | Information On Survival Mode Support |
|
||||||
|
| [zhuowei/MinecraftPEModWiki](https://github.com/zhuowei/MinecraftPEModWiki/wiki/How-some-unlocks-are-made) | Information On Smooth Lighting Support |
|
||||||
|
| [Ghidra](https://ghidra-sre.org) | Used For Decompiling Minecraft: Pi Edition |
|
||||||
|
| [RetDec](https://retdec.com) | Used For Decompiling Minecraft: Pi Edition |
|
||||||
|
| [minecraft-linux/mcpelauncher-core](https://github.com/minecraft-linux/mcpelauncher-core/blob/6b5e17b5685a612143297ae4595bdd12327284f3/src/patch_utils.cpp#L42) | Original Function Overwrite Code |
|
||||||
|
| [Hooking C Functions at Runtime - Thomas Finch](http://thomasfinch.me/blog/2015/07/24/Hooking-C-Functions-At-Runtime.html) | Original Patching Code |
|
16
debian/client/common/usr/bin/minecraft-pi
vendored
16
debian/client/common/usr/bin/minecraft-pi
vendored
@ -4,7 +4,21 @@ set -e
|
|||||||
|
|
||||||
# Ensure Features Are Selected
|
# Ensure Features Are Selected
|
||||||
if [ -z "${MCPI_SUBSHELL}" ]; then
|
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' TRUE 'Animated Water' TRUE 'Remove Invalid Item Background')"
|
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' \
|
||||||
|
TRUE 'Remove Invalid Item Background' \
|
||||||
|
TRUE 'Smooth Lighting')"
|
||||||
MCPI_USERNAME="$(zenity --class 'Minecraft - Pi edition' --entry --text 'Minecraft Username:' --entry-text 'StevePi')"
|
MCPI_USERNAME="$(zenity --class 'Minecraft - Pi edition' --entry --text 'Minecraft Username:' --entry-text 'StevePi')"
|
||||||
fi
|
fi
|
||||||
export MCPI_FEATURES
|
export MCPI_FEATURES
|
||||||
|
@ -455,6 +455,12 @@ HOOK(SDL_GetWMInfo, int, (SDL_SysWMinfo *info)) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force Smooth Shading In Smooth Lighting Mode
|
||||||
|
HOOK(glShadeModel, void, (GLenum mode)) {
|
||||||
|
ensure_glShadeModel();
|
||||||
|
(*real_glShadeModel)(extra_get_smooth_lighting() ? GL_SMOOTH : mode);
|
||||||
|
}
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
// Use VirGL
|
// Use VirGL
|
||||||
|
@ -7,10 +7,12 @@
|
|||||||
#include "server/server.h"
|
#include "server/server.h"
|
||||||
|
|
||||||
static int mob_spawning = 0;
|
static int mob_spawning = 0;
|
||||||
|
// Override Mob Spawning
|
||||||
static uint32_t LevelData_getSpawnMobs_injection(__attribute__((unused)) unsigned char *level_data) {
|
static uint32_t LevelData_getSpawnMobs_injection(__attribute__((unused)) unsigned char *level_data) {
|
||||||
return mob_spawning;
|
return mob_spawning;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store Right-Click Status
|
||||||
static int is_right_click = 0;
|
static int is_right_click = 0;
|
||||||
void extra_set_is_right_click(int val) {
|
void extra_set_is_right_click(int val) {
|
||||||
is_right_click = val;
|
is_right_click = val;
|
||||||
@ -27,6 +29,7 @@ static Player_isUsingItem_t Player_isUsingItem = (Player_isUsingItem_t) 0x8f15c;
|
|||||||
// Enable Bow & Arrow Fix
|
// Enable Bow & Arrow Fix
|
||||||
static int fix_bow = 0;
|
static int fix_bow = 0;
|
||||||
|
|
||||||
|
// Handle Input Fixes
|
||||||
static void Minecraft_tickInput_injection(unsigned char *minecraft) {
|
static void Minecraft_tickInput_injection(unsigned char *minecraft) {
|
||||||
// Call Original Method
|
// Call Original Method
|
||||||
(*Minecraft_tickInput)(minecraft);
|
(*Minecraft_tickInput)(minecraft);
|
||||||
@ -52,6 +55,7 @@ static Gui_tickItemDrop_t Gui_tickItemDrop = (Gui_tickItemDrop_t) 0x27778;
|
|||||||
|
|
||||||
#include <SDL/SDL_events.h>
|
#include <SDL/SDL_events.h>
|
||||||
|
|
||||||
|
// Block UI Interaction When Mouse Is Locked
|
||||||
static void Gui_tickItemDrop_injection(unsigned char *this) {
|
static void Gui_tickItemDrop_injection(unsigned char *this) {
|
||||||
if (SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE) {
|
if (SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE) {
|
||||||
// Call Original Method
|
// Call Original Method
|
||||||
@ -62,6 +66,7 @@ static void Gui_tickItemDrop_injection(unsigned char *this) {
|
|||||||
typedef void (*Gui_handleClick_t)(unsigned char *this, int32_t param_2, int32_t param_3, int32_t param_4);
|
typedef void (*Gui_handleClick_t)(unsigned char *this, int32_t param_2, int32_t param_3, int32_t param_4);
|
||||||
static Gui_handleClick_t Gui_handleClick = (Gui_handleClick_t) 0x2599c;
|
static Gui_handleClick_t Gui_handleClick = (Gui_handleClick_t) 0x2599c;
|
||||||
|
|
||||||
|
// Block UI Interaction When Mouse Is Locked
|
||||||
static void Gui_handleClick_injection(unsigned char *this, int32_t param_2, int32_t param_3, int32_t param_4) {
|
static void Gui_handleClick_injection(unsigned char *this, int32_t param_2, int32_t param_3, int32_t param_4) {
|
||||||
if (SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE) {
|
if (SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE) {
|
||||||
// Call Original Method
|
// Call Original Method
|
||||||
@ -98,6 +103,7 @@ static void set_is_survival(int new_is_survival) {
|
|||||||
typedef void (*Minecraft_setIsCreativeMode_t)(unsigned char *, int32_t);
|
typedef void (*Minecraft_setIsCreativeMode_t)(unsigned char *, int32_t);
|
||||||
static Minecraft_setIsCreativeMode_t Minecraft_setIsCreativeMode = (Minecraft_setIsCreativeMode_t) 0x16ec4;
|
static Minecraft_setIsCreativeMode_t Minecraft_setIsCreativeMode = (Minecraft_setIsCreativeMode_t) 0x16ec4;
|
||||||
|
|
||||||
|
// Handle Gamemode Switching
|
||||||
static void Minecraft_setIsCreativeMode_injection(unsigned char *this, int32_t new_game_mode) {
|
static void Minecraft_setIsCreativeMode_injection(unsigned char *this, int32_t new_game_mode) {
|
||||||
set_is_survival(!new_game_mode);
|
set_is_survival(!new_game_mode);
|
||||||
|
|
||||||
@ -105,6 +111,7 @@ static void Minecraft_setIsCreativeMode_injection(unsigned char *this, int32_t n
|
|||||||
(*Minecraft_setIsCreativeMode)(this, new_game_mode);
|
(*Minecraft_setIsCreativeMode)(this, new_game_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get Custom Username
|
||||||
static char *get_username() {
|
static char *get_username() {
|
||||||
char *username = getenv("MCPI_USERNAME");
|
char *username = getenv("MCPI_USERNAME");
|
||||||
if (username == NULL) {
|
if (username == NULL) {
|
||||||
@ -118,6 +125,7 @@ static Minecraft_init_t Minecraft_init = (Minecraft_init_t) 0x1700c;
|
|||||||
|
|
||||||
static int fancy_graphics;
|
static int fancy_graphics;
|
||||||
static int peaceful_mode;
|
static int peaceful_mode;
|
||||||
|
// Configure Options
|
||||||
static void Minecraft_init_injection(unsigned char *this) {
|
static void Minecraft_init_injection(unsigned char *this) {
|
||||||
// Call Original Method
|
// Call Original Method
|
||||||
(*Minecraft_init)(this);
|
(*Minecraft_init)(this);
|
||||||
@ -157,6 +165,7 @@ int extra_has_feature(const char *name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get Graphics Mode
|
||||||
int extra_get_mode() {
|
int extra_get_mode() {
|
||||||
char *mode = getenv("MCPI_MODE");
|
char *mode = getenv("MCPI_MODE");
|
||||||
if (mode == NULL) {
|
if (mode == NULL) {
|
||||||
@ -172,10 +181,17 @@ int extra_get_mode() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Enable Touch GUI
|
||||||
static int32_t Minecraft_isTouchscreen(__attribute__((unused)) unsigned char *minecraft) {
|
static int32_t Minecraft_isTouchscreen(__attribute__((unused)) unsigned char *minecraft) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store Smooth Lighting
|
||||||
|
static int smooth_lighting;
|
||||||
|
int extra_get_smooth_lighting() {
|
||||||
|
return smooth_lighting;
|
||||||
|
}
|
||||||
|
|
||||||
__attribute__((constructor)) static void init() {
|
__attribute__((constructor)) static void init() {
|
||||||
is_server = extra_get_mode() == 2;
|
is_server = extra_get_mode() == 2;
|
||||||
if (is_server) {
|
if (is_server) {
|
||||||
@ -286,4 +302,11 @@ __attribute__((constructor)) static void init() {
|
|||||||
unsigned char invalid_item_background_patch[4] = {0x00, 0xf0, 0x20, 0xe3};
|
unsigned char invalid_item_background_patch[4] = {0x00, 0xf0, 0x20, 0xe3};
|
||||||
patch((void *) 0x63c98, invalid_item_background_patch);
|
patch((void *) 0x63c98, invalid_item_background_patch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
smooth_lighting = extra_has_feature("Smooth Lighting");
|
||||||
|
if (smooth_lighting) {
|
||||||
|
// Enable Smooth Lighting
|
||||||
|
unsigned char smooth_lighting_patch[4] = {0x01, 0x00, 0x53, 0xe3};
|
||||||
|
patch((void *) 0x59ea4, smooth_lighting_patch);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
// Read Asset File
|
||||||
static cxx11_string AppPlatform_readAssetFile(__attribute__((unused)) unsigned char *app_platform, std::string const& path) {
|
static cxx11_string AppPlatform_readAssetFile(__attribute__((unused)) unsigned char *app_platform, std::string const& path) {
|
||||||
std::string full_path("./data/");
|
std::string full_path("./data/");
|
||||||
full_path.append(path);
|
full_path.append(path);
|
||||||
@ -27,6 +28,7 @@ extern "C" {
|
|||||||
typedef void (*Minecraft_setScreen_t)(unsigned char *, unsigned char *);
|
typedef void (*Minecraft_setScreen_t)(unsigned char *, unsigned char *);
|
||||||
static Minecraft_setScreen_t Minecraft_setScreen = (Minecraft_setScreen_t) 0x15d6c;
|
static Minecraft_setScreen_t Minecraft_setScreen = (Minecraft_setScreen_t) 0x15d6c;
|
||||||
|
|
||||||
|
// Open Sign Screen
|
||||||
static void LocalPlayer_openTextEdit(unsigned char *local_player, unsigned char *sign) {
|
static void LocalPlayer_openTextEdit(unsigned char *local_player, unsigned char *sign) {
|
||||||
if (*(int *)(sign + 0x18) == 4) {
|
if (*(int *)(sign + 0x18) == 4) {
|
||||||
unsigned char *minecraft = *(unsigned char **) (local_player + 0xc90);
|
unsigned char *minecraft = *(unsigned char **) (local_player + 0xc90);
|
||||||
@ -42,6 +44,7 @@ extern "C" {
|
|||||||
return (key >= 32 && key <= 126) || key == BACKSPACE_KEY;
|
return (key >= 32 && key <= 126) || key == BACKSPACE_KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store Text Input
|
||||||
std::vector<char> input;
|
std::vector<char> input;
|
||||||
void extra_key_press(char key) {
|
void extra_key_press(char key) {
|
||||||
if (is_valid_key(key)) {
|
if (is_valid_key(key)) {
|
||||||
@ -58,8 +61,9 @@ extern "C" {
|
|||||||
typedef void (*Screen_keyboardNewChar_t)(unsigned char *screen, char key);
|
typedef void (*Screen_keyboardNewChar_t)(unsigned char *screen, char key);
|
||||||
typedef void (*Screen_keyPressed_t)(unsigned char *screen, int32_t key);
|
typedef void (*Screen_keyPressed_t)(unsigned char *screen, int32_t key);
|
||||||
|
|
||||||
|
// Handle Text Input
|
||||||
static void Screen_updateEvents_injection(unsigned char *screen) {
|
static void Screen_updateEvents_injection(unsigned char *screen) {
|
||||||
// Call Original
|
// Call Original Method
|
||||||
(*Screen_updateEvents)(screen);
|
(*Screen_updateEvents)(screen);
|
||||||
|
|
||||||
if (*(char *)(screen + 4) == '\0') {
|
if (*(char *)(screen + 4) == '\0') {
|
||||||
|
@ -14,6 +14,8 @@ void extra_clear_input();
|
|||||||
|
|
||||||
void extra_set_is_right_click(int val);
|
void extra_set_is_right_click(int val);
|
||||||
|
|
||||||
|
int extra_get_smooth_lighting();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user