Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
7e1940a
Attempt To Get CMake To Like MinGW
TheBrokenRail Jun 18, 2024
8ee49a8
Some Fixes
TheBrokenRail Jun 18, 2024
73846e9
More CMake Fiexes!
TheBrokenRail Jun 18, 2024
ad386d3
Decouple Audio Platforms
TheBrokenRail Jun 18, 2024
34baf62
Try To Fix The Build Again
TheBrokenRail Jun 18, 2024
7c268be
Fix Cursed Symlink
TheBrokenRail Jun 18, 2024
37a8170
Please Work
TheBrokenRail Jun 18, 2024
0aae3d5
Maybe this will work?
TheBrokenRail Jun 18, 2024
3b5f465
New Sound Script
TheBrokenRail Jun 18, 2024
4d5d85e
Fancy Sound Loading
TheBrokenRail Jun 18, 2024
2e3a554
Update GLES Layer
TheBrokenRail Jun 18, 2024
fade654
Fix macOS Build (Again)
TheBrokenRail Jun 18, 2024
f854bfc
Update GLES Compat Layer
TheBrokenRail Jun 18, 2024
7a5c479
I Dream Of Burning Macs
TheBrokenRail Jun 18, 2024
cdd0b29
Some Final Fixes
TheBrokenRail Jun 18, 2024
78b9dd2
OpenAL On Windows
TheBrokenRail Jun 18, 2024
8414def
Fix WASM Build
TheBrokenRail Jun 18, 2024
ba38e1f
Fancy APK Extractor!
TheBrokenRail Jun 19, 2024
7cc2c5c
Some Fixes
TheBrokenRail Jun 19, 2024
7786ce6
Fix Merge Conflicts + Bugfixes
BrentDaMage Mar 6, 2025
f4e028a
Rendering Bugfixes
BrentDaMage Mar 6, 2025
f0c079b
Fixed UI sound playback volume + cleanup
BrentDaMage Mar 15, 2025
dbe8cff
Cleanup
BrentDaMage Mar 29, 2025
22093e9
Merge branch 'master' into cmake-mingw-things
BrentDaMage Apr 13, 2025
45bb7e3
Merge branch 'master' into cmake-mingw-things
BrentDaMage Apr 19, 2025
c87a853
Fix bad merge
BrentDaMage Apr 19, 2025
d527f0e
Added OGG Vorbis Support
BrentDaMage Apr 20, 2025
c8d3e09
Documented Field + Minor Bugfix
BrentDaMage Apr 20, 2025
bef312f
Fixed stb_vorbis include
BrentDaMage Apr 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 40 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y build-essential cmake ninja-build libopenal-dev libsdl2-dev zlib1g-dev
sudo apt-get install --no-install-recommends -y \
build-essential \
cmake ninja-build \
libopenal-dev \
libsdl2-dev zlib1g-dev
- name: Build
run: |
cd platforms/sdl
mkdir build
cd build
cmake -GNinja ${{ matrix.flags }} ..
Expand All @@ -37,7 +40,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true
- name: Install Dependencies
Expand All @@ -51,7 +54,7 @@ jobs:
runs-on: macos-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true
- name: Install MacPorts
Expand All @@ -62,6 +65,7 @@ jobs:
sudo port install libpng +universal
- name: Build macOS Archive
run: |
ln -s sound/openal platforms/openal # Please someone fix this properly later.
cd platforms/macos/projects/Minecraft
xcodebuild -scheme "MinecraftClient.SDL2" \
-archivePath $RUNNER_TEMP/GitHubActions_MacOS_SDL2.xcarchive \
Expand Down Expand Up @@ -103,11 +107,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true
- name: Setup JDK
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
Expand All @@ -116,3 +120,32 @@ jobs:
run: |
cd ${{ matrix.directory }}
./gradlew build
mingw:
strategy:
fail-fast: false
matrix:
include:
- name: Win32
flags: "-DREMCPE_PLATFORM=windows"
- name: SDL
flags: "-DREMCPE_PLATFORM=sdl"
name: MinGW-w64 (${{ matrix.name }})
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: true
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y \
build-essential \
cmake ninja-build \
mingw-w64
- name: Build
run: |
mkdir build
cd build
cmake -GNinja -DCMAKE_TOOLCHAIN_FILE=../cmake/mingw-w64-toolchain.cmake ${{ matrix.flags }} ..
cmake --build .
15 changes: 11 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ xcuserdata/
/sound_data

# Ignore linux/mingw build artifacts.
/build
/build*
/minecraftcpp
/minecraftcpp.exe

Expand Down Expand Up @@ -187,9 +187,7 @@ xcuserdata/
/game/assets/gui/startmenu/sm_play.png
/game/assets/gui/startmenu/sm_multi.png
/game/assets/gui/startmenu/sm_options.png
/game/assets/gui/touchgui.png
/game/assets/gui/feedback_fill.png
/game/assets/gui/feedback_outer.png

