Allow Changing Render Distance
This commit is contained in:
parent
04668f223e
commit
530e31820b
6
debian/client/common/usr/bin/minecraft-pi
vendored
6
debian/client/common/usr/bin/minecraft-pi
vendored
@ -22,12 +22,16 @@ export DOCKER_COMPOSE_YML="/usr/share/minecraft-pi/client/docker-compose.yml"
|
|||||||
|
|
||||||
# Ensure Features Are Selected
|
# Ensure Features Are Selected
|
||||||
if [ -z "${MCPI_FEATURES+x}" ]; then
|
if [ -z "${MCPI_FEATURES+x}" ]; then
|
||||||
MCPI_FEATURES="$(eval "zenity --class \"${ZENITY_CLASS}\" --list --checklist --width=600 --height=600 --column 'Enabled' --column 'Feature' ${AVAILABLE_FEATURES}")"
|
MCPI_FEATURES="$(eval "zenity --class \"${ZENITY_CLASS}\" --list --checklist --width 400 --height 400 --column 'Enabled' --column 'Feature' ${AVAILABLE_FEATURES}")"
|
||||||
|
fi
|
||||||
|
if [ -z "${MCPI_RENDER_DISTANCE+x}" ]; then
|
||||||
|
MCPI_RENDER_DISTANCE="$(zenity --class "${ZENITY_CLASS}" --list --radiolist --width 400 --height 400 --text 'Minecraft Render Distance:' --column 'Selected' --column 'Name' FALSE 'Far' FALSE 'Normal' TRUE 'Short' FALSE 'Tiny')"
|
||||||
fi
|
fi
|
||||||
if [ -z "${MCPI_USERNAME+x}" ]; then
|
if [ -z "${MCPI_USERNAME+x}" ]; then
|
||||||
MCPI_USERNAME="$(zenity --class "${ZENITY_CLASS}" --entry --text 'Minecraft Username:' --entry-text 'StevePi')"
|
MCPI_USERNAME="$(zenity --class "${ZENITY_CLASS}" --entry --text 'Minecraft Username:' --entry-text 'StevePi')"
|
||||||
fi
|
fi
|
||||||
export MCPI_FEATURES
|
export MCPI_FEATURES
|
||||||
|
export MCPI_RENDER_DISTANCE
|
||||||
export MCPI_USERNAME
|
export MCPI_USERNAME
|
||||||
|
|
||||||
# Allow X11 Connections From Root
|
# Allow X11 Connections From Root
|
||||||
|
@ -14,5 +14,6 @@ services:
|
|||||||
- 'HOME=/home'
|
- 'HOME=/home'
|
||||||
- 'DISPLAY=unix${DISPLAY}'
|
- 'DISPLAY=unix${DISPLAY}'
|
||||||
- 'MCPI_FEATURES=${MCPI_FEATURES}'
|
- 'MCPI_FEATURES=${MCPI_FEATURES}'
|
||||||
|
- 'MCPI_RENDER_DISTANCE=${MCPI_RENDER_DISTANCE}'
|
||||||
- 'MCPI_USERNAME=${MCPI_USERNAME}'
|
- 'MCPI_USERNAME=${MCPI_USERNAME}'
|
||||||
- 'MCPI_MODE=native'
|
- 'MCPI_MODE=native'
|
||||||
|
@ -13,5 +13,6 @@ services:
|
|||||||
- 'HOME=/home'
|
- 'HOME=/home'
|
||||||
- 'DISPLAY=unix${DISPLAY}'
|
- 'DISPLAY=unix${DISPLAY}'
|
||||||
- 'MCPI_FEATURES=${MCPI_FEATURES}'
|
- 'MCPI_FEATURES=${MCPI_FEATURES}'
|
||||||
|
- 'MCPI_RENDER_DISTANCE=${MCPI_RENDER_DISTANCE}'
|
||||||
- 'MCPI_USERNAME=${MCPI_USERNAME}'
|
- 'MCPI_USERNAME=${MCPI_USERNAME}'
|
||||||
- 'MCPI_MODE=virgl'
|
- 'MCPI_MODE=virgl'
|
||||||
|
@ -115,6 +115,7 @@ static uint32_t Options_3d_anaglyph_property_offset = 0x15; // unsigned char / b
|
|||||||
static uint32_t Options_ambient_occlusion_property_offset = 0x18; // unsigned char / bool
|
static uint32_t Options_ambient_occlusion_property_offset = 0x18; // unsigned char / bool
|
||||||
static uint32_t Options_hide_gui_property_offset = 0xec; // unsigned char / bool
|
static uint32_t Options_hide_gui_property_offset = 0xec; // unsigned char / bool
|
||||||
static uint32_t Options_third_person_property_offset = 0xed; // unsigned char / bool
|
static uint32_t Options_third_person_property_offset = 0xed; // unsigned char / bool
|
||||||
|
static uint32_t Options_render_distance_property_offset = 0x10; // int32_t
|
||||||
|
|
||||||
// MouseBuildInput
|
// MouseBuildInput
|
||||||
|
|
||||||
|
@ -13,6 +13,24 @@ static uint32_t LevelData_getSpawnMobs_injection(__attribute__((unused)) unsigne
|
|||||||
return mob_spawning;
|
return mob_spawning;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get Custom Render Distance
|
||||||
|
static int get_render_distance() {
|
||||||
|
char *distance_str = getenv("MCPI_RENDER_DISTANCE");
|
||||||
|
if (distance_str == NULL) {
|
||||||
|
distance_str = "Short";
|
||||||
|
}
|
||||||
|
if (strcmp("Far", distance_str) == 0) {
|
||||||
|
return 0;
|
||||||
|
} else if (strcmp("Normal", distance_str) == 0) {
|
||||||
|
return 1;
|
||||||
|
} else if (strcmp("Short", distance_str) == 0) {
|
||||||
|
return 2;
|
||||||
|
} else if (strcmp("Tiny", distance_str) == 0) {
|
||||||
|
return 3;
|
||||||
|
} else {
|
||||||
|
ERR("Invalid Render Distance: %s", distance_str);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Get Custom Username
|
// Get Custom Username
|
||||||
static char *get_username() {
|
static char *get_username() {
|
||||||
char *username = getenv("MCPI_USERNAME");
|
char *username = getenv("MCPI_USERNAME");
|
||||||
@ -26,6 +44,7 @@ static int fancy_graphics;
|
|||||||
static int peaceful_mode;
|
static int peaceful_mode;
|
||||||
static int anaglyph;
|
static int anaglyph;
|
||||||
static int smooth_lighting;
|
static int smooth_lighting;
|
||||||
|
static int render_distance;
|
||||||
// Configure Options
|
// Configure Options
|
||||||
static void Minecraft_init_injection(unsigned char *this) {
|
static void Minecraft_init_injection(unsigned char *this) {
|
||||||
// Call Original Method
|
// Call Original Method
|
||||||
@ -42,6 +61,8 @@ static void Minecraft_init_injection(unsigned char *this) {
|
|||||||
*(options + Options_3d_anaglyph_property_offset) = anaglyph;
|
*(options + Options_3d_anaglyph_property_offset) = anaglyph;
|
||||||
// Smooth Lighting
|
// Smooth Lighting
|
||||||
*(options + Options_ambient_occlusion_property_offset) = smooth_lighting;
|
*(options + Options_ambient_occlusion_property_offset) = smooth_lighting;
|
||||||
|
// Render Distance
|
||||||
|
*(int32_t *) (options + Options_render_distance_property_offset) = render_distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable Touch GUI
|
// Enable Touch GUI
|
||||||
@ -71,6 +92,13 @@ void init_options() {
|
|||||||
peaceful_mode = feature_has("Peaceful Mode");
|
peaceful_mode = feature_has("Peaceful Mode");
|
||||||
// 3D Anaglyph
|
// 3D Anaglyph
|
||||||
anaglyph = feature_has("3D Anaglyph");
|
anaglyph = feature_has("3D Anaglyph");
|
||||||
|
// Render Distance
|
||||||
|
if (!is_server) {
|
||||||
|
render_distance = get_render_distance();
|
||||||
|
INFO("Setting Render Distance: %i", render_distance);
|
||||||
|
} else {
|
||||||
|
render_distance = 3;
|
||||||
|
}
|
||||||
|
|
||||||
// Set Options
|
// Set Options
|
||||||
overwrite_calls((void *) Minecraft_init, Minecraft_init_injection);
|
overwrite_calls((void *) Minecraft_init, Minecraft_init_injection);
|
||||||
|
Loading…
Reference in New Issue
Block a user