Fixes and enhancements from my MCPE repository. (https://github.com/mschiller890/mcpe64)

This commit is contained in:
Michal Schiller
2026-03-10 19:31:40 +01:00
parent 0c97ceb340
commit 2fc323639a
69 changed files with 2509 additions and 639 deletions

View File

@@ -6,8 +6,8 @@
android:installLocation="preferExternal">
<!-- This is the platform API where NativeActivity was introduced. -->
<uses-sdk android:minSdkVersion="9"
android:targetSdkVersion="9" />
<uses-sdk android:minSdkVersion="21"
android:targetSdkVersion="21" />
<!-- uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="true"/ -->

View File

@@ -170,6 +170,7 @@ options.guiScale.auto=Auto
options.guiScale.small=Small
options.guiScale.normal=Normal
options.guiScale.large=Large
options.guiScale.larger=Larger
options.advancedOpengl=Advanced OpenGL
options.renderClouds=Clouds
options.farWarning1=A 64 bit Java installation is recommended

View File

@@ -4,7 +4,7 @@ include $(CLEAR_VARS)
LOCAL_MODULE := minecraftpe
LOCAL_SRC_FILES := ../../../src/main.cpp \
../../../src/main_android.cpp \
../../../src/main_android_java.cpp \
../../../src/platform/audio/SoundSystemSL.cpp \
../../../src/platform/input/Controller.cpp \
../../../src/platform/input/Keyboard.cpp \
@@ -40,6 +40,7 @@ LOCAL_SRC_FILES := ../../../src/main.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 \
@@ -48,6 +49,10 @@ LOCAL_SRC_FILES := ../../../src/main.cpp \
../../../src/client/gui/screens/ScreenChooser.cpp \
../../../src/client/gui/screens/ArmorScreen.cpp \
../../../src/client/gui/screens/ChatScreen.cpp \
../../../src/client/gui/screens/ChooseLevelScreen.cpp \
../../../src/client/gui/screens/SimpleChooseLevelScreen.cpp \
../../../src/client/gui/screens/ConsoleScreen.cpp \
../../../src/client/gui/screens/UsernameScreen.cpp \
../../../src/client/gui/screens/ConfirmScreen.cpp \
../../../src/client/gui/screens/ChestScreen.cpp \
../../../src/client/gui/screens/DeathScreen.cpp \
@@ -56,7 +61,8 @@ LOCAL_SRC_FILES := ../../../src/main.cpp \
../../../src/client/gui/screens/IngameBlockSelectionScreen.cpp \
../../../src/client/gui/screens/JoinGameScreen.cpp \
../../../src/client/gui/screens/OptionsScreen.cpp \
../../../src/client/gui/screens/PauseScreen.cpp \
../../../src/client/gui/screens/CreditsScreen.cpp \
../../../src/client/gui/screens/PauseScreen.cpp \
../../../src/client/gui/screens/ProgressScreen.cpp \
../../../src/client/gui/screens/RenameMPLevelScreen.cpp \
../../../src/client/gui/screens/SelectWorldScreen.cpp \
@@ -245,7 +251,9 @@ LOCAL_SRC_FILES := ../../../src/main.cpp \
../../../src/world/level/tile/entity/FurnaceTileEntity.cpp \
../../../src/world/phys/HitResult.cpp
LOCAL_CFLAGS := -Wno-psabi $(LOCAL_CFLAGS)
LOCAL_CFLAGS := -DPLATFORM_ANDROID -DPRE_ANDROID23 -Wno-narrowing $(LOCAL_CFLAGS)
LOCAL_CPPFLAGS := -std=c++11
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../src
#LOCAL_CFLAGS := -DANDROID_PUBLISH -DDEMO_MODE $(LOCAL_CFLAGS)
#LOCAL_CFLAGS := -DANDROID_PUBLISH $(LOCAL_CFLAGS)

View File

@@ -1,5 +1,5 @@
APP_PLATFORM := android-9
APP_STL := stlport_static
APP_PLATFORM := android-21
APP_STL := gnustl_static
APP_OPTIM := release
APP_ABI := armeabi-v7a
APP_ABI := arm64-v8a
#APP_ABI := armeabi-v7a x86

View File

@@ -2,43 +2,73 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mojang.minecraftpe"
android:versionCode="4000"
android:versionName="0.4.0"
>
<!-- android:installLocation="preferExternal" -->
android:versionName="0.4.0">
<uses-sdk android:targetSdkVersion="8" android:minSdkVersion="7"/>
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="28"/>
<uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="true"/>
<uses-feature
android:name="android.hardware.touchscreen.multitouch"
android:required="true"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<application android:icon="@drawable/icon"
android:label="@string/app_name"
>
<application
android:icon="@drawable/icon"
android:label="@string/app_name"
android:hardwareAccelerated="true"
android:extractNativeLibs="true"
android:requestLegacyExternalStorage="true">
<activity android:name="com.mojang.minecraftpe.Minecraft_Market"
android:label="@string/app_name_short"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
<activity
android:name="com.mojang.minecraftpe.Minecraft_Market"
android:label="@string/app_name_short"
android:configChanges="orientation|keyboardHidden|screenSize|uiMode"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:exported="true">
<meta-data android:name="android.app.lib_name"
android:value="minecraftpe" />
<meta-data
android:name="android.app.lib_name"
android:value="minecraftpe"/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity android:name="com.mojang.minecraftpe.MainMenuOptionsActivity"></activity>
<meta-data android:name="xperiaplayoptimized_content" android:resource="@string/xperiaplayoptimized_content" />
<meta-data android:name="game_display_name" android:resource="@string/app_name" />
<meta-data android:name="game_icon" android:resource="@drawable/iconx" />
<uses-library android:name="xperiaplaycertified" android:required="false"/>
<activity
android:name="com.mojang.minecraftpe.MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize|uiMode"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:exported="false"/>
<activity
android:name="com.mojang.minecraftpe.MainMenuOptionsActivity"
android:exported="false"/>
<meta-data
android:name="xperiaplayoptimized_content"
android:resource="@string/xperiaplayoptimized_content"/>
<meta-data
android:name="game_display_name"
android:resource="@string/app_name"/>
<meta-data
android:name="game_icon"
android:resource="@drawable/iconx"/>
<uses-library
android:name="xperiaplaycertified"
android:required="false"/>
</application>
</manifest>
</manifest>

View File

@@ -40,7 +40,6 @@ import android.os.Vibrator;
import android.preference.PreferenceManager;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -58,6 +57,8 @@ public class MainActivity extends Activity {
private GLView _glView;
public float invScale = 1.0f;// / 1.5f;
private int _screenWidth = 0;
private int _screenHeight = 0;
Vector<MotionEvent> _touchEvents = new Vector<MotionEvent>();
Vector<KeyEvent> _keyEvents = new Vector<KeyEvent>();
@@ -67,8 +68,13 @@ public class MainActivity extends Activity {
setVolumeControlStream(AudioManager.STREAM_MUSIC);
super.onCreate(savedInstanceState);
nativeRegisterThis();
nativeOnCreate();
// Cache screen dimensions once to avoid re-entrant getDisplayMetrics() callbacks
android.util.DisplayMetrics _dm = getResources().getDisplayMetrics();
_screenWidth = Math.max(_dm.widthPixels, _dm.heightPixels);
_screenHeight = Math.min(_dm.widthPixels, _dm.heightPixels);
nativeOnCreate(_screenWidth, _screenHeight);
_glView = new GLView(getApplication(), this);
//_glView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
@@ -105,15 +111,22 @@ public class MainActivity extends Activity {
}
public boolean isTouchscreen() { return true; }
public boolean supportsTouchscreen() { return true; }
static public boolean isXperiaPlay() { return false; }
static private boolean _isPowerVr = false;
public void setIsPowerVR(boolean status) { MainActivity._isPowerVr = status; }
static public boolean isPowerVR() { return _isPowerVr; }
@SuppressWarnings("deprecation")
public void vibrate(int milliSeconds) {
Vibrator v = (Vibrator)this.getSystemService(VIBRATOR_SERVICE);
v.vibrate(milliSeconds);
Vibrator v = (Vibrator) getSystemService(VIBRATOR_SERVICE);
if (android.os.Build.VERSION.SDK_INT >= 26) {
v.vibrate(android.os.VibrationEffect.createOneShot(milliSeconds,
android.os.VibrationEffect.DEFAULT_AMPLITUDE));
} else {
v.vibrate(milliSeconds);
}
}
private void createAlertDialog(boolean hasOkButton, boolean hasCancelButton, boolean preventBackKey) {
@@ -144,9 +157,16 @@ public class MainActivity extends Activity {
@Override
public void onWindowFocusChanged(boolean hasFocus) {
// TODO Auto-generated method stub
//System.out.println("Focus has changed. Has Focus? " + hasFocus);
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
}
}
@Override
@@ -184,9 +204,12 @@ public class MainActivity extends Activity {
return;
}
if (event.getAction() == KeyEvent.ACTION_DOWN)
if (event.getAction() == KeyEvent.ACTION_DOWN) {
nativeOnKeyDown(keyCode);
else if (event.getAction() == KeyEvent.ACTION_UP)
int unicodeChar = event.getUnicodeChar(event.getMetaState());
if (unicodeChar > 0)
nativeTextChar(unicodeChar);
} else if (event.getAction() == KeyEvent.ACTION_UP)
nativeOnKeyUp(keyCode);
}
@@ -347,22 +370,15 @@ public class MainActivity extends Activity {
}
public int getScreenWidth() {
Display display = ((WindowManager)this.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int out = Math.max(display.getWidth(), display.getHeight());
//System.out.println("getwidth: " + out);
return out;
return _screenWidth;
}
public int getScreenHeight() {
Display display = ((WindowManager)this.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
int out = Math.min(display.getWidth(), display.getHeight());
//System.out.println("getheight: " + out);
return out;
return _screenHeight;
}
public float getPixelsPerMillimeter() {
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
android.util.DisplayMetrics metrics = getResources().getDisplayMetrics();
return (metrics.xdpi + metrics.ydpi) * 0.5f / 25.4f;
}
@@ -465,8 +481,8 @@ public class MainActivity extends Activity {
MainActivity.this.mDialog.show();
MainActivity.this.mDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
MainActivity.this.mDialog.getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
//MainActivity.this.getWindow().setLayout(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
MainActivity.this.mDialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
//MainActivity.this.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
}
});
}
@@ -516,6 +532,11 @@ public class MainActivity extends Activity {
public void buyGame() {}
public int getKeyFromKeyCode(int keyCode, int metaState, int deviceId) {
android.view.KeyCharacterMap kcm = android.view.KeyCharacterMap.load(deviceId);
return kcm.get(keyCode, metaState);
}
public String getPlatformStringVar(int id) {
if (id == 0) return android.os.Build.MODEL;
return null;
@@ -604,10 +625,11 @@ public class MainActivity extends Activity {
//
native void nativeRegisterThis();
native void nativeUnregisterThis();
native static void nativeOnCreate();
native static void nativeOnCreate(int screenWidth, int screenHeight);
native static void nativeOnDestroy();
native static void nativeOnKeyDown(int key);
native static void nativeOnKeyUp(int key);
native static void nativeTextChar(int unicodeChar);
native static boolean nativeHandleBack(boolean isDown);
native static void nativeMouseDown(int pointerId, int buttonId, float x, float y);
native static void nativeMouseUp(int pointerId, int buttonId, float x, float y);

View File

@@ -5,7 +5,7 @@
#include <stdio.h> // RAKNET_DEBUG_PRINTF
#include "RakAssert.h"
#if defined(ANDROID)
#include <asm/io.h>
// <asm/io.h> not needed and unavailable on arm64
#elif defined(_WIN32) || defined(__CYGWIN__)
#include <io.h>