/game/assets/snow.png
# Ignore all native iOS UI assets.
/game/assets/app/ios/
Expand Down Expand Up @@ -242,3 +240,12 @@ xcuserdata/
# Ignore options.txt - where your configuration will be saved
/game/options.txt
/game/assetsO

# CLion
/.idea
/cmake-build-*

# Sound
/tools/__pycache__
/tools/venv
/game/assets/sound
61 changes: 61 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
cmake_minimum_required(VERSION 3.16.0)
project(reminecraftpe)

# Store Output In Top-Level Build Directory
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")

# WASM
if(EMSCRIPTEN)
function(add_compile_and_link_options)
add_compile_options(${ARGV})
add_link_options(${ARGV})
endfunction()
set(CMAKE_EXECUTABLE_SUFFIX ".js")
add_link_options("$<$<CONFIG:DEBUG>:-gsource-map>")
add_link_options(-Wno-pthreads-mem-growth -sALLOW_MEMORY_GROWTH=1)
endif()

# Clang
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_compile_options(-Wno-inconsistent-missing-override -Wno-enum-compare-switch -Wno-register)
endif()

# Windows Linking
if(WIN32)
add_link_options(
-static-libgcc
-static-libstdc++
)
endif()

# HaikuOS Network Library
if(HAIKU)
link_libraries(network)
endif()

# Threading
if(EMSCRIPTEN)
add_compile_and_link_options(-pthread)
else()
find_package(Threads)
link_libraries(Threads::Threads)
endif()

# Android Logging
if(ANDROID)
link_libraries(log)
endif()

# Load Common Code
add_subdirectory(source)

# Load Platform-Specific Code
add_subdirectory(platforms)

