From 11e986bcf2c73e5730df00dfde701c82d935e101 Mon Sep 17 00:00:00 2001 From: mschiller890 Date: Tue, 17 Mar 2026 19:01:27 +0100 Subject: [PATCH] FIXED: Android build issues, added building to Andr from Linux I really hope this didnt break anything Im proud of the bash script --- .gitignore | 1 + README.md | 80 ++++- build.sh | 383 +++++++++++++++++++++ project/android/jni/Android.mk | 8 +- project/android/jni/Application.mk | 1 + project/lib_projects/raknet/jni/Android.mk | 5 +- src/client/Minecraft.cpp | 2 + src/client/Option.cpp | 7 +- src/client/Option.h | 2 +- src/client/gui/Gui.cpp | 5 +- src/client/player/LocalPlayer.cpp | 4 +- src/client/player/input/XperiaPlayInput.h | 2 + src/client/renderer/GameRenderer.cpp | 2 +- src/main_android.h | 2 +- src/main_android_java.h | 2 +- 15 files changed, 488 insertions(+), 18 deletions(-) create mode 100755 build.sh diff --git a/.gitignore b/.gitignore index 5dfd1b9..6336105 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ build/ out/ bin/ lib/ +build-apk/ cmake-build-*/ CMakeFiles/ CMakeCache.txt diff --git a/README.md b/README.md index 9470125..a5bf6be 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,9 @@ This project aims to preserve and improve this early version of Minecraft PE. - [ ] Screen fixes - [ ] Rewrite platform logic - [x] Fix sound -- [ ] Do a server connection GUI +- [x] Do a server connection GUI - [ ] Controller support -- [ ] Minecraft server hosting +- [x] Minecraft server hosting - [x] Screen fixess - [x] Fix fog - [x] Add sprinting @@ -70,7 +70,7 @@ cmake --build . 4. Press **Run** (or F5) to build and launch the game. ## Android - +### Windows 1. Download **Android NDK r14b**: http://dl.google.com/android/repository/android-ndk-r14b-windows-x86_64.zip @@ -94,4 +94,76 @@ cmake --build . # Only repackage + install (no compilation) .\build.ps1 -NoBuild -``` \ No newline at end of file +``` + +### Linux +1. Download **Command line tools**: + https://developer.android.com/studio#command-line-tools-only + +2. Unzip it into a folder, e.g.: + + ```bash + mkdir -p "$HOME/Android/Sdk/" + unzip commandlinetools-linux-*.zip -d "$HOME/Android/Sdk/" + ``` + +3. Your structure should look like + + ```bash + $HOME/Android/Sdk/cmdline-tools/bin/sdkmanager + ``` + + > [!NOTE] + > `sdkmanager` expects the SDK to include a `cmdline-tools/latest/` folder. + > If you only have `cmdline-tools/bin`, create the required layout: + > + > ```bash + > mkdir -p "$HOME/Android/Sdk/cmdline-tools/latest" + > ln -snf ../bin "$HOME/Android/Sdk/cmdline-tools/latest/bin" + > ln -snf ../lib "$HOME/Android/Sdk/cmdline-tools/latest/lib" + > ln -snf ../source.properties "$HOME/Android/Sdk/cmdline-tools/latest/source.properties" + > ln -snf ../NOTICE.txt "$HOME/Android/Sdk/cmdline-tools/latest/NOTICE.txt" + > ``` + +4. Install the build tools (and platform) using `sdkmanager` + + ```bash + export ANDROID_SDK_ROOT="$HOME/Android/Sdk" + export PATH="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$PATH" + + sdkmanager --install "platform-tools" "platforms;android-35" "build-tools;35.0.0" + ``` + + > [!NOTE] + > if you want build.sh to always find the SDK, + > Set ANDROID_SDK_ROOT in your shell config (~/.bashrc / ~/.profile / ~/.config/fish/config.fish), for example: + > + > ```bash + > export ANDROID_SDK_ROOT="$HOME/Android/Sdk" + > ``` + > + > Then restart your shell (or `source` the file) + +5. Verify the install + + ```bash + ls "$ANDROID_SDK_ROOT/build-tools" + ``` + + You should see a version folder like: + + ```bash + 35.0.0 + 33.0.2 + ``` + +6. Download **Android NDK r14b**: + https://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zip + +7. Extract the archive to `/home/username/`, so that the final directory path is `/home/username/android-ndk-r14b/` + + > [!WARNING] + > Make sure you don’t end up with a nested folder like `/home/username/android-ndk-r14b/android-ndk-r14b/`. + +8. Re run `build.sh` + diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..c9fd016 --- /dev/null +++ b/build.sh @@ -0,0 +1,383 @@ +#!/usr/bin/env bash +# ============================================================ +# Usage: +# ./build.sh # full build (NDK + Java + APK + install) +# ./build.sh --no-cpp # skip NDK rebuild (Java/assets changed) +# ./build.sh --no-java # skip Java recompile (C++ changed only) +# ./build.sh --no-build # repackage + install only (no recompile) +# ============================================================ + +# lets be strict cuz we are safe like that +# *thanos snap* +set -euo pipefail +IFS=$'\n\t' + +######################################## +# configuration +######################################## +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$SCRIPT_DIR" + +# build output directory (similar to apkbuild in the PS script) +# maybe doing this in build.ps1 would be cleaner, than putting the apkbuild in C: +BUILD_DIR="$REPO_ROOT/build-apk" + +# default Android/NDK/SDK paths (can be overridden by env vars) +ANDROID_NDK_PATH="${ANDROID_NDK_PATH:-$HOME/android-ndk-r14b}" +ANDROID_SDK_ROOT="${ANDROID_SDK_ROOT:-${ANDROID_HOME:-$HOME/Android/Sdk}}" +ANDROID_BUILD_TOOLS_VERSION="${ANDROID_BUILD_TOOLS_VERSION:-}" +ANDROID_PLATFORM_API="${ANDROID_PLATFORM_API:-}" + +function fail() { + echo "ERROR: $1" >&2 + exit 1 +} + +function find_build_tools_dir() { + if [[ -n "$ANDROID_BUILD_TOOLS_VERSION" ]]; then + local candidate="$ANDROID_SDK_ROOT/build-tools/$ANDROID_BUILD_TOOLS_VERSION" + [[ -d "$candidate" ]] && echo "$candidate" && return + fi + + if [[ ! -d "$ANDROID_SDK_ROOT/build-tools" ]]; then + fail "Android build-tools not found under $ANDROID_SDK_ROOT/build-tools. Set ANDROID_SDK_ROOT or install Android SDK build-tools." + fi + + # picking the highest build tools version because its the easiest way rn + # i guess if it breaks then fuck you + local best + best=$(ls -1 "$ANDROID_SDK_ROOT/build-tools" | sort -V | tail -n 1) + [[ -n "$best" && -d "$ANDROID_SDK_ROOT/build-tools/$best" ]] || \ + fail "No Android build-tools versions found under $ANDROID_SDK_ROOT/build-tools." + echo "$ANDROID_SDK_ROOT/build-tools/$best" +} + +function find_android_platform_dir() { + if [[ -n "$ANDROID_PLATFORM_API" ]]; then + local candidate="$ANDROID_SDK_ROOT/platforms/android-$ANDROID_PLATFORM_API" + [[ -d "$candidate" ]] && echo "$candidate" && return + fi + + if [[ ! -d "$ANDROID_SDK_ROOT/platforms" ]]; then + fail "Android platforms not found under $ANDROID_SDK_ROOT/platforms. Install an Android platform." + fi + + # pick the highest api level installed for now + # ideally we should be able to build to any api level, but lets keep it simple for now and + # just pick the highest one available + local best + best=$(ls -1 "$ANDROID_SDK_ROOT/platforms" | grep -E '^android-[0-9]+' | sed 's/android-//' | sort -n | tail -n 1) + [[ -n "$best" ]] || fail "No Android platforms found under $ANDROID_SDK_ROOT/platforms." + echo "$ANDROID_SDK_ROOT/platforms/android-$best" +} + +ANDROID_BUILD_TOOLS_DIR="$(find_build_tools_dir)" +ANDROID_PLATFORM_DIR="$(find_android_platform_dir)" + +KEYSTORE_FILE="$BUILD_DIR/debug.keystore" +PACKAGE_NAME="com.mojang.minecraftpe" + +# android tool binaries +AAPT="$ANDROID_BUILD_TOOLS_DIR/aapt" +ZIPALIGN="$ANDROID_BUILD_TOOLS_DIR/zipalign" +APKSIGNER="$ANDROID_BUILD_TOOLS_DIR/apksigner" +DEX_TOOL="$ANDROID_BUILD_TOOLS_DIR/d8" +ADB="${ADB:-$ANDROID_SDK_ROOT/platform-tools/adb}" + +# java tool binaries +JAVA_HOME_DEFAULT="${JAVA_HOME:-}" # may be empty + +# prefer javac from the jdk; +# on some systems /usr/lib/jvm/default points to a JRE only. +# If javac is missing, try to locate a JDK installation. +JAVAC_CMD="" +if command -v javac >/dev/null 2>&1; then + JAVAC_CMD="$(command -v javac)" +elif [[ -n "$JAVA_HOME_DEFAULT" && -x "$JAVA_HOME_DEFAULT/bin/javac" ]]; then + JAVAC_CMD="$JAVA_HOME_DEFAULT/bin/javac" +elif [[ -x "/usr/lib/jvm/java-8-openjdk/bin/javac" ]]; then + JAVAC_CMD="/usr/lib/jvm/java-8-openjdk/bin/javac" +elif [[ -x "/usr/lib/jvm/default/bin/javac" ]]; then + JAVAC_CMD="/usr/lib/jvm/default/bin/javac" +fi + +if [[ -z "$JAVAC_CMD" ]]; then + fail "javac not found; install a JDK and ensure javac is on PATH" +fi + +KEYTOOL="" # will be detected later + +# swource directories +JNI_DIR="$REPO_ROOT/project/android/jni" +JAVA_SRC_DIR="$REPO_ROOT/project/android_java/src" +ANDROID_MANIFEST="$REPO_ROOT/project/android_java/AndroidManifest.xml" +ANDROID_RES_DIR="$REPO_ROOT/project/android_java/res" +DATA_DIR="$REPO_ROOT/data" + +# output files +APK_UNSIGNED="$BUILD_DIR/minecraftpe-unsigned.apk" +APK_ALIGNED="$BUILD_DIR/minecraftpe-aligned.apk" +APK_SIGNED="$BUILD_DIR/minecraftpe-debug.apk" +DEX_OUTPUT="$BUILD_DIR/classes.dex" + +# flags parsed from CLI args +NO_CPP=false +NO_JAVA=false +NO_BUILD=false + +######################################## +# helpers +######################################## +function usage() { + cat < $1" +} + +function fail() { + echo "ERROR: $1" >&2 + exit 1 +} + +function require_cmd() { + if ! command -v "$1" >/dev/null 2>&1; then + fail "$1 not found; install it (e.g. 'sudo pacman -S $1')" + fi +} + +# ensure required tools are available early +require_cmd zip +require_cmd unzip + +function ensure_dir() { + mkdir -p "$1" +} + +function find_keytool() { + # first try JAVA_HOME if set + if [[ -n "$JAVA_HOME_DEFAULT" && -x "$JAVA_HOME_DEFAULT/bin/keytool" ]]; then + echo "$JAVA_HOME_DEFAULT/bin/keytool" + return + fi + + # try common install locations + if [[ -n "${JAVA_HOME:-}" && -x "${JAVA_HOME}/bin/keytool" ]]; then + echo "${JAVA_HOME}/bin/keytool" + return + fi + + if command -v keytool >/dev/null 2>&1; then + command -v keytool + return + fi + + fail "keytool not found. Set JAVA_HOME or install a JDK." +} + +function write_stub_file() { + local rel_path="$1" + local content="$2" + local full_path="$BUILD_DIR/stubs/$rel_path" + + ensure_dir "$(dirname "$full_path")" + if [[ ! -f "$full_path" ]]; then + echo -e "$content" > "$full_path" + echo " stub: $rel_path" + fi +} + +######################################## +# argument parsing +######################################## +while [[ $# -gt 0 ]]; do + case "$1" in + --no-cpp) NO_CPP=true ;; + --no-java) NO_JAVA=true ;; + --no-build) NO_BUILD=true ;; + -h|--help) usage ;; + *) + echo "Unknown option: $1" >&2 + usage + ;; + esac + shift +done + +######################################## +# validate required tools +######################################## +KEYTOOL="$(find_keytool)" + +if [[ ! -x "$AAPT" ]]; then + fail "aapt not found at $AAPT" +fi + +if [[ ! -x "$ZIPALIGN" ]]; then + fail "zipalign not found at $ZIPALIGN" +fi + +if [[ ! -x "$APKSIGNER" ]]; then + fail "apksigner not found at $APKSIGNER" +fi + +if [[ ! -x "$DEX_TOOL" ]]; then + fail "d8 not found at $DEX_TOOL" +fi + +if [[ ! -x "$ADB" ]]; then + fail "adb not found at $ADB" +fi + +######################################## +# bootstrap +######################################## +log_step "Bootstrap" + +ensure_dir "$BUILD_DIR" +ensure_dir "$BUILD_DIR/lib/arm64-v8a" +ensure_dir "$BUILD_DIR/gen" +ensure_dir "$BUILD_DIR/stubs" + +# create a debug keystore if it doesn't exist +if [[ ! -f "$KEYSTORE_FILE" ]]; then + echo " generating debug.keystore..." + "$KEYTOOL" -genkeypair \ + -keystore "$KEYSTORE_FILE" -storepass android -keypass android \ + -alias androiddebugkey -keyalg RSA -keysize 2048 -validity 10000 \ + -dname "CN=Android Debug,O=Android,C=US" >/dev/null 2>&1 + echo " keystore created" +else + echo " keystore OK" +fi + +# why dont we just include the stubs lol +write_stub_file "com/mojang/android/StringValue.java" "package com.mojang.android;\npublic interface StringValue { String getStringValue(); }\n" + +write_stub_file "com/mojang/android/licensing/LicenseCodes.java" "package com.mojang.android.licensing;\npublic class LicenseCodes { public static final int LICENSE_OK = 0; }\n" + +write_stub_file "com/mojang/android/EditTextAscii.java" "package com.mojang.android;\nimport android.content.Context;\nimport android.text.Editable;\nimport android.text.TextWatcher;\nimport android.util.AttributeSet;\nimport android.widget.EditText;\npublic class EditTextAscii extends EditText implements TextWatcher {\n public EditTextAscii(Context c) { super(c); addTextChangedListener(this); }\n public EditTextAscii(Context c, AttributeSet a) { super(c,a); addTextChangedListener(this); }\n public EditTextAscii(Context c, AttributeSet a, int d) { super(c,a,d); addTextChangedListener(this); }\n @Override public void onTextChanged(CharSequence s,int st,int b,int co){}\n public void beforeTextChanged(CharSequence s,int st,int co,int aft){}\n public void afterTextChanged(Editable e){\n String s=e.toString(),san=sanitize(s);\n if(!s.equals(san))e.replace(0,e.length(),san);\n }\n static public String sanitize(String s){\n StringBuilder sb=new StringBuilder();\n for(int i=0;iSurvival?Survival:i);\n int id=_type==Survival?R.string.gamemode_survival_summary:R.string.gamemode_creative_summary;\n String desc=getContext().getString(id);\n View v=getRootView().findViewById(R.id.labelGameModeDesc);\n if(desc!=null&&v instanceof TextView)((TextView)v).setText(desc);\n }\n public String getStringValue(){return new String[]{\"creative\",\"survival\"}[_type];}\n static public String getStringForType(int i){int c=iSurvival?Survival:i);return new String[]{\"creative\",\"survival\"}[c];}\n}\n" + +echo " stubs OK" + +######################################## +# ndk build +######################################## +if [[ "$NO_CPP" == false && "$NO_BUILD" == false ]]; then + log_step "NDK build (arm64-v8a)" + + # the original windows build script used a junction to avoid long paths here + # on linux, path lengths are *usually* fine, but we still keep things simple + pushd "$JNI_DIR" >/dev/null + + export NDK_MODULE_PATH="$REPO_ROOT/project/lib_projects" + + # run ndk-build and show output in case of failure + if ! "$ANDROID_NDK_PATH/ndk-build" NDK_PROJECT_PATH="$REPO_ROOT/project/android" APP_BUILD_SCRIPT="$JNI_DIR/Android.mk" 2>&1 | tee "$BUILD_DIR/ndk-build.log"; then + echo "NDK build failed. See $BUILD_DIR/ndk-build.log" >&2 + exit 1 + fi + + popd >/dev/null + + # copy the compiled library to the APK staging folder + cp -v "$REPO_ROOT/project/android/libs/arm64-v8a/libminecraftpe.so" "$BUILD_DIR/lib/arm64-v8a/" + + echo " .so -> $BUILD_DIR/lib/arm64-v8a/libminecraftpe.so" +fi + +######################################## +# java compile +######################################## +if [[ "$NO_JAVA" == false && "$NO_BUILD" == false ]]; then + log_step "Java compile" + + ensure_dir "$(dirname "$BUILD_DIR/gen/R.java")" + + # generate R.java + "$AAPT" package -f -M "$ANDROID_MANIFEST" -S "$ANDROID_RES_DIR" -I "$ANDROID_PLATFORM_DIR/android.jar" -J "$BUILD_DIR/gen" -F "$BUILD_DIR/_rgen.apk" + rm -f "$BUILD_DIR/_rgen.apk" + + # collect all source files (project + stubs + generated R.java) + JAVA_SOURCES=( + $(find "$JAVA_SRC_DIR" -name "*.java" -print) + $(find "$BUILD_DIR/stubs" -name "*.java" -print) + "$BUILD_DIR/gen/R.java" + ) + + rm -rf "$BUILD_DIR/classes" + ensure_dir "$BUILD_DIR/classes" + + # Some JDK versions (<=8) don’t support --release. + JAVAC_ARGS=(--release 8) + if "$JAVAC_CMD" -version 2>&1 | grep -qE '^javac 1\.'; then + JAVAC_ARGS=(-source 1.8 -target 1.8) + fi + + "$JAVAC_CMD" "${JAVAC_ARGS[@]}" -cp "$ANDROID_PLATFORM_DIR/android.jar" -d "$BUILD_DIR/classes" "${JAVA_SOURCES[@]}" + echo " javac OK" + + # convert class files into dex + JAVA_CLASS_FILES=( $(find "$BUILD_DIR/classes" -name "*.class" -print) ) + "$DEX_TOOL" --min-api 21 --output "$BUILD_DIR" "${JAVA_CLASS_FILES[@]}" + echo " d8 -> $DEX_OUTPUT" +fi + +######################################## +# package apk +######################################## +log_step "Package APK" + +rm -f "$APK_UNSIGNED" "$APK_ALIGNED" "$APK_SIGNED" + +"$AAPT" package -f -M "$ANDROID_MANIFEST" -S "$ANDROID_RES_DIR" -I "$ANDROID_PLATFORM_DIR/android.jar" -F "$APK_UNSIGNED" + +# add classes.dex and native library into apk +pushd "$BUILD_DIR" >/dev/null +zip -q "$APK_UNSIGNED" "classes.dex" +zip -q "$APK_UNSIGNED" "lib/arm64-v8a/libminecraftpe.so" +popd >/dev/null + +# add assets from data/ directory into the apk under assets/ +TMP_ASSETS_DIR="$(mktemp -d)" +mkdir -p "$TMP_ASSETS_DIR/assets" +cp -r "$DATA_DIR/." "$TMP_ASSETS_DIR/assets/" +pushd "$TMP_ASSETS_DIR" >/dev/null +zip -q -r "$APK_UNSIGNED" assets +popd >/dev/null +rm -rf "$TMP_ASSETS_DIR" + +"$ZIPALIGN" -p 4 "$APK_UNSIGNED" "$APK_ALIGNED" +"$APKSIGNER" sign --ks "$KEYSTORE_FILE" --ks-pass pass:android --key-pass pass:android --out "$APK_SIGNED" "$APK_ALIGNED" + +echo " signed -> $APK_SIGNED" + +######################################## +# install +######################################## +log_step "Install" + +"$ADB" shell am force-stop "$PACKAGE_NAME" || true +"$ADB" uninstall "$PACKAGE_NAME" || true +"$ADB" install --no-incremental "$APK_SIGNED" + +echo -e "\nDone. Enjoy MCPE 0.6.1 on your device!" diff --git a/project/android/jni/Android.mk b/project/android/jni/Android.mk index 3deb435..9bff609 100755 --- a/project/android/jni/Android.mk +++ b/project/android/jni/Android.mk @@ -24,6 +24,7 @@ LOCAL_SRC_FILES := ../../../src/main.cpp \ ../../../src/client/Options.cpp \ ../../../src/client/OptionsFile.cpp \ ../../../src/client/OptionStrings.cpp \ +../../../src/client/Option.cpp \ ../../../src/client/gamemode/GameMode.cpp \ ../../../src/client/gamemode/CreativeMode.cpp \ ../../../src/client/gamemode/SurvivalMode.cpp \ @@ -37,14 +38,14 @@ LOCAL_SRC_FILES := ../../../src/main.cpp \ ../../../src/client/gui/components/NinePatch.cpp \ ../../../src/client/gui/components/OptionsGroup.cpp \ ../../../src/client/gui/components/OptionsItem.cpp \ -../../../src/client/gui/components/OptionsPane.cpp \ +../../../src/client/gui/components/KeyOption.cpp \ +../../../src/client/gui/components/TextOption.cpp \ ../../../src/client/gui/components/RolledSelectionListH.cpp \ ../../../src/client/gui/components/RolledSelectionListV.cpp \ ../../../src/client/gui/components/ScrolledSelectionList.cpp \ ../../../src/client/gui/components/ScrollingPane.cpp \ ../../../src/client/gui/components/Slider.cpp \ ../../../src/client/gui/components/TextBox.cpp \ -../../../src/client/gui/components/SmallButton.cpp \ ../../../src/client/gui/Font.cpp \ ../../../src/client/gui/Gui.cpp \ ../../../src/client/gui/GuiComponent.cpp \ @@ -256,7 +257,8 @@ LOCAL_SRC_FILES := ../../../src/main.cpp \ ../../../src/world/phys/HitResult.cpp LOCAL_CFLAGS := -DPLATFORM_ANDROID -DPRE_ANDROID23 -Wno-narrowing $(LOCAL_CFLAGS) -LOCAL_CPPFLAGS := -std=c++11 +LOCAL_CPPFLAGS := -std=c++14 -frtti +LOCAL_CPPFLAGS += -frtti LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../src #LOCAL_CFLAGS := -DANDROID_PUBLISH -DDEMO_MODE $(LOCAL_CFLAGS) diff --git a/project/android/jni/Application.mk b/project/android/jni/Application.mk index 9853b52..2ea6b29 100755 --- a/project/android/jni/Application.mk +++ b/project/android/jni/Application.mk @@ -3,4 +3,5 @@ APP_STL := gnustl_static APP_OPTIM := release APP_ABI := arm64-v8a APP_SHORT_COMMANDS := true +APP_CPPFLAGS += -frtti -fexceptions #APP_ABI := armeabi-v7a x86 diff --git a/project/lib_projects/raknet/jni/Android.mk b/project/lib_projects/raknet/jni/Android.mk index 4be2d71..f50b99a 100755 --- a/project/lib_projects/raknet/jni/Android.mk +++ b/project/lib_projects/raknet/jni/Android.mk @@ -4,10 +4,11 @@ include $(CLEAR_VARS) LOCAL_MODULE := RakNet -MY_PREFIX := $(LOCAL_PATH)/RakNetSources/ +MY_PREFIX := $(LOCAL_PATH)/RaknetSources/ MY_SOURCES := $(wildcard $(MY_PREFIX)*.cpp) -LOCAL_SRC_FILES += $(MY_SOURCES:$(MY_PREFIX)%=RakNetSources/%) +LOCAL_SRC_FILES += $(MY_SOURCES:$(MY_PREFIX)%=RaknetSources/%) LOCAL_CFLAGS := -Wno-psabi $(LOCAL_CFLAGS) +LOCAL_CPPFLAGS += -frtti include $(BUILD_STATIC_LIBRARY) diff --git a/src/client/Minecraft.cpp b/src/client/Minecraft.cpp index 13bdf8f..5de6e52 100755 --- a/src/client/Minecraft.cpp +++ b/src/client/Minecraft.cpp @@ -23,6 +23,8 @@ #include "../world/level/storage/LevelStorageSource.h" #include "../world/level/storage/LevelStorage.h" #include "player/input/KeyboardInput.h" +#include "player/input/ControllerTurnInput.h" +#include "player/input/XperiaPlayInput.h" #include "world/level/chunk/ChunkSource.h" #ifndef STANDALONE_SERVER diff --git a/src/client/Option.cpp b/src/client/Option.cpp index 0e92abc..5b8c422 100644 --- a/src/client/Option.cpp +++ b/src/client/Option.cpp @@ -1,5 +1,8 @@ #include "Option.h" #include +#include + +Option::~Option() {} bool Option::parse_bool_like(const std::string& value, bool& out) { if (value == "true" || value == "YES") { @@ -23,7 +26,7 @@ bool OptionFloat::parse(const std::string& value) { return true; } - return std::sscanf(value.c_str(), "%f", &m_value) == 1; + return sscanf(value.c_str(), "%f", &m_value) == 1; } bool OptionInt::parse(const std::string& value) { bool b; @@ -32,7 +35,7 @@ bool OptionInt::parse(const std::string& value) { return true; } - return std::sscanf(value.c_str(), "%d", &m_value) == 1; + return sscanf(value.c_str(), "%d", &m_value) == 1; } bool OptionBool::parse(const std::string& value) { if (value == "0") { diff --git a/src/client/Option.h b/src/client/Option.h index 5bb0e56..cc6547a 100644 --- a/src/client/Option.h +++ b/src/client/Option.h @@ -21,7 +21,7 @@ template<> struct is_min_max_option : std::true_type {}; class Option { public: Option(const std::string& key) : m_key("options." + key) {} - virtual ~Option() = default; + virtual ~Option(); const std::string& getStringId() { return m_key; } diff --git a/src/client/gui/Gui.cpp b/src/client/gui/Gui.cpp index 6d0a25f..21be996 100755 --- a/src/client/gui/Gui.cpp +++ b/src/client/gui/Gui.cpp @@ -27,6 +27,7 @@ #include "../../platform/time.h" #include #include +#include float Gui::InvGuiScale = 1.0f / 3.0f; float Gui::GuiScale = 1.0f / Gui::InvGuiScale; @@ -841,7 +842,9 @@ void Gui::renderPlayerList(Font* font, int screenWidth, int screenHeight) { } // player count title - std::string titleText = "Players (" + std::to_string(playerNames.size()) + ")"; + std::ostringstream titleStream; + titleStream << "Players (" << playerNames.size() << ")"; + std::string titleText = titleStream.str(); float titleWidth = font->width(titleText); if (titleWidth > maxNameWidth) diff --git a/src/client/player/LocalPlayer.cpp b/src/client/player/LocalPlayer.cpp index 90d06a9..86629f5 100755 --- a/src/client/player/LocalPlayer.cpp +++ b/src/client/player/LocalPlayer.cpp @@ -350,8 +350,8 @@ void LocalPlayer::calculateFlight(float xa, float ya, float za) { za = za * flySpeed; #ifdef ANDROID - if (Keyboard::isKeyDown(103)) ya = .2f * minecraft->options.flySpeed; - if (Keyboard::isKeyDown(102)) ya = -.2f * minecraft->options.flySpeed; + if (Keyboard::isKeyDown(103)) ya = .2f * flySpeed; + if (Keyboard::isKeyDown(102)) ya = -.2f * flySpeed; #else if (Keyboard::isKeyDown(Keyboard::KEY_E)) ya = .2f * flySpeed; if (Keyboard::isKeyDown(Keyboard::KEY_Q)) ya = -.2f * flySpeed; diff --git a/src/client/player/input/XperiaPlayInput.h b/src/client/player/input/XperiaPlayInput.h index 196dda0..0b3afc5 100755 --- a/src/client/player/input/XperiaPlayInput.h +++ b/src/client/player/input/XperiaPlayInput.h @@ -4,6 +4,8 @@ //package net.minecraft.client.player; #include "KeyboardInput.h" +#include "platform/input/Controller.h" +#include "world/entity/player/Player.h" // @note: This is just copy-pasted from KeyboardInput right now. class XperiaPlayInput: public KeyboardInput diff --git a/src/client/renderer/GameRenderer.cpp b/src/client/renderer/GameRenderer.cpp index c1bc872..8165793 100755 --- a/src/client/renderer/GameRenderer.cpp +++ b/src/client/renderer/GameRenderer.cpp @@ -655,7 +655,7 @@ void GameRenderer::pick(float a) { float range = mc->gameMode->getPickRange(); bool isPicking = true; #ifndef PLATFORM_DESKTOP - bool freeform = mc->useTouchscreen() && !mc->options.isJoyTouchArea; + bool freeform = mc->useTouchscreen() && !mc->options.getBooleanValue(OPTIONS_IS_JOY_TOUCH_AREA); #else bool freeform = false; #endif diff --git a/src/main_android.h b/src/main_android.h index 4ab1285..e31102c 100755 --- a/src/main_android.h +++ b/src/main_android.h @@ -25,7 +25,7 @@ #include "platform/input/Mouse.h" #include "platform/input/Multitouch.h" -#include "EGLConfigPrinter.h" +#include "EglConfigPrinter.h" const int BroadcastPort = 9991; diff --git a/src/main_android_java.h b/src/main_android_java.h index 3c33244..89f8bb0 100755 --- a/src/main_android_java.h +++ b/src/main_android_java.h @@ -23,7 +23,7 @@ #include "platform/input/Mouse.h" #include "platform/input/Controller.h" -#include "EGLConfigPrinter.h" +#include "EglConfigPrinter.h" const int BroadcastPort = 9991;