# Assets
if(EMSCRIPTEN)
target_link_options(reminecraftpe PRIVATE --use-preload-plugins --preload-file "${CMAKE_CURRENT_SOURCE_DIR}/game@/")
else()
file(CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR}/game/assets" "${CMAKE_CURRENT_BINARY_DIR}/assets" SYMBOLIC)
endif()
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ based on Minecraft PE v0.1.3.
* To keep the source code layout similar to the original Minecraft PE (reconstructed from clues hidden within
certain versions of the game, such as the 0.1.0 touch prototype/debug build)
* To port the game to more platforms, such as Windows (including older versions), Xbox 360, Wii, and more.
Currently there are ports for:
Currently, there are ports for:
* Windows XP-11
* Android (thanks to [Stom](https://github.com/Stommm) for the help)
* Linux
* WebGL
* Mac OS (port by [BrentDaMage](https://github.com/BrentDaMage))
* macOS (port by [BrentDaMage](https://github.com/BrentDaMage))
* iOS (3.0 and above; port by [BrentDaMage](https://github.com/BrentDaMage))
* HaikuOS (thanks to [SanyaSho](https://github.com/SanyaSho))
* Xbox 360 (work in progress; port by [BrentDaMage](https://github.com/BrentDaMage))
Expand All @@ -36,7 +36,7 @@ Note: While the original Minecraft PE v0.1.3 may not work on newer devices, ReMi

## License information

This project is licensed under the [BSD 1 clause license](LICENSE.md). However, it contains third party
This project is licensed under the [BSD 1 clause license](LICENSE.txt). However, it contains third party
software with different but compatible licenses:

- [RakNet](https://github.com/facebookarchive/RakNet): [Licensed under the BSD 2 clause license](thirdparty/raknet/LICENSE)
Expand Down Expand Up @@ -142,7 +142,6 @@ This project uses CMake on Linux. Just like WebAssembly, the game assets must be
#### How To Build

```sh
cd platforms/sdl
mkdir build && cd build
cmake -GNinja ..
cmake --build .
Expand Down
2 changes: 1 addition & 1 deletion build-wasm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ mkdir -p build
cd build

# Configure Build
emcmake cmake -GNinja "$@" ../../platforms/sdl
emcmake cmake -GNinja "$@" ../../

# Build
cmake --build .
Expand Down
11 changes: 11 additions & 0 deletions cmake/mingw-w64-toolchain.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# https://gist.github.com/peterspackman/8cf73f7f12ba270aa8192d6911972fe8
set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
set(CMAKE_C_COMPILER "${TOOLCHAIN_PREFIX}-gcc")
set(CMAKE_CXX_COMPILER "${TOOLCHAIN_PREFIX}-g++")
set(CMAKE_Fortran_COMPILER "${TOOLCHAIN_PREFIX}-gfortran")
set(CMAKE_RC_COMPILER "${TOOLCHAIN_PREFIX}-windres")
set(CMAKE_FIND_ROOT_PATH "/usr/${TOOLCHAIN_PREFIX}")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
2 changes: 1 addition & 1 deletion compat/KeyCodes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ enum eSDLVirtualKeys

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <windows.h>
#elif __APPLE__
// https://i.stack.imgur.com/LD8pT.png
#define AKEYCODE_FORWARD_DEL 0x75
Expand Down
12 changes: 12 additions & 0 deletions platforms/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
project(reminecraftpe-platforms)

# Select & Build
set(DEFAULT_PLATFORM "sdl")
if(WIN32)
set(DEFAULT_PLATFORM "windows")
endif()
set(REMCPE_PLATFORM "${DEFAULT_PLATFORM}" CACHE STRING "ReMCPE Platform (Check <root>/platforms)")
add_subdirectory("${REMCPE_PLATFORM}")

# Load Sound
add_subdirectory(sound)
23 changes: 21 additions & 2 deletions platforms/android/AppPlatform_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <sstream>

#include "AppPlatform_android.hpp"
#include "SoundSystemSL.hpp"
#include "CustomSoundSystem.hpp"
#include "client/player/input/Mouse.hpp"

#include "stb_image.h"
Expand Down Expand Up @@ -174,7 +174,7 @@ SoundSystem* const AppPlatform_android::getSoundSystem() const
void AppPlatform_android::initSoundSystem()
{
if (!m_pSoundSystem)
m_pSoundSystem = new SoundSystemSL();
m_pSoundSystem = new SOUND_SYSTEM();
else
LOG_E("Trying to initialize SoundSystem more than once!");
}
Expand Down Expand Up @@ -357,3 +357,22 @@ int AppPlatform_android::getKeyboardUpOffset()
// For now we'll just return 1/2 of the screen height. That ought to cover most cases.
return m_ScreenHeight / 2;
}

AssetFile AppPlatform_android::readAssetFile(const std::string& str) const
{
std::string realPath = str;
if (realPath.size() && realPath[0] == '/')
// trim it off
realPath = realPath.substr(1);

AAsset* asset = AAssetManager_open(m_app->activity->assetManager, str.c_str(), AASSET_MODE_BUFFER);
if (!asset) {
LOG_E("File %s couldn't be opened", realPath.c_str());
return AssetFile();
}
size_t cnt = AAsset_getLength(asset);
unsigned char* buffer = new unsigned char[cnt];
AAsset_read(asset, (void*)buffer, cnt);
AAsset_close(asset);
return AssetFile(ssize_t(cnt), buffer);
}
2 changes: 2 additions & 0 deletions platforms/android/AppPlatform_android.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class AppPlatform_android : public AppPlatform
void initAndroidApp(android_app* ptr);
void setExternalStoragePath(const std::string& path);

AssetFile readAssetFile(const std::string&) const override;

private:
void changeKeyboardVisibility(bool bShown);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
cmake_minimum_required(VERSION 3.16.0)
project(reminecraftpe-android)

# Project Root
set(MC_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../..")

# Native Android Build
add_compile_definitions(USE_NATIVE_ANDROID)
set(USE_NATIVE_ANDROID TRUE)
target_compile_definitions(reminecraftpe-core PUBLIC USE_NATIVE_ANDROID)

# Build
add_library(reminecraftpe SHARED
"${MC_ROOT}/platforms/android/android_native_app_glue.c"
"${MC_ROOT}/platforms/android/AppPlatform_android.cpp"
"${MC_ROOT}/platforms/android/SoundSystemSL.cpp"
"${MC_ROOT}/platforms/android/main.cpp"
android_native_app_glue.c
AppPlatform_android.cpp
main.cpp
)

# Core
add_subdirectory("${MC_ROOT}/source" source)
target_link_libraries(reminecraftpe reminecraftpe-core)

# OpenGL
target_link_libraries(reminecraftpe-core PUBLIC EGL GLESv1_CM)

# stb_image
add_subdirectory("${MC_ROOT}/thirdparty/stb_image" stb_image)
add_subdirectory(../../thirdparty/stb_image stb_image)
target_link_libraries(reminecraftpe stb_image)

# Extra Dependencies
target_link_libraries(reminecraftpe android OpenSLES)
target_link_libraries(reminecraftpe android)

# Check for the presence of some optional asset based features.
if(EXISTS "${MC_ROOT}/game/assets/gui/background/panorama_0.png")
Expand Down
4 changes: 2 additions & 2 deletions platforms/android/project/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ android {
// testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
arguments '-DANDROID_PLATFORM=android-21', '-DANDROID_STL=c++_static'
arguments '-DANDROID_PLATFORM=android-21', '-DANDROID_STL=c++_static', '-DREMCPE_PLATFORM=android', '-DREMCPE_SOUND_PLATFORM=opensl'
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86', 'x86_64'
}
}
Expand All @@ -47,7 +47,7 @@ android {
}
externalNativeBuild {
cmake {
path file('src/main/cpp/CMakeLists.txt')
path '../../../../CMakeLists.txt'
version '3.22.1'
}
}
Expand Down
Loading
Loading