mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-03-30 20:13:31 +00:00
Compare commits
8 Commits
!no-build-
...
abfb9e0f64
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abfb9e0f64 | ||
|
|
359a9d2620 | ||
|
|
967080a435 | ||
|
|
05baea1ed4 | ||
|
|
04aea27334 | ||
|
|
2d731bc3b6 | ||
|
|
0d1387ad8f | ||
|
|
d103caddab |
27
.github/actions/setup-cache/action.yml
vendored
27
.github/actions/setup-cache/action.yml
vendored
@@ -1,27 +0,0 @@
|
||||
name: Setup cache
|
||||
description: Sets up sccache, CPM cache, etc.
|
||||
|
||||
inputs:
|
||||
host:
|
||||
description: 'Host platform: win or linux'
|
||||
required: true
|
||||
target:
|
||||
description: 'Target platform: win, linux'
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Setup sccache
|
||||
uses: hendrikmuhs/ccache-action@v1.2.13
|
||||
with:
|
||||
variant: sccache
|
||||
key: ${{ inputs.target }}-v1
|
||||
|
||||
- name: Setup CPM Cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: cpm-cache
|
||||
key: cpm-${{ inputs.target }}-v1-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
|
||||
restore-keys: |
|
||||
cpm-${{ inputs.target }}-v1-
|
||||
17
.github/actions/setup-ninja/action.yml
vendored
17
.github/actions/setup-ninja/action.yml
vendored
@@ -1,17 +0,0 @@
|
||||
name: Setup Ninja
|
||||
description: Sets up Ninja
|
||||
|
||||
inputs:
|
||||
host:
|
||||
description: 'Host platform: win, mac or linux'
|
||||
required: true
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Setup
|
||||
shell: bash
|
||||
run: |
|
||||
curl -L https://github.com/ninja-build/ninja/releases/latest/download/ninja-${{ inputs.host }}.zip -o ninja.zip
|
||||
7z x ninja.zip -o"$GITHUB_WORKSPACE/ninja"
|
||||
echo "$GITHUB_WORKSPACE/ninja" >> $GITHUB_PATH
|
||||
36
.github/workflows/android.yml
vendored
Normal file
36
.github/workflows/android.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
name: Android Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download Android NDK r14b
|
||||
shell: powershell
|
||||
run: |
|
||||
Invoke-WebRequest `
|
||||
-Uri "http://dl.google.com/android/repository/android-ndk-r14b-windows-x86_64.zip" `
|
||||
-OutFile "ndk.zip"
|
||||
|
||||
- name: Extract NDK
|
||||
shell: powershell
|
||||
run: |
|
||||
Expand-Archive ndk.zip C:\
|
||||
|
||||
- name: Verify NDK path
|
||||
shell: powershell
|
||||
run: |
|
||||
Test-Path "C:\android-ndk-r14b"
|
||||
|
||||
- name: Run build script
|
||||
shell: powershell
|
||||
run: |
|
||||
./build.ps1
|
||||
343
.github/workflows/build.yml
vendored
343
.github/workflows/build.yml
vendored
@@ -1,343 +0,0 @@
|
||||
name: Build Game
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- '**' # every branch
|
||||
- '!no-build-**' # unless marked as no-build
|
||||
|
||||
env:
|
||||
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
||||
BUILD_TYPE: Release
|
||||
CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm-cache
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build-windows:
|
||||
name: Build Windows
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup caches
|
||||
uses: ./.github/actions/setup-cache
|
||||
with:
|
||||
host: linux
|
||||
target: win
|
||||
|
||||
- name: Setup Ninja
|
||||
uses: ./.github/actions/setup-ninja
|
||||
with:
|
||||
host: linux
|
||||
|
||||
- name: Download llvm-mingw
|
||||
run: |
|
||||
curl -L https://github.com/mstorsjo/llvm-mingw/releases/download/20260311/llvm-mingw-20260311-msvcrt-ubuntu-22.04-x86_64.tar.xz -o llvm-mingw.tar.xz
|
||||
tar -xf llvm-mingw.tar.xz
|
||||
mv llvm-mingw-* llvm-mingw
|
||||
|
||||
- name: Create Build Environment
|
||||
# Some projects don't allow in-source building, so create a separate build directory
|
||||
# We'll use this as our working directory for all subsequent commands
|
||||
run: cmake -E make_directory ${{github.workspace}}/build
|
||||
|
||||
- name: Configure CMake
|
||||
working-directory: ${{github.workspace}}/build
|
||||
run: |
|
||||
cmake $GITHUB_WORKSPACE \
|
||||
-G Ninja \
|
||||
-DCMAKE_SYSTEM_NAME=Windows \
|
||||
-DCMAKE_C_COMPILER=$GITHUB_WORKSPACE/llvm-mingw/bin/x86_64-w64-mingw32-clang \
|
||||
-DCMAKE_CXX_COMPILER=$GITHUB_WORKSPACE/llvm-mingw/bin/x86_64-w64-mingw32-clang++ \
|
||||
-DCMAKE_RC_COMPILER=$GITHUB_WORKSPACE/llvm-mingw/bin/x86_64-w64-mingw32-windres \
|
||||
-DALSOFT_BACKEND_PIPEWIRE=OFF \
|
||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{github.workspace}}/build
|
||||
run: cmake --build . --config $BUILD_TYPE --target MinecraftPE --parallel
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mcpe-windows
|
||||
path: |
|
||||
${{github.workspace}}/build/MinecraftPE.exe
|
||||
${{github.workspace}}/build/libpng16.dll
|
||||
${{github.workspace}}/build/OpenAL32.dll
|
||||
${{github.workspace}}/build/libz.dll
|
||||
|
||||
build-linux:
|
||||
name: Build Linux
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup caches
|
||||
uses: ./.github/actions/setup-cache
|
||||
with:
|
||||
host: linux
|
||||
target: linux
|
||||
|
||||
- name: Create Build Environment
|
||||
# Some projects don't allow in-source building, so create a separate build directory
|
||||
# We'll use this as our working directory for all subsequent commands
|
||||
run: cmake -E make_directory ${{github.workspace}}/build
|
||||
|
||||
- name: Setup Environment
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install gcc-multilib
|
||||
sudo apt-get install -y --no-install-recommends build-essential libgl-dev libwayland-dev xorg-dev libxkbcommon-dev
|
||||
|
||||
- name: Configure CMake
|
||||
# Use a bash shell so we can use the same syntax for environment variable
|
||||
# access regardless of the host operating system
|
||||
shell: bash
|
||||
working-directory: ${{github.workspace}}/build
|
||||
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{github.workspace}}/build
|
||||
shell: bash
|
||||
run: |
|
||||
cmake --build . --config $BUILD_TYPE --target MinecraftPE --parallel
|
||||
cmake --build . --config $BUILD_TYPE --target MinecraftPE-server --parallel
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mcpe-linux
|
||||
path: |
|
||||
${{github.workspace}}/build/MinecraftPE
|
||||
${{github.workspace}}/build/MinecraftPE-server
|
||||
|
||||
build-android: # pray to god
|
||||
name: Build Android (${{ matrix.abi }})
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
# keep going with the other ABI if one fails so you at least get something useful
|
||||
fail-fast: false
|
||||
matrix:
|
||||
abi: [ arm64-v8a, armeabi-v7a ]
|
||||
|
||||
env:
|
||||
ANDROID_SDK_ROOT: ${{ github.workspace }}/android-sdk
|
||||
ANDROID_NDK_PATH: ${{ github.workspace }}/android-ndk-r14b
|
||||
ANDROID_PLATFORM_API: 36
|
||||
ANDROID_BUILD_TOOLS_VERSION: 36.0.0
|
||||
ADB: /bin/true
|
||||
# build.sh reads MATRIX_ABI to decide which ABI to build when no --abi flag is passed
|
||||
MATRIX_ABI: ${{ matrix.abi }}
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Cache Android command-line tools
|
||||
id: cache-android-tools
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ env.ANDROID_SDK_ROOT }}
|
||||
key: android-cmdline-tools-v36
|
||||
|
||||
- name: Setup Android command line tools
|
||||
if: steps.cache-android-tools.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
if [ ! -d "$ANDROID_SDK_ROOT/cmdline-tools/latest" ]; then
|
||||
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools"
|
||||
curl -o cmdline-tools.zip -L "https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip"
|
||||
unzip -q cmdline-tools.zip -d "$ANDROID_SDK_ROOT/cmdline-tools"
|
||||
mv "$ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools" "$ANDROID_SDK_ROOT/cmdline-tools/latest"
|
||||
fi
|
||||
yes | "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --sdk_root="$ANDROID_SDK_ROOT" "platform-tools" "platforms;android-${ANDROID_PLATFORM_API}" "build-tools;${ANDROID_BUILD_TOOLS_VERSION}"
|
||||
|
||||
|
||||
- name: Cache Android NDK r14b
|
||||
id: cache-android-ndk
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ github.workspace }}/android-ndk-r14b
|
||||
key: android-ndk-r14b
|
||||
|
||||
- name: Install Android NDK r14b
|
||||
if: steps.cache-android-ndk.outputs.cache-hit != 'true'
|
||||
run: |
|
||||
if [ ! -d "$ANDROID_NDK_PATH" ]; then
|
||||
curl -L -o ndk.zip "https://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zip"
|
||||
unzip -q ndk.zip -d "$GITHUB_WORKSPACE"
|
||||
fi
|
||||
|
||||
- name: Install system prerequisites
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y --no-install-recommends wget unzip curl git python3 libncurses6 libtinfo6
|
||||
if ! ldconfig -p | grep -q "libncurses.so.5"; then
|
||||
sudo ln -sf /lib/x86_64-linux-gnu/libncurses.so.6 /usr/lib/x86_64-linux-gnu/libncurses.so.5 || true
|
||||
fi
|
||||
if ! ldconfig -p | grep -q "libtinfo.so.5"; then
|
||||
sudo ln -sf /lib/x86_64-linux-gnu/libtinfo.so.6 /usr/lib/x86_64-linux-gnu/libtinfo.so.5 || true
|
||||
fi
|
||||
|
||||
- name: Setup Java 25
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 25
|
||||
|
||||
- name: Validate environment
|
||||
run: |
|
||||
echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT"
|
||||
echo "ANDROID_NDK_PATH=$ANDROID_NDK_PATH"
|
||||
echo "JAVA_HOME=$JAVA_HOME"
|
||||
echo "MATRIX_ABI=$MATRIX_ABI"
|
||||
$ANDROID_SDK_ROOT/platform-tools/adb version || true
|
||||
java -version
|
||||
javac -version
|
||||
|
||||
- name: Run Android build script
|
||||
run: |
|
||||
chmod +x ./build.sh
|
||||
./build.sh
|
||||
|
||||
- name: Upload APK
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
# artifact name is ABI-specific so both matrix legs can upload without clobbering each other
|
||||
name: minecraftpe-apk-${{ matrix.abi }}
|
||||
path: ${{ github.workspace }}/build-apk/minecraftpe-*-debug.apk
|
||||
|
||||
build-web:
|
||||
name: Build Web
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Setup caches
|
||||
uses: ./.github/actions/setup-cache
|
||||
with:
|
||||
host: linux
|
||||
target: linux
|
||||
|
||||
- name: Setup Ninja
|
||||
uses: ./.github/actions/setup-ninja
|
||||
with:
|
||||
host: linux
|
||||
|
||||
- name: Setup emsdk
|
||||
uses: mymindstorm/setup-emsdk@v14
|
||||
with:
|
||||
version: 5.0.3
|
||||
actions-cache-folder: 'emsdk-cache'
|
||||
|
||||
- name: Create Build Environment
|
||||
# Some projects don't allow in-source building, so create a separate build directory
|
||||
# We'll use this as our working directory for all subsequent commands
|
||||
run: cmake -E make_directory ${{github.workspace}}/build
|
||||
|
||||
- name: Configure CMake
|
||||
# Use a bash shell so we can use the same syntax for environment variable
|
||||
# access regardless of the host operating system
|
||||
shell: bash
|
||||
working-directory: ${{github.workspace}}/build
|
||||
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -G Ninja -DCMAKE_TOOLCHAIN_FILE="$GITHUB_WORKSPACE/emsdk-cache/emsdk-main/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
|
||||
|
||||
- name: Build
|
||||
working-directory: ${{github.workspace}}/build
|
||||
run: cmake --build . --config $BUILD_TYPE --target MinecraftPE --parallel
|
||||
|
||||
- name: Upload Artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mcpe-web
|
||||
path: |
|
||||
${{github.workspace}}/build/MinecraftPE.js
|
||||
${{github.workspace}}/build/MinecraftPE.wasm
|
||||
${{github.workspace}}/build/MinecraftPE.data
|
||||
|
||||
publish:
|
||||
name: Publish
|
||||
runs-on: ubuntu-latest
|
||||
needs: [ build-windows, build-linux, build-android, build-web ]
|
||||
if: github.ref == 'refs/heads/main'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Declare Version Variables
|
||||
id: ref
|
||||
run: |
|
||||
echo "version=$(cat VERSION | xargs)" >> $GITHUB_OUTPUT
|
||||
echo "hash=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Download Artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
|
||||
- name: Zip Windows Artifacts
|
||||
uses: vimtor/action-zip@v1.2
|
||||
with:
|
||||
files: mcpe-windows/MinecraftPE.exe mcpe-windows/libpng16.dll mcpe-windows/OpenAL32.dll mcpe-windows/libz.dll
|
||||
dest: minecraftpe-${{ steps.ref.outputs.hash }}-windows.zip
|
||||
|
||||
- name: Zip Linux Artifacts
|
||||
uses: vimtor/action-zip@v1.2
|
||||
with:
|
||||
files: mcpe-linux/MinecraftPE
|
||||
dest: minecraftpe-${{ steps.ref.outputs.hash }}-linux.zip
|
||||
|
||||
- name: Zip Linux Server Artifacts
|
||||
uses: vimtor/action-zip@v1.2
|
||||
with:
|
||||
files: mcpe-linux/MinecraftPE-server
|
||||
dest: minecraftpe-server-${{ steps.ref.outputs.hash }}.zip
|
||||
|
||||
- name: Zip Android arm64-v8a Artifact
|
||||
uses: vimtor/action-zip@v1.2
|
||||
with:
|
||||
files: minecraftpe-apk-arm64-v8a/minecraftpe-v8a-debug.apk
|
||||
dest: minecraftpe-${{ steps.ref.outputs.hash }}-android-arm64-v8a.zip
|
||||
|
||||
- name: Zip Android armeabi-v7a Artifact
|
||||
uses: vimtor/action-zip@v1.2
|
||||
with:
|
||||
files: minecraftpe-apk-armeabi-v7a/minecraftpe-v7a-debug.apk
|
||||
dest: minecraftpe-${{ steps.ref.outputs.hash }}-android-armeabi-v7a.zip
|
||||
|
||||
- name: Zip Web Artifact
|
||||
uses: vimtor/action-zip@v1.2
|
||||
with:
|
||||
files: mcpe-web/MinecraftPE.js mcpe-web/MinecraftPE.wasm mcpe-web/MinecraftPE.data misc/web/index.html
|
||||
dest: minecraftpe-${{ steps.ref.outputs.hash }}-web.zip
|
||||
|
||||
- name: Zip Data
|
||||
uses: vimtor/action-zip@v1.2
|
||||
with:
|
||||
files: data
|
||||
recursive: false
|
||||
dest: data.zip
|
||||
|
||||
- name: Update Development Release
|
||||
uses: andelf/nightly-release@main
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: dev
|
||||
name: 'Development Release'
|
||||
body: |
|
||||
MinecraftPE development release for commit ${{ github.sha }}.
|
||||
files: |
|
||||
./data.zip
|
||||
./minecraftpe-${{ steps.ref.outputs.hash }}-windows.zip
|
||||
./minecraftpe-${{ steps.ref.outputs.hash }}-linux.zip
|
||||
./minecraftpe-server-${{ steps.ref.outputs.hash }}.zip
|
||||
./minecraftpe-${{ steps.ref.outputs.hash }}-android-arm64-v8a.zip
|
||||
./minecraftpe-${{ steps.ref.outputs.hash }}-android-armeabi-v7a.zip
|
||||
./minecraftpe-${{ steps.ref.outputs.hash }}-web.zip
|
||||
75
.github/workflows/cmake-multiplatform.yml
vendored
Normal file
75
.github/workflows/cmake-multiplatform.yml
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
name: CMake multiplatform
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
pull_request:
|
||||
branches: [ "main" ]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
build_type: [Release]
|
||||
include:
|
||||
- os: windows-latest
|
||||
c_compiler: clang
|
||||
cpp_compiler: clang++
|
||||
- os: ubuntu-latest
|
||||
c_compiler: clang
|
||||
cpp_compiler: clang++
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set reusable strings
|
||||
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
|
||||
id: strings
|
||||
shell: bash
|
||||
run: |
|
||||
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Setup Environment
|
||||
if: ${{ matrix.os == 'ubuntu-latest' }}
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install gcc-multilib
|
||||
sudo apt-get install -y --no-install-recommends build-essential libgl-dev libwayland-dev xorg-dev libxkbcommon-dev
|
||||
|
||||
- name: Configure CMake
|
||||
run: >
|
||||
cmake -B ${{ steps.strings.outputs.build-output-dir }}
|
||||
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
|
||||
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
|
||||
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
|
||||
-S ${{ github.workspace }}
|
||||
|
||||
- name: Build
|
||||
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
|
||||
|
||||
- name: Install
|
||||
run: cmake --install ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
|
||||
|
||||
- name: Pack
|
||||
run: |
|
||||
cd ${{ steps.strings.outputs.build-output-dir }}
|
||||
cpack -C ${{ matrix.build_type }}
|
||||
|
||||
- name: Create or Update Development Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
name: Development Build
|
||||
tag_name: dev
|
||||
body: |
|
||||
${{ github.event.head_commit.timestamp }}
|
||||
draft: false
|
||||
prerelease: true
|
||||
generate_release_notes: false
|
||||
files: 'build/package/*.zip'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -3,12 +3,13 @@ build/
|
||||
out/
|
||||
bin/
|
||||
lib/
|
||||
build-apk/
|
||||
cmake-build-*/
|
||||
CMakeFiles/
|
||||
CMakeCache.txt
|
||||
cmake_install.cmake
|
||||
Makefile
|
||||
*.cmake
|
||||
!cmake/CPM.cmake
|
||||
|
||||
# Compiled object files
|
||||
*.o
|
||||
|
||||
342
CMakeLists.txt
342
CMakeLists.txt
@@ -6,148 +6,86 @@ include(cmake/CPM.cmake)
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||
set(CMAKE_POLICY_VERSION_MINIMUM 3.10)
|
||||
|
||||
include(cmake/EnumOption.cmake)
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
# When configuring web builds with "emcmake cmake -B build -S .", set PLATFORM to Web by default
|
||||
set(PLATFORM Web CACHE STRING "Platform to build for.")
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
set(CMAKE_CXX_FLAGS "-Wno-c++11-narrowing -Wno-narrowing -Wno-invalid-source-encoding -Wno-reserved-user-defined-literal")
|
||||
endif()
|
||||
|
||||
enum_option(PLATFORM "Desktop;Web" "Platform to build for.")
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
find_package(OpenSSL)
|
||||
|
||||
if (${PLATFORM} STREQUAL "Desktop")
|
||||
set(PLATFORM_CPP "PLATFORM_DESKTOP")
|
||||
|
||||
if (MINGW)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc")
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++11-narrowing -Wno-narrowing -Wno-invalid-source-encoding -Wno-reserved-user-defined-literal")
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
include_directories(misc/windows)
|
||||
set(EXTRA_LIBS ws2_32 winhttp)
|
||||
elseif(UNIX)
|
||||
find_library(pthread NAMES pthread)
|
||||
set(EXTRA_LIBS pthread m)
|
||||
endif()
|
||||
|
||||
include_directories("glad/include")
|
||||
|
||||
elseif (${PLATFORM} STREQUAL "Web")
|
||||
set(PLATFORM_CPP "PLATFORM_WEB")
|
||||
set(EXTRA_LIBS "idbfs.js")
|
||||
if (OpenSSL_FOUND)
|
||||
message(STATUS "found openssl ${OPENSSL_VERSION}")
|
||||
endif()
|
||||
|
||||
# I totally shocked
|
||||
if(${PLATFORM} MATCHES "Web")
|
||||
set(PNG_LIB png)
|
||||
set(AL_LIBTYPE "STATIC")
|
||||
|
||||
add_library(zlib INTERFACE IMPORTED)
|
||||
set_target_properties(zlib PROPERTIES
|
||||
INTERFACE_LINK_OPTIONS "-sUSE_ZLIB=1"
|
||||
)
|
||||
|
||||
add_library(png INTERFACE IMPORTED)
|
||||
set_target_properties(png PROPERTIES
|
||||
INTERFACE_COMPILE_OPTIONS "-sUSE_LIBPNG=1"
|
||||
INTERFACE_LINK_OPTIONS "-sUSE_LIBPNG=1"
|
||||
)
|
||||
|
||||
add_library(glfw INTERFACE IMPORTED)
|
||||
set_target_properties(glfw PROPERTIES
|
||||
INTERFACE_LINK_OPTIONS "-sUSE_GLFW=3"
|
||||
)
|
||||
else()
|
||||
set(PNG_LIB png_shared)
|
||||
set(AL_LIBTYPE "SHARED")
|
||||
|
||||
CPMAddPackage(
|
||||
NAME "zlib"
|
||||
GIT_REPOSITORY "https://github.com/madler/zlib"
|
||||
GIT_TAG "v1.3.2"
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME "libpng"
|
||||
GIT_REPOSITORY "https://github.com/pnggroup/libpng.git"
|
||||
GIT_TAG "v1.6.55"
|
||||
OPTIONS
|
||||
"ZLIB_ROOT ${zlib_SOURCE_DIR}"
|
||||
"ZLIB_INCLUDE_DIRS ${zlib_SOURCE_DIR}"
|
||||
"PNG_TOOLS OFF"
|
||||
"PNG_TESTS OFF"
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME "glfw"
|
||||
GIT_REPOSITORY "https://github.com/glfw/glfw.git"
|
||||
GIT_TAG "3.4"
|
||||
EXCLUDE_FROM_ALL TRUE
|
||||
OPTIONS
|
||||
"GLFW_BUILD_EXAMPLES OFF"
|
||||
"GLFW_BUILD_TESTS OFF"
|
||||
"GLFW_BUILD_DOCS OFF"
|
||||
)
|
||||
endif()
|
||||
CPMAddPackage("gh:madler/zlib@1.3.2")
|
||||
CPMAddPackage(
|
||||
NAME "libpng"
|
||||
GIT_REPOSITORY "https://github.com/pnggroup/libpng.git"
|
||||
GIT_TAG "v1.6.55"
|
||||
EXCLUDE_FROM_ALL TRUE
|
||||
OPTIONS
|
||||
"ZLIB_ROOT ${zlib_SOURCE_DIR}"
|
||||
"ZLIB_INCLUDE_DIRS ${zlib_SOURCE_DIR}"
|
||||
"PNG_TOOLS OFF"
|
||||
"PNG_TESTS OFF"
|
||||
"BUILD_SHARED_LIBS ON"
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME "openal"
|
||||
GIT_REPOSITORY "https://github.com/kcat/openal-soft.git"
|
||||
GIT_TAG "1.25.1"
|
||||
EXCLUDE_FROM_ALL TRUE
|
||||
OPTIONS
|
||||
"ALSOFT_EXAMPLES OFF"
|
||||
"ALSOFT_TESTS OFF"
|
||||
"ALSOFT_UTILS OFF"
|
||||
"LIBTYPE ${AL_LIBTYPE}"
|
||||
"ALSOFT_ENABLE_MODULES OFF"
|
||||
"ALSOFT_STATIC_STDCXX ON"
|
||||
"ALSOFT_STATIC_LIBGCC ON"
|
||||
"BUILD_SHARED_LIBS ON"
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME "glfw"
|
||||
GIT_REPOSITORY "https://github.com/glfw/glfw.git"
|
||||
GIT_TAG "3.4"
|
||||
EXCLUDE_FROM_ALL TRUE
|
||||
OPTIONS
|
||||
"GLFW_BUILD_EXAMPLES OFF"
|
||||
"GLFW_BUILD_TESTS OFF"
|
||||
"GLFW_BUILD_DOCS OFF"
|
||||
"BUILD_SHARED_LIBS ON"
|
||||
)
|
||||
|
||||
# TODO: Clear this paths with *
|
||||
file(GLOB SERVER_SOURCES
|
||||
"project/lib_projects/raknet/jni/RaknetSources/*.cpp"
|
||||
"src/NinecraftApp.cpp"
|
||||
"src/Performance.cpp"
|
||||
"src/SharedConstants.cpp"
|
||||
"src/Minecraft.cpp"
|
||||
"src/MinecraftServer.cpp"
|
||||
"src/App.cpp"
|
||||
"src/IPlatform.cpp"
|
||||
|
||||
"src/client/IConfigListener.cpp"
|
||||
"src/client/Minecraft.cpp"
|
||||
"src/client/OptionStrings.cpp"
|
||||
"src/client/Option.cpp"
|
||||
"src/client/Options.cpp"
|
||||
"src/client/OptionsFile.cpp"
|
||||
"src/client/ServerProfiler.cpp"
|
||||
|
||||
# "src/client/IConfigListener.cpp"
|
||||
# "src/client/Minecraft.cpp"
|
||||
# "src/client/OptionStrings.cpp"
|
||||
# "src/client/Option.cpp"
|
||||
# "src/client/Options.cpp"
|
||||
# "src/client/OptionsFile.cpp"
|
||||
# "src/client/ServerProfiler.cpp"
|
||||
"src/client/gamemode/CreativeMode.cpp"
|
||||
"src/client/gamemode/GameMode.cpp"
|
||||
"src/client/gamemode/SurvivalMode.cpp"
|
||||
|
||||
# "src/client/gamemode/CreativeMode.cpp"
|
||||
# "src/client/gamemode/GameMode.cpp"
|
||||
# "src/client/gamemode/SurvivalMode.cpp"
|
||||
|
||||
# "src/client/player/LocalPlayer.cpp"
|
||||
# "src/client/player/RemotePlayer.cpp"
|
||||
# "src/client/player/input/KeyboardInput.cpp"
|
||||
|
||||
"src/gamemode/*.cpp"
|
||||
"src/client/player/LocalPlayer.cpp"
|
||||
"src/client/player/RemotePlayer.cpp"
|
||||
"src/client/player/input/KeyboardInput.cpp"
|
||||
|
||||
"src/locale/I18n.cpp"
|
||||
|
||||
"src/main.cpp"
|
||||
"src/main_dedicated.cpp"
|
||||
|
||||
"src/nbt/Tag.cpp"
|
||||
|
||||
"src/network/ClientSideNetworkHandler.cpp"
|
||||
"src/network/NetEventCallback.cpp"
|
||||
"src/network/Packet.cpp"
|
||||
"src/network/RakNetInstance.cpp"
|
||||
@@ -158,7 +96,11 @@ file(GLOB SERVER_SOURCES
|
||||
"src/platform/HttpClient.cpp"
|
||||
"src/platform/PngLoader.cpp"
|
||||
"src/platform/time.cpp"
|
||||
"src/platform/server/PlatformServer.cpp"
|
||||
|
||||
"src/platform/input/Controller.cpp"
|
||||
"src/platform/input/Keyboard.cpp"
|
||||
"src/platform/input/Mouse.cpp"
|
||||
"src/platform/input/Multitouch.cpp"
|
||||
|
||||
"src/server/ArgumentsSettings.cpp"
|
||||
"src/server/ServerLevel.cpp"
|
||||
@@ -292,32 +234,50 @@ file(GLOB CLIENT_SOURCES
|
||||
"src/SharedConstants.cpp"
|
||||
"src/main.cpp"
|
||||
"src/NinecraftApp.cpp"
|
||||
|
||||
"src/AppPlatform_glfw.cpp"
|
||||
"src/main.cpp"
|
||||
)
|
||||
|
||||
if (${PLATFORM} STREQUAL "Desktop")
|
||||
list(APPEND CLIENT_SOURCES glad/src/glad.c)
|
||||
if(NOT DEFINED PLATFORM)
|
||||
set(PLATFORM "PLATFORM_GLFW")
|
||||
endif()
|
||||
|
||||
|
||||
if(PLATFORM STREQUAL "PLATFORM_WIN32")
|
||||
list(APPEND CLIENT_SOURCES "src/AppPlatform_win32.cpp")
|
||||
endif()
|
||||
|
||||
if(PLATFORM STREQUAL "PLATFORM_GLFW")
|
||||
list(APPEND CLIENT_SOURCES "src/AppPlatform_glfw.cpp")
|
||||
endif()
|
||||
|
||||
# Server
|
||||
if(UNIX)
|
||||
add_executable("${PROJECT_NAME}-server" ${SERVER_SOURCES})
|
||||
add_executable("${PROJECT_NAME}-server" ${SERVER_SOURCES})
|
||||
|
||||
target_compile_definitions("${PROJECT_NAME}-server" PUBLIC "STANDALONE_SERVER" "SERVER_PROFILER")
|
||||
target_compile_definitions("${PROJECT_NAME}-server" PUBLIC "STANDALONE_SERVER" "SERVER_PROFILER")
|
||||
|
||||
target_include_directories("${PROJECT_NAME}-server" PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/src/"
|
||||
"project/lib_projects/raknet/jni/RaknetSources"
|
||||
)
|
||||
target_include_directories("${PROJECT_NAME}-server" PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/src/"
|
||||
"project/lib_projects/raknet/jni/RaknetSources"
|
||||
)
|
||||
|
||||
target_link_libraries("${PROJECT_NAME}-server" ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_link_libraries("${PROJECT_NAME}-server" ${CMAKE_THREAD_LIBS_INIT} png_shared)
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
${CLIENT_SOURCES}
|
||||
"glad/src/glad.c"
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
set(EXTRA_LIBS "ws2_32")
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "_CRT_SECURE_NO_WARNINGS")
|
||||
endif()
|
||||
|
||||
if(PLATFORM STREQUAL "PLATFORM_WIN32" OR PLATFORM STREQUAL "PLATFORM_GLFW")
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "PLATFORM_DESKTOP")
|
||||
endif()
|
||||
|
||||
add_executable(${PROJECT_NAME} ${CLIENT_SOURCES})
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC ${PLATFORM_CPP})
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/glad/include/"
|
||||
@@ -327,52 +287,9 @@ target_include_directories(${PROJECT_NAME} PUBLIC
|
||||
"lib/include"
|
||||
)
|
||||
|
||||
if(${PLATFORM} MATCHES "Web")
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
# uuuh i hate it
|
||||
set(EM_FLAGS "-pthread -sUSE_PTHREADS=1 -sUSE_LIBPNG=1 -sSHARED_MEMORY=1")
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EM_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EM_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EM_FLAGS} --preload-file ${CMAKE_SOURCE_DIR}/data@/data")
|
||||
|
||||
target_compile_options(${PROJECT_NAME} PUBLIC
|
||||
"-Os"
|
||||
"-Wno-invalid-source-encoding"
|
||||
"-Wno-narrowing"
|
||||
"-Wno-deprecated-register"
|
||||
"-Wno-reserved-user-defined-literal"
|
||||
)
|
||||
|
||||
target_link_options(${PROJECT_NAME} PUBLIC
|
||||
"-Os"
|
||||
"-sALLOW_MEMORY_GROWTH=1"
|
||||
"-sFORCE_FILESYSTEM=1"
|
||||
"-sLEGACY_GL_EMULATION=1"
|
||||
"-sGL_UNSAFE_OPTS=0"
|
||||
"-sEMULATE_FUNCTION_POINTER_CASTS=1"
|
||||
"-sALLOW_TABLE_GROWTH=1"
|
||||
"-sEXPORTED_RUNTIME_METHODS=['FS','stringToUTF8','UTF8ToString','cwrap','ccall','HEAP8','HEAPU8','HEAP32','HEAPU32']"
|
||||
"-sEXPORTED_FUNCTIONS=['_main']"
|
||||
)
|
||||
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
message("DEBUG MODE")
|
||||
|
||||
target_link_options(${PROJECT_NAME} PUBLIC
|
||||
"-sASSERTIONS=2"
|
||||
"-sSTACK_OVERFLOW_CHECK=2"
|
||||
"-sSTACK_SIZE=5242880"
|
||||
"-sGL_DEBUG=1"
|
||||
)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "__EMSCRIPTEN__" "NO_SOUND" "NO_NETWORK")
|
||||
endif()
|
||||
|
||||
# Client
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "OPENGL_ES" "NO_EGL" "${PLATFORM_CPP}")
|
||||
target_link_libraries(${PROJECT_NAME} zlib ${PNG_LIB} OpenAL::OpenAL glfw ${EXTRA_LIBS})
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "OPENGL_ES" "NO_EGL" ${PLATFORM})
|
||||
target_link_libraries(${PROJECT_NAME} zlib png_shared alsoft.common OpenAL::OpenAL glfw ${EXTRA_LIBS})
|
||||
|
||||
if (OpenSSL_FOUND)
|
||||
target_link_libraries(${PROJECT_NAME} OpenSSL::SSL OpenSSL::Crypto)
|
||||
@@ -380,27 +297,72 @@ if (OpenSSL_FOUND)
|
||||
endif()
|
||||
|
||||
if (NOT UNIX)
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_RUNTIME_DLLS:${PROJECT_NAME}> $<TARGET_FILE_DIR:${PROJECT_NAME}>
|
||||
COMMAND_EXPAND_LISTS
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_RUNTIME_DLLS:${PROJECT_NAME}> $<TARGET_FILE_DIR:${PROJECT_NAME}>
|
||||
COMMAND_EXPAND_LISTS
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT ${PLATFORM} MATCHES "Web")
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/data" $<TARGET_FILE_DIR:${PROJECT_NAME}>/data
|
||||
)
|
||||
else()
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/misc/web/index.html" $<TARGET_FILE_DIR:${PROJECT_NAME}>
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET ${PROJECT_NAME}
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/data" $<TARGET_FILE_DIR:${PROJECT_NAME}>/data
|
||||
)
|
||||
|
||||
# Installing and packing
|
||||
|
||||
find_package(Git REQUIRED)
|
||||
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} log -1 --format=%h
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_SHORTSHA
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME)
|
||||
set(CPACK_PACKAGE_NAME "MCPE-0.6.1-for-all")
|
||||
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${SYSTEM_NAME})
|
||||
set(CPACK_PACKAGE_VENDOR "MCPE-0.6.1-for-all")
|
||||
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
|
||||
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/package")
|
||||
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install")
|
||||
set(CPACK_GENERATOR "ZIP")
|
||||
|
||||
set(GIT_REPO "https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1")
|
||||
|
||||
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION .)
|
||||
|
||||
if(NOT UNIX)
|
||||
install(FILES
|
||||
$<TARGET_RUNTIME_DLLS:${PROJECT_NAME}>
|
||||
DESTINATION .
|
||||
)
|
||||
endif()
|
||||
|
||||
message(STATUS "Compiling with the flags:")
|
||||
message(STATUS " PLATFORM=" ${PLATFORM_CPP})
|
||||
install(DIRECTORY "${CMAKE_SOURCE_DIR}/data" DESTINATION .)
|
||||
|
||||
string(TIMESTAMP CURRENT_DATE "%Y-%m-%d")
|
||||
string(TIMESTAMP CURRENT_TIME "%H:%M:%S")
|
||||
|
||||
set(VERSION_STR "${PROJECT_VERSION}")
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
set(VERSION_STR "${VERSION_STR} - Development Build")
|
||||
endif()
|
||||
|
||||
file(WRITE "${CMAKE_BINARY_DIR}/version.txt"
|
||||
"Minecraft PE 0.6.1
|
||||
|
||||
Autogenerated file by cmake-${CMAKE_VERSION}
|
||||
Report issues ${GIT_REPO}/issues
|
||||
|
||||
Build date: ${CURRENT_DATE} ${CURRENT_TIME}
|
||||
Build configuration: ${CMAKE_BUILD_TYPE}
|
||||
Git commit: ${GIT_SHORTSHA}
|
||||
Platform: ${CMAKE_SYSTEM_NAME}")
|
||||
|
||||
install(FILES "${CMAKE_BINARY_DIR}/version.txt" DESTINATION .)
|
||||
|
||||
include(CPack)
|
||||
109
README.md
109
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
|
||||
- [x] Do a server connection GUI
|
||||
- [ ] Do a server connection GUI
|
||||
- [ ] Controller support
|
||||
- [x] Minecraft server hosting
|
||||
- [ ] 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
|
||||
|
||||
@@ -95,106 +95,3 @@ cmake --build .
|
||||
# Only repackage + install (no compilation)
|
||||
.\build.ps1 -NoBuild
|
||||
```
|
||||
|
||||
### 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`
|
||||
|
||||
## Web
|
||||
1. Download and install **emsdk**: https://emscripten.org/docs/getting_started/downloads.html
|
||||
> [!Note]
|
||||
> On arch linux you can use AUR:
|
||||
> `yay -Sy emsdk`
|
||||
|
||||
2. Configure and build project:
|
||||
```
|
||||
mkdir build && cd build
|
||||
cmake .. -B . -G Ninja "-DCMAKE_TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
|
||||
cmake --build . --target MinecraftPE
|
||||
```
|
||||
> [!Note]
|
||||
> If you are using VSCode with CMake plugin, you can add Emscripten kit
|
||||
> 1. Press Ctrl + Shift + P
|
||||
> 2. Type `CMake: Edit User-Local CMake Kits` and hit Enter
|
||||
> 3. Add this:
|
||||
```json
|
||||
{
|
||||
"name": "Emscripten",
|
||||
"compilers": {
|
||||
"C": "/usr/lib/emsdk/upstream/bin/clang",
|
||||
"CXX": "/usr/lib/emsdk/upstream/bin/clang++"
|
||||
},
|
||||
"toolchainFile": "/usr/lib/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
|
||||
}
|
||||
```
|
||||
3. Run game:
|
||||
```
|
||||
emrun --port 8080 .
|
||||
```
|
||||
52
build.ps1
52
build.ps1
@@ -1,16 +1,18 @@
|
||||
# ============================================================
|
||||
# MCPE 0.6.1 Android Build Script — from-scratch capable
|
||||
# Works on a clean machine; creates all dirs, keystore and
|
||||
# stub Java files automatically.
|
||||
#
|
||||
# Usage:
|
||||
# .\build.ps1 # full build (NDK + Java + APK + install)
|
||||
# .\build.ps1 -NoCpp # skip NDK rebuild (Java/assets changed)
|
||||
# .\build.ps1 -NoJava # skip Java recompile (C++ changed only)
|
||||
# .\build.ps1 -NoBuild # repackage + install only (no recompile)
|
||||
# .\build.ps1 -Clean # remove build output before building
|
||||
# .\build.ps1 # full build (NDK + Java + APK + install)
|
||||
# .\build.ps1 -NoCpp # skip NDK rebuild (Java/assets changed)
|
||||
# .\build.ps1 -NoJava # skip Java recompile (C++ changed only)
|
||||
# .\build.ps1 -NoBuild # repackage + install only (no recompile)
|
||||
# ============================================================
|
||||
param(
|
||||
[switch]$NoCpp,
|
||||
[switch]$NoJava,
|
||||
[switch]$NoBuild,
|
||||
[switch]$Clean
|
||||
[switch]$NoBuild
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
@@ -64,13 +66,7 @@ function Write-Stub([string]$rel, [string]$content) {
|
||||
if (-not (Test-Path $full)) { [System.IO.File]::WriteAllText($full, $content); Write-Host " stub: $rel" }
|
||||
}
|
||||
|
||||
# ── 0. Clean (optional) ───────────────────────────────────────
|
||||
if ($Clean) {
|
||||
Write-Step "Cleaning build output"
|
||||
Remove-Item -Recurse -Force $apkbuild -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
# ── 1. Bootstrap ─────────────────────────────────────────────
|
||||
# ── 0. Bootstrap ─────────────────────────────────────────────
|
||||
Write-Step "Bootstrap"
|
||||
|
||||
New-Dir $apkbuild
|
||||
@@ -231,16 +227,16 @@ if (-not $NoCpp -and -not $NoBuild) {
|
||||
}
|
||||
Push-Location "$junctionBase/project/android/jni"
|
||||
$env:NDK_MODULE_PATH = "$junctionBase/project/lib_projects"
|
||||
# run ndk-build and stream output directly to the console
|
||||
$ndkCmd = Join-Path $ndk 'ndk-build.cmd'
|
||||
$ndkArgs = "NDK_PROJECT_PATH=`"$junctionBase/project/android`" APP_BUILD_SCRIPT=`"$junctionBase/project/android/jni/Android.mk`""
|
||||
|
||||
$proc = Start-Process -FilePath $ndkCmd -ArgumentList $ndkArgs -NoNewWindow -Wait -PassThru
|
||||
# run ndk-build and capture everything; let user see full output for debugging
|
||||
$ndkOutput = & "$ndk\ndk-build.cmd" NDK_PROJECT_PATH="$junctionBase/project/android" APP_BUILD_SCRIPT="$junctionBase/project/android/jni/Android.mk" 2>&1 | Tee-Object -Variable ndkOutput
|
||||
# dump entire output for diagnosis
|
||||
Write-Host "---- NDK BUILD OUTPUT BEGIN ----"
|
||||
$ndkOutput | ForEach-Object { Write-Host $_ }
|
||||
Write-Host "---- NDK BUILD OUTPUT END ----"
|
||||
# optionally highlight errors/warnings afterwards
|
||||
$ndkOutput | Where-Object { $_ -match "error:|warning:|libminecraftpe|In file included" }
|
||||
Pop-Location
|
||||
if ($proc.ExitCode -ne 0) {
|
||||
Write-Host "ndk-build failed (exit $($proc.ExitCode))" -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
Assert-ExitCode "ndk-build"
|
||||
Copy-Item $libSrc $libDst -Force
|
||||
Write-Host " .so -> $libDst"
|
||||
}
|
||||
@@ -250,7 +246,7 @@ if (-not $NoJava -and -not $NoBuild) {
|
||||
Write-Step "Java compile"
|
||||
|
||||
New-Dir (Split-Path $rJava -Parent)
|
||||
& "$sdkTools\aapt.exe" package -f -M $manifest -S $res -I $androidJar -J "$apkbuild\gen" -F "$apkbuild\_rgen.apk"
|
||||
& "$sdkTools\aapt.exe" package -f -M $manifest -S $res -I $androidJar -J "$apkbuild\gen" -F "$apkbuild\_rgen.apk" 2>&1 | Out-Null
|
||||
Assert-ExitCode "aapt R.java"
|
||||
Remove-Item "$apkbuild\_rgen.apk" -ea SilentlyContinue
|
||||
|
||||
@@ -262,9 +258,11 @@ if (-not $NoJava -and -not $NoBuild) {
|
||||
|
||||
Remove-Item $classesDir -Recurse -Force -ea SilentlyContinue
|
||||
New-Dir $classesDir
|
||||
|
||||
& javac --release 8 -cp $androidJar -d $classesDir @srcs
|
||||
if ($LASTEXITCODE -ne 0) { Write-Host 'javac failed' -ForegroundColor Red; exit 1 }
|
||||
$eap = $ErrorActionPreference; $ErrorActionPreference = "Continue"
|
||||
$errors = & javac --release 8 -cp $androidJar -d $classesDir @srcs 2>&1 |
|
||||
Where-Object { $_ -match "error:" }
|
||||
$ErrorActionPreference = $eap
|
||||
if ($errors) { Write-Host $errors -ForegroundColor Red; exit 1 }
|
||||
Write-Host " javac OK"
|
||||
|
||||
$classFiles = Get-ChildItem $classesDir -Recurse -Filter "*.class" | Select-Object -Exp FullName
|
||||
|
||||
455
build.sh
455
build.sh
@@ -1,455 +0,0 @@
|
||||
#!/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)
|
||||
#
|
||||
# ABI targeting:
|
||||
# ./build.sh --abi arm64-v8a # build for arm64 only (default)
|
||||
# ./build.sh --abi armeabi-v7a # build for ARMv7 only
|
||||
# ./build.sh --abi all # build for both ABIs (fat APK)
|
||||
# ============================================================
|
||||
|
||||
# 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:-}"
|
||||
|
||||
# ABI selection: can be set via --abi flag or MATRIX_ABI env var.
|
||||
# Supported values: arm64-v8a, armeabi-v7a, all
|
||||
# MATRIX_ABI takes precedence over the default but is overridden by --abi on the CLI.
|
||||
TARGET_ABI="${MATRIX_ABI:-arm64-v8a}"
|
||||
|
||||
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 names are derived after argument parsing once TARGET_ABI is final.
|
||||
# see the "resolve APK output filenames" block below.
|
||||
APK_UNSIGNED=""
|
||||
APK_ALIGNED=""
|
||||
APK_SIGNED=""
|
||||
DEX_OUTPUT="$BUILD_DIR/classes.dex"
|
||||
|
||||
# flags parsed from CLI args
|
||||
NO_CPP=false
|
||||
NO_JAVA=false
|
||||
NO_BUILD=false
|
||||
|
||||
########################################
|
||||
# helpers
|
||||
########################################
|
||||
function usage() {
|
||||
cat <<EOF
|
||||
Usage: $0 [--no-cpp] [--no-java] [--no-build] [--abi <abi>]
|
||||
|
||||
Options:
|
||||
--no-cpp Skip the NDK (C++) build step
|
||||
--no-java Skip the Java build step
|
||||
--no-build Skip the compile steps; just package + install
|
||||
--abi <abi> Target ABI: arm64-v8a (default), armeabi-v7a, or all
|
||||
Can also be set via MATRIX_ABI env var for CI matrix builds.
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
|
||||
function log_step() {
|
||||
echo -e "\n==> $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
|
||||
}
|
||||
|
||||
function build_ndk_abi() {
|
||||
local abi="$1"
|
||||
|
||||
# armeabi-v7a needs a few extra NDK flags to get hardware FPU support
|
||||
# without APP_ABI the default would be whatever Android.mk says, so we
|
||||
# always pass it explicitly so the same Android.mk works for both targets
|
||||
local -a extra_flags=( "APP_ABI=$abi" )
|
||||
if [[ "$abi" == "armeabi-v7a" ]]; then
|
||||
# enable hardware FPU + NEON like the old Minecraft ARMv7 builds used to
|
||||
extra_flags+=( "APP_ARM_MODE=arm" "APP_ARM_NEON=true" )
|
||||
fi
|
||||
|
||||
echo " ndk-build for $abi..."
|
||||
if ! "$ANDROID_NDK_PATH/ndk-build" \
|
||||
NDK_PROJECT_PATH="$REPO_ROOT/project/android" \
|
||||
APP_BUILD_SCRIPT="$JNI_DIR/Android.mk" \
|
||||
"${extra_flags[@]}" \
|
||||
2>&1 | tee "$BUILD_DIR/ndk-build-${abi}.log"; then
|
||||
echo "NDK build failed for $abi. See $BUILD_DIR/ndk-build-${abi}.log" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ensure_dir "$BUILD_DIR/lib/$abi"
|
||||
cp -v "$REPO_ROOT/project/android/libs/$abi/libminecraftpe.so" "$BUILD_DIR/lib/$abi/"
|
||||
echo " .so -> $BUILD_DIR/lib/$abi/libminecraftpe.so"
|
||||
}
|
||||
|
||||
########################################
|
||||
# argument parsing
|
||||
########################################
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--no-cpp) NO_CPP=true ;;
|
||||
--no-java) NO_JAVA=true ;;
|
||||
--no-build) NO_BUILD=true ;;
|
||||
--abi)
|
||||
shift
|
||||
[[ $# -gt 0 ]] || fail "--abi requires a value (arm64-v8a, armeabi-v7a, all)"
|
||||
TARGET_ABI="$1"
|
||||
;;
|
||||
-h|--help) usage ;;
|
||||
*)
|
||||
echo "Unknown option: $1" >&2
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# validate the ABI value now that all args are parsed
|
||||
case "$TARGET_ABI" in
|
||||
arm64-v8a|armeabi-v7a|all) ;;
|
||||
*) fail "Unknown ABI '$TARGET_ABI'. Supported values: arm64-v8a, armeabi-v7a, all" ;;
|
||||
esac
|
||||
|
||||
echo " TARGET_ABI=$TARGET_ABI"
|
||||
|
||||
# resolve APK output filenames now that TARGET_ABI is final.
|
||||
# arm64-v8a -> minecraftpe-v8a-debug.apk
|
||||
# armeabi-v7a -> minecraftpe-v7a-debug.apk
|
||||
# all -> minecraftpe-all-debug.apk (fat APK containing both ABIs)
|
||||
case "$TARGET_ABI" in
|
||||
arm64-v8a) APK_SUFFIX="v8a" ;;
|
||||
armeabi-v7a) APK_SUFFIX="v7a" ;;
|
||||
*) APK_SUFFIX="$TARGET_ABI" ;;
|
||||
esac
|
||||
APK_UNSIGNED="$BUILD_DIR/minecraftpe-${APK_SUFFIX}-unsigned.apk"
|
||||
APK_ALIGNED="$BUILD_DIR/minecraftpe-${APK_SUFFIX}-aligned.apk"
|
||||
APK_SIGNED="$BUILD_DIR/minecraftpe-${APK_SUFFIX}-debug.apk"
|
||||
|
||||
########################################
|
||||
# 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/lib/armeabi-v7a"
|
||||
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;i<s.length();i++){char c=s.charAt(i);if(c<128)sb.append(c);}\n return sb.toString();\n }\n}\n"
|
||||
|
||||
write_stub_file "com/mojang/android/preferences/SliderPreference.java" "package com.mojang.android.preferences;\nimport android.content.Context;\nimport android.content.res.Resources;\nimport android.preference.DialogPreference;\nimport android.util.AttributeSet;\nimport android.view.Gravity;\nimport android.view.View;\nimport android.widget.LinearLayout;\nimport android.widget.SeekBar;\nimport android.widget.TextView;\npublic class SliderPreference extends DialogPreference implements SeekBar.OnSeekBarChangeListener {\n private static final String NS=\"http://schemas.android.com/apk/res/android\";\n private Context _ctx; private TextView _tv; private SeekBar _sb;\n private String _suf; private int _def,_max,_val,_min;\n public SliderPreference(Context ctx,AttributeSet a){\n super(ctx,a); _ctx=ctx;\n _suf=gStr(a,NS,\"text\",\"\"); _def=gInt(a,NS,\"defaultValue\",0);\n _max=gInt(a,NS,\"max\",100); _min=gInt(a,null,\"min\",0);\n setDefaultValue(_def);\n }\n @Override protected View onCreateDialogView(){\n LinearLayout l=new LinearLayout(_ctx); l.setOrientation(LinearLayout.VERTICAL); l.setPadding(6,6,6,6);\n _tv=new TextView(_ctx); _tv.setGravity(Gravity.CENTER_HORIZONTAL); _tv.setTextSize(32);\n l.addView(_tv,new LinearLayout.LayoutParams(-1,-2));\n _sb=new SeekBar(_ctx); _sb.setOnSeekBarChangeListener(this);\n l.addView(_sb,new LinearLayout.LayoutParams(-1,-2));\n if(shouldPersist())_val=getPersistedInt(_def);\n _sb.setMax(_max); _sb.setProgress(_val); return l;\n }\n @Override protected void onSetInitialValue(boolean r,Object d){\n super.onSetInitialValue(r,d);\n _val=r?(shouldPersist()?getPersistedInt(_def):0):(Integer)d;\n }\n public void onProgressChanged(SeekBar s,int v,boolean f){\n _val=v+_min; _tv.setText(_val+_suf);\n if(shouldPersist())persistInt(_val); callChangeListener(Integer.valueOf(_val));\n }\n public void onStartTrackingTouch(SeekBar s){}\n public void onStopTrackingTouch(SeekBar s){}\n private int gInt(AttributeSet a,String ns,String n,int d){int id=a.getAttributeResourceValue(ns,n,0);return id!=0?getContext().getResources().getInteger(id):a.getAttributeIntValue(ns,n,d);}\n private String gStr(AttributeSet a,String ns,String n,String d){int id=a.getAttributeResourceValue(ns,n,0);if(id!=0)return getContext().getResources().getString(id);String v=a.getAttributeValue(ns,n);return v!=null?v:d;}\n}\n"
|
||||
|
||||
write_stub_file "com/mojang/minecraftpe/MainMenuOptionsActivity.java" "package com.mojang.minecraftpe;\nimport android.app.Activity;\npublic class MainMenuOptionsActivity extends Activity {\n public static final String Internal_Game_DifficultyPeaceful=\"internal_game_difficulty_peaceful\";\n public static final String Game_DifficultyLevel=\"game_difficulty\";\n public static final String Controls_Sensitivity=\"controls_sensitivity\";\n}\n"
|
||||
|
||||
write_stub_file "com/mojang/minecraftpe/Minecraft_Market.java" "package com.mojang.minecraftpe;\nimport android.app.Activity; import android.content.Intent; import android.os.Bundle;\npublic class Minecraft_Market extends Activity {\n @Override protected void onCreate(Bundle s){super.onCreate(s);startActivity(new Intent(this,MainActivity.class));finish();}\n}\n"
|
||||
|
||||
write_stub_file "com/mojang/minecraftpe/Minecraft_Market_Demo.java" "package com.mojang.minecraftpe;\nimport android.content.Intent; import android.net.Uri;\npublic class Minecraft_Market_Demo extends MainActivity {\n @Override public void buyGame(){startActivity(new Intent(Intent.ACTION_VIEW,Uri.parse(\"market://details?id=com.mojang.minecraftpe\")));}\n @Override protected boolean isDemo(){return true;}\n}\n"
|
||||
|
||||
write_stub_file "com/mojang/minecraftpe/GameModeButton.java" "package com.mojang.minecraftpe;\nimport com.mojang.android.StringValue;\nimport android.content.Context; import android.util.AttributeSet;\nimport android.view.View; import android.view.View.OnClickListener;\nimport android.widget.TextView; import android.widget.ToggleButton;\npublic class GameModeButton extends ToggleButton implements OnClickListener,StringValue {\n static final int Creative=0,Survival=1;\n private int _type=0; private boolean _attached=false;\n public GameModeButton(Context c,AttributeSet a){super(c,a);setOnClickListener(this);}\n public void onClick(View v){_update();}\n @Override protected void onFinishInflate(){super.onFinishInflate();_update();}\n @Override protected void onAttachedToWindow(){if(!_attached){_update();_attached=true;}}\n private void _update(){_set(isChecked()?Survival:Creative);}\n private void _set(int i){\n _type=i<Creative?Creative:(i>Survival?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=i<Creative?Creative:(i>Survival?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 ($TARGET_ABI)"
|
||||
|
||||
# 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"
|
||||
|
||||
# build each requested ABI by delegating to build_ndk_abi()
|
||||
if [[ "$TARGET_ABI" == "all" ]]; then
|
||||
build_ndk_abi "arm64-v8a"
|
||||
build_ndk_abi "armeabi-v7a"
|
||||
else
|
||||
build_ndk_abi "$TARGET_ABI"
|
||||
fi
|
||||
|
||||
popd >/dev/null
|
||||
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/libraries into apk.
|
||||
# when building for "all" we pack both ABIs into the same APK so Android can
|
||||
# pick the right one at install time (fat APK). for a single-ABI build we
|
||||
# only include the one .so that was actually compiled.
|
||||
pushd "$BUILD_DIR" >/dev/null
|
||||
zip -q "$APK_UNSIGNED" "classes.dex"
|
||||
if [[ "$TARGET_ABI" == "all" ]]; then
|
||||
zip -q "$APK_UNSIGNED" "lib/arm64-v8a/libminecraftpe.so"
|
||||
zip -q "$APK_UNSIGNED" "lib/armeabi-v7a/libminecraftpe.so"
|
||||
else
|
||||
zip -q "$APK_UNSIGNED" "lib/$TARGET_ABI/libminecraftpe.so"
|
||||
fi
|
||||
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!"
|
||||
@@ -1,9 +0,0 @@
|
||||
macro(enum_option var values description)
|
||||
set(${var}_VALUES ${values})
|
||||
list(GET ${var}_VALUES 0 default)
|
||||
set(${var} "${default}" CACHE STRING "${description}")
|
||||
set_property(CACHE ${var} PROPERTY STRINGS ${${var}_VALUES})
|
||||
if (NOT ";${${var}_VALUES};" MATCHES ";${${var}};")
|
||||
message(FATAL_ERROR "Unknown value ${${var}}. Only -D${var}=${${var}_VALUES} allowed.")
|
||||
endif()
|
||||
endmacro()
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 41 KiB After Width: | Height: | Size: 23 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 90 KiB |
@@ -152,8 +152,7 @@ options.group.graphics=Graphics
|
||||
options.group.tweaks=Tweaks
|
||||
options.allowSprint=Allow sprint
|
||||
options.barOnTop=HUD above inventory
|
||||
options.rpiCursor=Show Raspberry PI cursor
|
||||
options.autoJump=Auto Jump
|
||||
options.autojump=Auto Jump
|
||||
options.thirdperson=Third Person
|
||||
options.servervisible=Server Visible
|
||||
options.sensitivity=Sensitivity
|
||||
@@ -182,10 +181,9 @@ options.graphics.fast=Fast
|
||||
options.guiScale=GUI Scale
|
||||
options.guiScale.auto=Auto
|
||||
options.guiScale.small=Small
|
||||
options.guiScale.medium=Medium
|
||||
options.guiScale.normal=Normal
|
||||
options.guiScale.large=Large
|
||||
options.guiScale.larger=Larger
|
||||
options.guiScale.largest=Largest
|
||||
options.advancedOpengl=Advanced OpenGL
|
||||
options.renderClouds=Clouds
|
||||
options.farWarning1=A 64 bit Java installation is recommended
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>MCPE 0.6.1</title>
|
||||
<style>
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
background: black;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#canvas {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<canvas id="canvas"></canvas>
|
||||
|
||||
<script>
|
||||
var Module = {
|
||||
canvas: document.getElementById('canvas'),
|
||||
onRuntimeInitialized: function () { resizeCanvas() }
|
||||
};
|
||||
|
||||
function resizeCanvas() {
|
||||
const canvas = Module.canvas;
|
||||
canvas.width = window.innerWidth;
|
||||
canvas.height = window.innerHeight;
|
||||
}
|
||||
|
||||
window.addEventListener('resize', resizeCanvas);
|
||||
window.addEventListener('onunload', () => {
|
||||
FS.syncfs(true, function (err) { console.log('Sync FS failed: ' + err) });
|
||||
})
|
||||
</script>
|
||||
|
||||
<script src="MinecraftPE.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -6,8 +6,8 @@
|
||||
android:installLocation="preferExternal">
|
||||
|
||||
<!-- This is the platform API where NativeActivity was introduced. -->
|
||||
<uses-sdk android:minSdkVersion="19"
|
||||
android:targetSdkVersion="30" />
|
||||
<uses-sdk android:minSdkVersion="24"
|
||||
android:targetSdkVersion="24" />
|
||||
|
||||
<!-- uses-feature android:name="android.hardware.touchscreen.multitouch" android:required="true"/ -->
|
||||
|
||||
|
||||
@@ -168,10 +168,9 @@ options.graphics.fast=Fast
|
||||
options.guiScale=GUI Scale
|
||||
options.guiScale.auto=Auto
|
||||
options.guiScale.small=Small
|
||||
options.guiScale.medium=Medium
|
||||
options.guiScale.normal=Normal
|
||||
options.guiScale.large=Large
|
||||
options.guiScale.larger=Larger
|
||||
options.guiScale.largest=Largest
|
||||
options.advancedOpengl=Advanced OpenGL
|
||||
options.renderClouds=Clouds
|
||||
options.farWarning1=A 64 bit Java installation is recommended
|
||||
|
||||
@@ -24,7 +24,6 @@ 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 \
|
||||
@@ -38,14 +37,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/KeyOption.cpp \
|
||||
../../../src/client/gui/components/TextOption.cpp \
|
||||
../../../src/client/gui/components/OptionsPane.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 \
|
||||
@@ -257,8 +256,7 @@ 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++14 -frtti
|
||||
LOCAL_CPPFLAGS += -frtti
|
||||
LOCAL_CPPFLAGS := -std=c++11
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../src
|
||||
|
||||
#LOCAL_CFLAGS := -DANDROID_PUBLISH -DDEMO_MODE $(LOCAL_CFLAGS)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
APP_PLATFORM := android-19
|
||||
APP_PLATFORM := android-21
|
||||
APP_STL := gnustl_static
|
||||
APP_OPTIM := release
|
||||
APP_ABI := arm64-v8a
|
||||
APP_SHORT_COMMANDS := true
|
||||
APP_CPPFLAGS += -frtti -fexceptions
|
||||
#APP_ABI := armeabi-v7a x86
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
android:versionName="0.6.1-alpha-0.0.3">
|
||||
|
||||
<uses-sdk
|
||||
android:minSdkVersion="19"
|
||||
android:targetSdkVersion="30"/>
|
||||
android:minSdkVersion="24"
|
||||
android:targetSdkVersion="28"/>
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.touchscreen.multitouch"
|
||||
|
||||
@@ -168,10 +168,8 @@ options.graphics.fast=Fast
|
||||
options.guiScale=GUI Scale
|
||||
options.guiScale.auto=Auto
|
||||
options.guiScale.small=Small
|
||||
options.guiScale.medium=Medium
|
||||
options.guiScale.normal=Normal
|
||||
options.guiScale.large=Large
|
||||
options.guiScale.larger=Larger
|
||||
options.guiScale.largest=Largest
|
||||
options.advancedOpengl=Advanced OpenGL
|
||||
options.renderClouds=Clouds
|
||||
options.farWarning1=A 64 bit Java installation is recommended
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_PLATFORM := android-19
|
||||
APP_PLATFORM := android-9
|
||||
APP_STL := gnustl_static
|
||||
APP_OPTIM := release
|
||||
APP_ABI := armeabi-v7a
|
||||
@@ -59,7 +59,6 @@ public class MainActivity extends Activity {
|
||||
private static final int PERMISSION_REQUEST_CODE = 123;
|
||||
|
||||
private GLView _glView;
|
||||
private boolean _nativeInitialized = false;
|
||||
public float invScale = 1.0f;// / 1.5f;
|
||||
private int _screenWidth = 0;
|
||||
private int _screenHeight = 0;
|
||||
@@ -78,48 +77,63 @@ public class MainActivity extends Activity {
|
||||
_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);
|
||||
|
||||
_glView.setEGLConfigChooser(true);
|
||||
//_glView
|
||||
|
||||
// _glView.setEGLConfigChooser(
|
||||
// new GLSurfaceView.EGLConfigChooser() {
|
||||
//
|
||||
// @Override
|
||||
// public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
|
||||
// // TODO Auto-generated method stub
|
||||
//
|
||||
// // Specify a configuration for our opengl session
|
||||
// // and grab the first configuration that matches is
|
||||
// int[] configSpec = {
|
||||
// EGL10.EGL_DEPTH_SIZE, 24,
|
||||
// EGL10.EGL_NONE
|
||||
// };
|
||||
// EGLConfig[] configs = new EGLConfig[1];
|
||||
// int[] num_config = new int[1];
|
||||
// egl.eglChooseConfig(display, configSpec, configs, 1, num_config);
|
||||
// EGLConfig config = configs[0];
|
||||
// return config;
|
||||
//
|
||||
// //return null;
|
||||
// }
|
||||
// } );
|
||||
|
||||
_glView.commit();
|
||||
setContentView(_glView);
|
||||
setContentView(_glView);
|
||||
|
||||
_soundPlayer = new SoundPlayer(this, AudioManager.STREAM_MUSIC);
|
||||
_soundPlayer = new SoundPlayer(this, AudioManager.STREAM_MUSIC);
|
||||
|
||||
// request dangerous permissions at runtime if necessary
|
||||
checkAndRequestPermissions();
|
||||
initNative();
|
||||
}
|
||||
|
||||
private void initNative() {
|
||||
if (_nativeInitialized) {
|
||||
return;
|
||||
private void checkAndRequestPermissions() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
boolean needRequest = false;
|
||||
if (checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
needRequest = true;
|
||||
}
|
||||
if (checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE)
|
||||
!= PackageManager.PERMISSION_GRANTED) {
|
||||
needRequest = true;
|
||||
}
|
||||
if (needRequest) {
|
||||
requestPermissions(new String[] {
|
||||
android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
android.Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
}, PERMISSION_REQUEST_CODE);
|
||||
}
|
||||
}
|
||||
_nativeInitialized = true;
|
||||
nativeOnCreate(_screenWidth, _screenHeight);
|
||||
}
|
||||
|
||||
// request dangerous permissions at runtime if necessary
|
||||
private boolean checkAndRequestPermissions() {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean writeGranted = checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
|
||||
boolean readGranted = checkSelfPermission(android.Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED;
|
||||
|
||||
if (writeGranted && readGranted) {
|
||||
return true;
|
||||
}
|
||||
|
||||
requestPermissions(new String[] {
|
||||
android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
|
||||
android.Manifest.permission.READ_EXTERNAL_STORAGE
|
||||
}, PERMISSION_REQUEST_CODE);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -132,18 +146,8 @@ public class MainActivity extends Activity {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (granted) {
|
||||
initNative();
|
||||
} else {
|
||||
// We can still run using app-specific external files in scoped-storage,
|
||||
// so allow startup while warning the user.
|
||||
initNative();
|
||||
new AlertDialog.Builder(this)
|
||||
.setTitle("Storage permission recommended")
|
||||
.setMessage("MinecraftPE can still run with app-private storage, but public external save/load may require permission.")
|
||||
.setPositiveButton("OK", null)
|
||||
.setCancelable(true)
|
||||
.show();
|
||||
if (!granted) {
|
||||
// user denied; you might want to warn or close the app
|
||||
}
|
||||
}
|
||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||
|
||||
@@ -41,7 +41,6 @@
|
||||
042A91AE16B17517007ABBC6 /* GuiElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 042A91A316B17517007ABBC6 /* GuiElement.cpp */; };
|
||||
042A91AF16B17517007ABBC6 /* NinePatch.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 042A91A516B17517007ABBC6 /* NinePatch.cpp */; };
|
||||
042A91B016B17517007ABBC6 /* OptionsGroup.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 042A91A716B17517007ABBC6 /* OptionsGroup.cpp */; };
|
||||
042A91B116B17517007ABBC6 /* OptionsPane.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 042A91A916B17517007ABBC6 /* OptionsPane.cpp */; };
|
||||
042A91B216B17517007ABBC6 /* TextBox.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 042A91AB16B17517007ABBC6 /* TextBox.cpp */; };
|
||||
044129071682FF9600B70EE6 /* MouseHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 044129061682FF9600B70EE6 /* MouseHandler.cpp */; };
|
||||
9D293CE716071C08000305C8 /* CreateNewWorld_iphone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9D293CE616071C08000305C8 /* CreateNewWorld_iphone.xib */; };
|
||||
@@ -1147,6 +1146,7 @@
|
||||
D5F3B7DD14548E7900D25470 /* IASKPSToggleSwitchSpecifierViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = D5F3B7C814548E7900D25470 /* IASKPSToggleSwitchSpecifierViewCell.xib */; };
|
||||
D5F3B7DE14548E7900D25470 /* IASKSpecifierValuesView.xib in Resources */ = {isa = PBXBuildFile; fileRef = D5F3B7C914548E7900D25470 /* IASKSpecifierValuesView.xib */; };
|
||||
D5F3B7E51454930400D25470 /* InAppSettings.bundle in Resources */ = {isa = PBXBuildFile; fileRef = D5F3B7E41454930400D25470 /* InAppSettings.bundle */; };
|
||||
F912B8CF2F6C3D5200BC60DF /* TextBox.h in Sources */ = {isa = PBXBuildFile; fileRef = 042A91AC16B17517007ABBC6 /* TextBox.h */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@@ -1208,10 +1208,8 @@
|
||||
042A91A616B17517007ABBC6 /* NinePatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NinePatch.h; sourceTree = "<group>"; };
|
||||
042A91A716B17517007ABBC6 /* OptionsGroup.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionsGroup.cpp; sourceTree = "<group>"; };
|
||||
042A91A816B17517007ABBC6 /* OptionsGroup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OptionsGroup.h; sourceTree = "<group>"; };
|
||||
042A91A916B17517007ABBC6 /* OptionsPane.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionsPane.cpp; sourceTree = "<group>"; };
|
||||
042A91AA16B17517007ABBC6 /* OptionsPane.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OptionsPane.h; sourceTree = "<group>"; };
|
||||
042A91AB16B17517007ABBC6 /* TextBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextBox.cpp; sourceTree = "<group>"; };
|
||||
042A91AC16B17517007ABBC6 /* TextBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextBox.h; sourceTree = "<group>"; };
|
||||
042A91AC16B17517007ABBC6 /* TextBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TextBox.h; path = ../../src/client/gui/components/TextBox.h; sourceTree = SOURCE_ROOT; };
|
||||
044129061682FF9600B70EE6 /* MouseHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseHandler.cpp; sourceTree = "<group>"; };
|
||||
9D293CE616071C08000305C8 /* CreateNewWorld_iphone.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = CreateNewWorld_iphone.xib; path = minecraftpe/dialogs/CreateNewWorld_iphone.xib; sourceTree = "<group>"; };
|
||||
9D293CEA160720D6000305C8 /* worldname_iphone5_3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = worldname_iphone5_3.png; sourceTree = "<group>"; };
|
||||
@@ -3226,8 +3224,6 @@
|
||||
042A91A616B17517007ABBC6 /* NinePatch.h */,
|
||||
042A91A716B17517007ABBC6 /* OptionsGroup.cpp */,
|
||||
042A91A816B17517007ABBC6 /* OptionsGroup.h */,
|
||||
042A91A916B17517007ABBC6 /* OptionsPane.cpp */,
|
||||
042A91AA16B17517007ABBC6 /* OptionsPane.h */,
|
||||
042A91AB16B17517007ABBC6 /* TextBox.cpp */,
|
||||
042A91AC16B17517007ABBC6 /* TextBox.h */,
|
||||
D5B50C2814CFF66F005F7284 /* Button.cpp */,
|
||||
@@ -4527,10 +4523,16 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0420;
|
||||
TargetAttributes = {
|
||||
D5CF9C41144C225000E4244F = {
|
||||
DevelopmentTeam = PZUVNW8F2U;
|
||||
ProvisioningStyle = Automatic;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = D5CF9C3C144C225000E4244F /* Build configuration list for PBXProject "minecraftpe" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
developmentRegion = en;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
@@ -5339,6 +5341,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F912B8CF2F6C3D5200BC60DF /* TextBox.h in Sources */,
|
||||
D5CF9C57144C225000E4244F /* main.mm in Sources */,
|
||||
D5CF9C5B144C225000E4244F /* minecraftpeAppDelegate.mm in Sources */,
|
||||
D5CF9C65144C225000E4244F /* EAGLView.m in Sources */,
|
||||
@@ -5697,7 +5700,6 @@
|
||||
042A91AE16B17517007ABBC6 /* GuiElement.cpp in Sources */,
|
||||
042A91AF16B17517007ABBC6 /* NinePatch.cpp in Sources */,
|
||||
042A91B016B17517007ABBC6 /* OptionsGroup.cpp in Sources */,
|
||||
042A91B116B17517007ABBC6 /* OptionsPane.cpp in Sources */,
|
||||
042A91B216B17517007ABBC6 /* TextBox.cpp in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -5736,24 +5738,31 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
|
||||
ARCHS = "$(ARCHS_STANDARD)";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Mojang AB";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = PUBLISH;
|
||||
GCC_VERSION = com.apple.compilers.llvmgcc42;
|
||||
GCC_VERSION = "";
|
||||
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO;
|
||||
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(SRCROOT)/src/**",
|
||||
"$(SRCROOT)/src/client/gui/components/**",
|
||||
"$(SRCROOT)/src/client/gui/**",
|
||||
);
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
|
||||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "C93D3524-5C6F-466E-B12B-833663B7EAE0";
|
||||
RUN_CLANG_STATIC_ANALYZER = NO;
|
||||
SDKROOT = iphoneos6.0;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)\\src/**";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = "Ad-Hoc";
|
||||
@@ -5765,15 +5774,21 @@
|
||||
GCC_PREFIX_HEADER = "minecraftpe/minecraftpe-Prefix.pch";
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "";
|
||||
"GCC_THUMB_SUPPORT[arch=armv7]" = NO;
|
||||
GCC_VERSION = com.apple.compilers.llvmgcc42;
|
||||
GCC_VERSION = "";
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(SRCROOT)/src/client/gui/components/**",
|
||||
"$(SRCROOT)/src/client/gui/**",
|
||||
"$(SRCROOT)/src/**",
|
||||
);
|
||||
INFOPLIST_FILE = "minecraftpe/minecraftpe-Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.games";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.mojang.mcpe-arm64";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
RUN_CLANG_STATIC_ANALYZER = NO;
|
||||
SDKROOT = iphoneos6.0;
|
||||
VALID_ARCHS = "i386 armv6 armv7";
|
||||
SDKROOT = iphoneos;
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = "Ad-Hoc";
|
||||
@@ -5847,23 +5862,30 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
|
||||
ARCHS = "$(ARCHS_STANDARD)";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution: Mojang AB";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_VERSION = com.apple.compilers.llvmgcc42;
|
||||
GCC_VERSION = "";
|
||||
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO;
|
||||
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(SRCROOT)/src/**",
|
||||
"$(SRCROOT)/src/client/gui/components/**",
|
||||
"$(SRCROOT)/src/client/gui/**",
|
||||
);
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
|
||||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "64BA8967-1A9A-4980-972C-42E75AD5E023";
|
||||
RUN_CLANG_STATIC_ANALYZER = NO;
|
||||
SDKROOT = iphoneos6.0;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)\\src/**";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = AppStore;
|
||||
@@ -5876,11 +5898,17 @@
|
||||
GCC_PREFIX_HEADER = "minecraftpe/minecraftpe-Prefix.pch";
|
||||
GCC_PREPROCESSOR_DEFINITIONS = PUBLISH;
|
||||
"GCC_THUMB_SUPPORT[arch=armv7]" = NO;
|
||||
GCC_VERSION = com.apple.compilers.llvmgcc42;
|
||||
GCC_VERSION = "";
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(SRCROOT)/src/client/gui/components/**",
|
||||
"$(SRCROOT)/src/client/gui/**",
|
||||
"$(SRCROOT)/src/**",
|
||||
);
|
||||
INFOPLIST_FILE = "minecraftpe/minecraftpe-Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.games";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_CFLAGS = (
|
||||
"-DNS_BLOCK_ASSERTIONS=1",
|
||||
"-DANDROID_PUBLISH",
|
||||
@@ -5888,8 +5916,7 @@
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "1B194957-98CF-49B7-A0E7-76692B4B722D";
|
||||
RUN_CLANG_STATIC_ANALYZER = NO;
|
||||
SDKROOT = iphoneos6.0;
|
||||
VALID_ARCHS = "i386 armv6 armv7";
|
||||
SDKROOT = iphoneos;
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = AppStore;
|
||||
@@ -5923,7 +5950,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
|
||||
ARCHS = "$(ARCHS_STANDARD)";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
@@ -5935,17 +5962,25 @@
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_VERSION = com.apple.compilers.llvmgcc42;
|
||||
GCC_VERSION = "";
|
||||
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO;
|
||||
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(SRCROOT)/src/**",
|
||||
"$(SRCROOT)/src/client/gui/components/**",
|
||||
"$(SRCROOT)/src/client/gui/**",
|
||||
);
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
RUN_CLANG_STATIC_ANALYZER = NO;
|
||||
SDKROOT = iphoneos6.0;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)\\src/**";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@@ -5953,23 +5988,30 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
ARCHS = "$(ARCHS_UNIVERSAL_IPHONE_OS)";
|
||||
ARCHS = "$(ARCHS_STANDARD)";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = PUBLISH;
|
||||
GCC_VERSION = com.apple.compilers.llvmgcc42;
|
||||
GCC_VERSION = "";
|
||||
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO;
|
||||
GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(SRCROOT)/src/**",
|
||||
"$(SRCROOT)/src/client/gui/components/**",
|
||||
"$(SRCROOT)/src/client/gui/**",
|
||||
);
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
|
||||
RUN_CLANG_STATIC_ANALYZER = NO;
|
||||
SDKROOT = iphoneos6.0;
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
USER_HEADER_SEARCH_PATHS = "$(SRCROOT)\\src/**";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
@@ -5977,19 +6019,29 @@
|
||||
D5CF9C6F144C225000E4244F /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = PZUVNW8F2U;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "minecraftpe/minecraftpe-Prefix.pch";
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
|
||||
"GCC_THUMB_SUPPORT[arch=armv7]" = NO;
|
||||
GCC_VERSION = com.apple.compilers.llvmgcc42;
|
||||
GCC_VERSION = "";
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(SRCROOT)/src/client/gui/components/**",
|
||||
"$(SRCROOT)/src/client/gui/**",
|
||||
"$(SRCROOT)/src/**",
|
||||
);
|
||||
INFOPLIST_FILE = "minecraftpe/minecraftpe-Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.games";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.mojang.mcpe-arm64";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
RUN_CLANG_STATIC_ANALYZER = NO;
|
||||
SDKROOT = iphoneos6.0;
|
||||
VALID_ARCHS = "i386 armv6 armv7";
|
||||
SDKROOT = iphoneos;
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = Debug;
|
||||
@@ -5997,19 +6049,29 @@
|
||||
D5CF9C70144C225000E4244F /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
DEVELOPMENT_TEAM = PZUVNW8F2U;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "minecraftpe/minecraftpe-Prefix.pch";
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "";
|
||||
"GCC_THUMB_SUPPORT[arch=armv7]" = NO;
|
||||
GCC_VERSION = com.apple.compilers.llvmgcc42;
|
||||
GCC_VERSION = "";
|
||||
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
|
||||
HEADER_SEARCH_PATHS = "";
|
||||
HEADER_SEARCH_PATHS = (
|
||||
"$(SRCROOT)/src/client/gui/components/**",
|
||||
"$(SRCROOT)/src/client/gui/**",
|
||||
"$(SRCROOT)/src/**",
|
||||
);
|
||||
INFOPLIST_FILE = "minecraftpe/minecraftpe-Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 4.3;
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.games";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "com.mojang.mcpe-arm64";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
RUN_CLANG_STATIC_ANALYZER = NO;
|
||||
SDKROOT = iphoneos6.0;
|
||||
VALID_ARCHS = "i386 armv6 armv7";
|
||||
SDKROOT = iphoneos;
|
||||
WRAPPER_EXTENSION = app;
|
||||
};
|
||||
name = Release;
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
</dict>
|
||||
</dict>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.mojang.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
|
||||
@@ -4,11 +4,10 @@ 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)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#if defined(X360__)
|
||||
#elif defined (_WIN32)
|
||||
#include <winsock2.h>
|
||||
#include <WinSock2.h>
|
||||
#include <windows.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <Ws2tcpip.h>
|
||||
|
||||
// Must always include Winsock2.h before windows.h
|
||||
// or else:
|
||||
|
||||
26
src/App.cpp
26
src/App.cpp
@@ -1,26 +0,0 @@
|
||||
#include "App.hpp"
|
||||
#include "IPlatform.hpp"
|
||||
|
||||
#include "platform/server/PlatformServer.hpp"
|
||||
#include "platform/glfw/PlatformGlfw.hpp"
|
||||
|
||||
std::unique_ptr<IPlatform> App::CreatePlatform() {
|
||||
#if defined(STANDALONE_SERVER)
|
||||
return std::make_unique<PlatformServer>();
|
||||
#elif defined(PLATFORM_DESKTOP)
|
||||
return std::make_unique<PlatformGlfw>();
|
||||
#else
|
||||
static_assert(false, "Unsupported platform!");
|
||||
#endif
|
||||
}
|
||||
|
||||
void App::run() {
|
||||
init();
|
||||
|
||||
m_platform->runMainLoop(*this);
|
||||
}
|
||||
|
||||
void App::swapBuffers() {
|
||||
m_platform->swapBuffers();
|
||||
}
|
||||
|
||||
87
src/App.h
Executable file
87
src/App.h
Executable file
@@ -0,0 +1,87 @@
|
||||
#ifndef APP_H__
|
||||
#define APP_H__
|
||||
|
||||
#ifdef __APPLE__
|
||||
#define NO_EGL
|
||||
#endif
|
||||
#ifdef STANDALONE_SERVER
|
||||
#define NO_EGL
|
||||
#endif
|
||||
|
||||
#include "AppPlatform.h"
|
||||
#ifndef NO_EGL
|
||||
#include <EGL/egl.h>
|
||||
#endif
|
||||
#include "platform/log.h"
|
||||
|
||||
typedef struct AppContext {
|
||||
#ifndef NO_EGL
|
||||
EGLDisplay display;
|
||||
EGLContext context;
|
||||
EGLSurface surface;
|
||||
#endif
|
||||
AppPlatform* platform;
|
||||
bool doRender;
|
||||
} AppContext;
|
||||
|
||||
|
||||
class App
|
||||
{
|
||||
public:
|
||||
App()
|
||||
: _finished(false),
|
||||
_inited(false)
|
||||
{
|
||||
_context.platform = 0;
|
||||
}
|
||||
virtual ~App() {}
|
||||
|
||||
void init(AppContext& c) {
|
||||
_context = c;
|
||||
init();
|
||||
_inited = true;
|
||||
}
|
||||
bool isInited() { return _inited; }
|
||||
|
||||
virtual AppPlatform* platform() { return _context.platform; }
|
||||
|
||||
void onGraphicsReset(AppContext& c) {
|
||||
_context = c;
|
||||
onGraphicsReset();
|
||||
}
|
||||
|
||||
virtual void audioEngineOn () {}
|
||||
virtual void audioEngineOff() {}
|
||||
|
||||
virtual void destroy() {}
|
||||
|
||||
virtual void loadState(void* state, int stateSize) {}
|
||||
virtual bool saveState(void** state, int* stateSize) { return false; }
|
||||
|
||||
void swapBuffers() {
|
||||
#ifndef NO_EGL
|
||||
if (_context.doRender)
|
||||
eglSwapBuffers(_context.display, _context.surface);
|
||||
#endif
|
||||
}
|
||||
|
||||
virtual void draw() {}
|
||||
virtual void update() {};// = 0;
|
||||
virtual void setSize(int width, int height) {}
|
||||
|
||||
virtual void quit() { _finished = true; }
|
||||
virtual bool wantToQuit() { return _finished; }
|
||||
virtual bool handleBack(bool isDown) { return false; }
|
||||
|
||||
protected:
|
||||
virtual void init() {}
|
||||
//virtual void onGraphicsLost() = 0;
|
||||
virtual void onGraphicsReset() = 0;
|
||||
|
||||
private:
|
||||
bool _inited;
|
||||
bool _finished;
|
||||
AppContext _context;
|
||||
};
|
||||
|
||||
#endif//APP_H__
|
||||
71
src/App.hpp
71
src/App.hpp
@@ -1,71 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#ifdef __APPLE__
|
||||
#define NO_EGL
|
||||
#endif
|
||||
#ifdef STANDALONE_SERVER
|
||||
#define NO_EGL
|
||||
#endif
|
||||
|
||||
#include <IPlatform.hpp>
|
||||
#ifndef NO_EGL
|
||||
#include <EGL/egl.h>
|
||||
#endif
|
||||
|
||||
|
||||
// typedef struct AppContext {
|
||||
// #ifndef NO_EGL
|
||||
// EGLDisplay display;
|
||||
// EGLContext context;
|
||||
// EGLSurface surface;
|
||||
// #endif
|
||||
// AppPlatform* platform;
|
||||
// bool doRender;
|
||||
// } AppContext;
|
||||
|
||||
class App {
|
||||
protected:
|
||||
std::unique_ptr<IPlatform> m_platform;
|
||||
|
||||
public:
|
||||
static std::unique_ptr<IPlatform> CreatePlatform();
|
||||
|
||||
App(std::unique_ptr<IPlatform> platform) : m_platform(std::move(platform)), m_finished(false), m_inited(false) {}
|
||||
App() = delete;
|
||||
virtual ~App() {}
|
||||
|
||||
void run();
|
||||
|
||||
bool isInited() { return m_inited; }
|
||||
|
||||
virtual void audioEngineOn () {}
|
||||
virtual void audioEngineOff() {}
|
||||
|
||||
virtual void destroy() {}
|
||||
|
||||
virtual void loadState(void* state, int stateSize) {}
|
||||
virtual bool saveState(void** state, int* stateSize) { return false; }
|
||||
|
||||
void swapBuffers();
|
||||
// {
|
||||
// #ifndef NO_EGL
|
||||
// if (_context.doRender)
|
||||
// eglSwapBuffers(_context.display, _context.surface);
|
||||
// #endif
|
||||
// m_platform->swapBuffers();
|
||||
// }
|
||||
|
||||
virtual void update() = 0;
|
||||
|
||||
virtual void quit() { m_finished = true; }
|
||||
virtual bool wantToQuit() { return m_finished; }
|
||||
virtual bool handleBack(bool isDown) { return false; }
|
||||
|
||||
protected:
|
||||
virtual void init() { m_inited = true;}
|
||||
|
||||
private:
|
||||
bool m_inited = false;
|
||||
bool m_finished = false;
|
||||
};
|
||||
10
src/AppConstants.h
Executable file
10
src/AppConstants.h
Executable file
@@ -0,0 +1,10 @@
|
||||
#ifndef _MINECRAFT_APPCONSTANTS_H_
|
||||
#define _MINECRAFT_APPCONSTANTS_H_
|
||||
|
||||
|
||||
#define APP_VERSION_STRING "Demo"
|
||||
#define APP_NAME "Minecraft - Pocket Edition " APP_VERSION_STRING
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
141
src/AppPlatform.h
Executable file
141
src/AppPlatform.h
Executable file
@@ -0,0 +1,141 @@
|
||||
#ifndef APPPLATFORM_H__
|
||||
#define APPPLATFORM_H__
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include "client/renderer/TextureData.h"
|
||||
|
||||
typedef std::vector<std::string> StringVector;
|
||||
|
||||
/*
|
||||
typedef struct UserInput
|
||||
{
|
||||
static const int STATUS_INVALID = -1;
|
||||
static const int STATUS_NOTINITED = -2;
|
||||
static const int STATUS_OK = 1;
|
||||
static const int STATUS_CANCEL = 0;
|
||||
|
||||
UserInput(int id)
|
||||
: _id(id),
|
||||
status(STATUS_NOTINITED)
|
||||
{}
|
||||
UserInput(int id, int status)
|
||||
: _id(id),
|
||||
status(status)
|
||||
{}
|
||||
int getId() { return _id; }
|
||||
|
||||
int status;
|
||||
private:
|
||||
int _id;
|
||||
} UserInput;
|
||||
|
||||
|
||||
class UserInputStatus {
|
||||
int _status;
|
||||
public:
|
||||
UserInputStatus(int status)
|
||||
: _status(status)
|
||||
{}
|
||||
bool isAnswered() { return _status >= 0; }
|
||||
bool isOk() { return _status == UserInput::STATUS_OK; }
|
||||
bool isCancel() { return _status == UserInput::STATUS_CANCEL; }
|
||||
};
|
||||
*/
|
||||
|
||||
class BinaryBlob {
|
||||
public:
|
||||
BinaryBlob()
|
||||
: data(NULL),
|
||||
size(-1) {}
|
||||
|
||||
BinaryBlob(unsigned char* data, unsigned int size)
|
||||
: data(data),
|
||||
size(size) {}
|
||||
|
||||
unsigned char* data;
|
||||
int size;
|
||||
};
|
||||
|
||||
class PlatformStringVars {
|
||||
public:
|
||||
static const int DEVICE_BUILD_MODEL = 0;
|
||||
};
|
||||
|
||||
class AppPlatform
|
||||
{
|
||||
public:
|
||||
AppPlatform() : keyboardVisible(false) {}
|
||||
virtual ~AppPlatform() {}
|
||||
|
||||
virtual void saveScreenshot(const std::string& filename, int glWidth, int glHeight) {}
|
||||
virtual TextureData loadTexture(const std::string& filename_, bool textureFolder) { return TextureData(); }
|
||||
virtual TextureData loadTextureFromMemory(const unsigned char* data, size_t size) { return TextureData(); }
|
||||
|
||||
virtual void playSound(const std::string& fn, float volume, float pitch) {}
|
||||
|
||||
virtual void showDialog(int dialogId) {}
|
||||
virtual void createUserInput() {}
|
||||
|
||||
bool is_big_endian(void) {
|
||||
union {
|
||||
unsigned int i;
|
||||
char c[4];
|
||||
} bint = {0x01020304};
|
||||
return bint.c[0] == 1;
|
||||
}
|
||||
|
||||
void createUserInput(int dialogId)
|
||||
{
|
||||
showDialog(dialogId);
|
||||
createUserInput();
|
||||
}
|
||||
virtual int getUserInputStatus() { return 0; }
|
||||
virtual StringVector getUserInput() { return StringVector(); }
|
||||
|
||||
virtual std::string getDateString(int s) { return ""; }
|
||||
//virtual void createUserInputScreen(const char* types) {}
|
||||
|
||||
virtual void uploadPlatformDependentData(int id, void* data) {}
|
||||
virtual BinaryBlob readAssetFile(const std::string& filename) { return BinaryBlob(); }
|
||||
virtual void _tick() {}
|
||||
|
||||
virtual int getScreenWidth() { return 854; }
|
||||
virtual int getScreenHeight() { return 480; }
|
||||
virtual float getPixelsPerMillimeter() { return 10; }
|
||||
|
||||
virtual bool isNetworkEnabled(bool onlyWifiAllowed) { return true; }
|
||||
|
||||
virtual bool isPowerVR() {
|
||||
return false;
|
||||
}
|
||||
virtual int getKeyFromKeyCode(int keyCode, int metaState, int deviceId) {return 0;}
|
||||
#ifdef __APPLE__
|
||||
virtual bool isSuperFast() = 0;
|
||||
#endif
|
||||
|
||||
virtual void openURL(const std::string& url) {}
|
||||
|
||||
virtual void finish() {}
|
||||
|
||||
virtual bool supportsTouchscreen() { return false; }
|
||||
|
||||
virtual void vibrate(int milliSeconds) {}
|
||||
|
||||
virtual std::string getPlatformStringVar(int stringId) {
|
||||
return "<getPlatformStringVar NotImplemented>";
|
||||
}
|
||||
|
||||
virtual void showKeyboard() {
|
||||
keyboardVisible = true;
|
||||
}
|
||||
virtual void hideKeyboard() {
|
||||
keyboardVisible = false;
|
||||
}
|
||||
virtual bool isKeyboardVisible() {return keyboardVisible;}
|
||||
protected:
|
||||
bool keyboardVisible;
|
||||
};
|
||||
|
||||
#endif /*APPPLATFORM_H__*/
|
||||
@@ -1,9 +1,10 @@
|
||||
#pragma once
|
||||
#ifndef APPPLATFORM_ANDROID_H__
|
||||
#define APPPLATFORM_ANDROID_H__
|
||||
|
||||
#include <IPlatform.hpp>
|
||||
#include "client/renderer/gles.hpp"
|
||||
#include "platform/log.hpp"
|
||||
#include "platform/time.hpp"
|
||||
#include "AppPlatform.h"
|
||||
#include "client/renderer/gles.h"
|
||||
#include "platform/log.h"
|
||||
#include "platform/time.h"
|
||||
#include <jni.h>
|
||||
#include <cmath>
|
||||
#include <exception>
|
||||
@@ -201,8 +202,6 @@ public:
|
||||
LOGI("initConsts: screenWidth=%d, calling getScreenHeight\n", _screenWidth);
|
||||
_screenHeight = env->CallIntMethod(instance, fHeight);
|
||||
LOGI("initConsts: screenHeight=%d, done\n", _screenHeight);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void tick() {
|
||||
@@ -321,7 +320,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
inline unsigned int rgbToBgr(unsigned int p) {
|
||||
__inline unsigned int rgbToBgr(unsigned int p) {
|
||||
return (p & 0xff00ff00) | ((p >> 16) & 0xff) | ((p << 16) & 0xff0000);
|
||||
}
|
||||
|
||||
@@ -535,9 +534,9 @@ public:
|
||||
return env->CallBooleanMethod(instance, _methodIsNetworkEnabled, onlyWifiAllowed);
|
||||
}
|
||||
|
||||
static inline bool isSquare(int n) {
|
||||
static __inline bool isSquare(int n) {
|
||||
int L = n & 0xf;
|
||||
if (((1 << L) & 0x213) == 0) return false;
|
||||
if ((1 << L) & 0x213 == 0) return false;
|
||||
|
||||
int t = (int) sqrt((double) n) + 0.5;
|
||||
return t*t == n;
|
||||
@@ -650,3 +649,4 @@ public:
|
||||
ANativeActivity* _nativeActivity;
|
||||
};
|
||||
|
||||
#endif /*APPPLATFORM_ANDROID_H__*/
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "AppPlatform_android.hpp"
|
||||
#include "AppPlatform_android.h"
|
||||
#include <android/asset_manager.h>
|
||||
#include <android/native_activity.h>
|
||||
|
||||
12
src/AppPlatform_glfw.cpp
Normal file
12
src/AppPlatform_glfw.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#include "AppPlatform_glfw.h"
|
||||
|
||||
float AppPlatform_glfw::getPixelsPerMillimeter() {
|
||||
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
|
||||
|
||||
int width_mm, height_mm;
|
||||
glfwGetMonitorPhysicalSize(monitor, &width_mm, &height_mm);
|
||||
|
||||
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
|
||||
|
||||
return (float)mode->width / (float)width_mm;
|
||||
}
|
||||
153
src/AppPlatform_glfw.h
Executable file
153
src/AppPlatform_glfw.h
Executable file
@@ -0,0 +1,153 @@
|
||||
#ifndef APPPLATFORM_GLFW_H__
|
||||
#define APPPLATFORM_GLFW_H__
|
||||
|
||||
#include "AppPlatform.h"
|
||||
#include "platform/log.h"
|
||||
#include "platform/HttpClient.h"
|
||||
#include "platform/PngLoader.h"
|
||||
#include "client/renderer/gles.h"
|
||||
#include "world/level/storage/FolderMethods.h"
|
||||
#include <png.h>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <ctime>
|
||||
#include "util/StringUtils.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <shellapi.h>
|
||||
#endif
|
||||
|
||||
static void png_funcReadFile(png_structp pngPtr, png_bytep data, png_size_t length) {
|
||||
((std::istream*)png_get_io_ptr(pngPtr))->read((char*)data, length);
|
||||
}
|
||||
|
||||
class AppPlatform_glfw: public AppPlatform
|
||||
{
|
||||
public:
|
||||
AppPlatform_glfw()
|
||||
{
|
||||
}
|
||||
|
||||
BinaryBlob readAssetFile(const std::string& filename) {
|
||||
FILE* fp = fopen(("data/" + filename).c_str(), "r");
|
||||
if (!fp)
|
||||
return BinaryBlob();
|
||||
|
||||
int size = getRemainingFileSize(fp);
|
||||
|
||||
BinaryBlob blob;
|
||||
blob.size = size;
|
||||
blob.data = new unsigned char[size];
|
||||
|
||||
fread(blob.data, 1, size, fp);
|
||||
fclose(fp);
|
||||
|
||||
return blob;
|
||||
}
|
||||
|
||||
void saveScreenshot(const std::string& filename, int glWidth, int glHeight) {
|
||||
//@todo
|
||||
}
|
||||
|
||||
__inline unsigned int rgbToBgr(unsigned int p) {
|
||||
return (p & 0xff00ff00) | ((p >> 16) & 0xff) | ((p << 16) & 0xff0000);
|
||||
}
|
||||
|
||||
TextureData loadTexture(const std::string& filename_, bool textureFolder)
|
||||
{
|
||||
// Support fetching PNG textures via HTTP/HTTPS (for skins, etc)
|
||||
if (Util::startsWith(filename_, "http://") || Util::startsWith(filename_, "https://")) {
|
||||
std::vector<unsigned char> body;
|
||||
if (HttpClient::download(filename_, body) && !body.empty()) {
|
||||
return loadTextureFromMemory(body.data(), body.size());
|
||||
}
|
||||
return TextureData();
|
||||
}
|
||||
|
||||
TextureData out;
|
||||
|
||||
std::string filename = textureFolder? "data/images/" + filename_
|
||||
: filename_;
|
||||
std::ifstream source(filename.c_str(), std::ios::binary);
|
||||
|
||||
if (source) {
|
||||
png_structp pngPtr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
|
||||
if (!pngPtr)
|
||||
return out;
|
||||
|
||||
png_infop infoPtr = png_create_info_struct(pngPtr);
|
||||
|
||||
if (!infoPtr) {
|
||||
png_destroy_read_struct(&pngPtr, NULL, NULL);
|
||||
return out;
|
||||
}
|
||||
|
||||
// Hack to get around the broken libpng for windows
|
||||
png_set_read_fn(pngPtr,(void*)&source, png_funcReadFile);
|
||||
|
||||
png_read_info(pngPtr, infoPtr);
|
||||
|
||||
// Set up the texdata properties
|
||||
out.w = png_get_image_width(pngPtr, infoPtr);
|
||||
out.h = png_get_image_height(pngPtr, infoPtr);
|
||||
|
||||
png_bytep* rowPtrs = new png_bytep[out.h];
|
||||
out.data = new unsigned char[4 * out.w * out.h];
|
||||
out.memoryHandledExternally = false;
|
||||
|
||||
int rowStrideBytes = 4 * out.w;
|
||||
for (int i = 0; i < out.h; i++) {
|
||||
rowPtrs[i] = (png_bytep)&out.data[i*rowStrideBytes];
|
||||
}
|
||||
png_read_image(pngPtr, rowPtrs);
|
||||
|
||||
// Teardown and return
|
||||
png_destroy_read_struct(&pngPtr, &infoPtr,(png_infopp)0);
|
||||
delete[] (png_bytep)rowPtrs;
|
||||
source.close();
|
||||
|
||||
return out;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGI("Couldn't find file: %s\n", filename.c_str());
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
TextureData loadTextureFromMemory(const unsigned char* data, size_t size) override {
|
||||
return loadPngFromMemory(data, size);
|
||||
}
|
||||
|
||||
virtual std::string getDateString(int s) override {
|
||||
time_t tm = s;
|
||||
|
||||
char mbstr[100];
|
||||
std::strftime(mbstr, sizeof(mbstr), "%F %T", std::localtime(&tm));
|
||||
|
||||
return std::string(mbstr);
|
||||
}
|
||||
|
||||
virtual int getScreenWidth() { return 854; };
|
||||
virtual int getScreenHeight() { return 480; };
|
||||
|
||||
virtual float getPixelsPerMillimeter();
|
||||
|
||||
virtual bool supportsTouchscreen() override { return true; }
|
||||
|
||||
virtual void openURL(const std::string& url) override {
|
||||
#ifdef _WIN32
|
||||
ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL);
|
||||
#elif __linux__
|
||||
std::string command = "xdg-open " + url;
|
||||
system(command.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
};
|
||||
#endif /*APPPLATFORM_GLFW_H__*/
|
||||
@@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
#ifndef APPPLATFORM_IOS_H__
|
||||
#define APPPLATFORM_IOS_H__
|
||||
|
||||
#include <IPlatform.h>
|
||||
#include "client/renderer/gles.hpp"
|
||||
#include "platform/log.hpp"
|
||||
#include "AppPlatform.h"
|
||||
#include "client/renderer/gles.h"
|
||||
#include "platform/log.h"
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
@@ -26,7 +27,7 @@ public:
|
||||
//@todo
|
||||
}
|
||||
|
||||
inline unsigned int rgbToBgr(unsigned int p) {
|
||||
__inline unsigned int rgbToBgr(unsigned int p) {
|
||||
return (p & 0xff00ff00) | ((p >> 16) & 0xff) | ((p << 16) & 0xff0000);
|
||||
}
|
||||
|
||||
@@ -51,14 +52,14 @@ public:
|
||||
|
||||
virtual StringVector getOptionStrings();
|
||||
|
||||
virtual bool isPowerVR() { return false; }
|
||||
virtual bool isPowerVR();
|
||||
virtual bool isSuperFast();
|
||||
virtual void showKeyboard();
|
||||
virtual void hideKeyboard();
|
||||
virtual void isPowerVR();
|
||||
private:
|
||||
|
||||
std::string _basePath;
|
||||
minecraftpeViewController* _viewController;
|
||||
};
|
||||
|
||||
#endif /*APPPLATFORM_IOS_H__*/
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "AppPlatform_win32.hpp"
|
||||
#include "util/Mth.hpp"
|
||||
#include "AppPlatform_win32.h"
|
||||
#include "util/Mth.h"
|
||||
|
||||
int AppPlatform_win32::getScreenWidth() { return 854; }
|
||||
int AppPlatform_win32::getScreenHeight() { return 480; }
|
||||
@@ -1,12 +1,13 @@
|
||||
#pragma once
|
||||
#ifndef APPPLATFORM_WIN32_H__
|
||||
#define APPPLATFORM_WIN32_H__
|
||||
|
||||
#include <IPlatform.hpp>
|
||||
#include "platform/log.hpp"
|
||||
#include "platform/HttpClient.hpp"
|
||||
#include "platform/PngLoader.hpp"
|
||||
#include "client/renderer/gles.hpp"
|
||||
#include "world/level/storage/FolderMethods.hpp"
|
||||
#include "util/StringUtils.hpp"
|
||||
#include "AppPlatform.h"
|
||||
#include "platform/log.h"
|
||||
#include "platform/HttpClient.h"
|
||||
#include "platform/PngLoader.h"
|
||||
#include "client/renderer/gles.h"
|
||||
#include "world/level/storage/FolderMethods.h"
|
||||
#include "util/StringUtils.h"
|
||||
#include <png.h>
|
||||
#include <cmath>
|
||||
#include <fstream>
|
||||
@@ -46,7 +47,7 @@ public:
|
||||
//@todo
|
||||
}
|
||||
|
||||
inline unsigned int rgbToBgr(unsigned int p) {
|
||||
__inline unsigned int rgbToBgr(unsigned int p) {
|
||||
return (p & 0xff00ff00) | ((p >> 16) & 0xff) | ((p << 16) & 0xff0000);
|
||||
}
|
||||
|
||||
@@ -138,3 +139,4 @@ public:
|
||||
private:
|
||||
};
|
||||
|
||||
#endif /*APPPLATFORM_WIN32_H__*/
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef EGLCONFIGPRINTER_H__
|
||||
#define EGLCONFIGPRINTER_H__
|
||||
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
@@ -121,3 +122,4 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
#endif /*EGLCONFIGPRINTER_H__*/
|
||||
13
src/ErrorCodes.h
Executable file
13
src/ErrorCodes.h
Executable file
@@ -0,0 +1,13 @@
|
||||
#ifndef ERRORCODES_H__
|
||||
#define ERRORCODES_H__
|
||||
|
||||
namespace ErrorCodes {
|
||||
|
||||
enum Enum {
|
||||
Unknown,
|
||||
ContainerRefStillExistsAfterDestruction
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif /*ERRORCODES_H__*/
|
||||
@@ -1,14 +0,0 @@
|
||||
#include <IPlatform.hpp>
|
||||
#include <App.hpp>
|
||||
#include <fstream>
|
||||
|
||||
void IPlatform::runMainLoop(App& app) {
|
||||
while(!app.wantToQuit()) app.update();
|
||||
}
|
||||
|
||||
ByteVector IPlatform::readAssetFile(const std::string& path) {
|
||||
std::ifstream instream(path, std::ios::in | std::ios::binary);
|
||||
std::vector<uint8_t> data((std::istreambuf_iterator<char>(instream)), std::istreambuf_iterator<char>());
|
||||
|
||||
return data;
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "client/renderer/TextureData.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
typedef std::vector<std::string> StringVector;
|
||||
typedef std::vector<uint8_t> ByteVector;
|
||||
|
||||
class App;
|
||||
|
||||
class IPlatform {
|
||||
public:
|
||||
IPlatform() : keyboardVisible(false), windowSizeChanged(false), m_targetFrametime(0.f) {}
|
||||
virtual ~IPlatform() {}
|
||||
|
||||
virtual bool init() { return true; }
|
||||
virtual void swapBuffers() {}
|
||||
|
||||
virtual void runMainLoop(App& app);
|
||||
|
||||
virtual ByteVector readAssetFile(const std::string& path);
|
||||
|
||||
|
||||
// Mojang functions here
|
||||
virtual TextureData loadTexture(const std::string& filename_, bool textureFolder) { return TextureData(); }
|
||||
virtual TextureData loadTextureFromMemory(const unsigned char* data, size_t size) { return TextureData(); }
|
||||
|
||||
virtual void playSound(const std::string& fn, float volume, float pitch) {}
|
||||
|
||||
virtual void hideCursor(bool hide) {}
|
||||
|
||||
virtual std::string getDateString(int s) = 0;
|
||||
|
||||
virtual void uploadPlatformDependentData(int id, void* data) {}
|
||||
// virtual BinaryBlob readAssetFile(const std::string& filename) { return BinaryBlob(); }
|
||||
virtual void _tick() {}
|
||||
|
||||
virtual int getScreenWidth() { return 854; }
|
||||
virtual int getScreenHeight() { return 480; }
|
||||
virtual float getPixelsPerMillimeter() { return 10; }
|
||||
|
||||
virtual bool isNetworkEnabled(bool onlyWifiAllowed) { return true; }
|
||||
|
||||
virtual bool isPowerVR() {
|
||||
return false;
|
||||
}
|
||||
virtual int getKeyFromKeyCode(int keyCode, int metaState, int deviceId) {return 0;}
|
||||
#ifdef __APPLE__
|
||||
virtual bool isSuperFast() = 0;
|
||||
#endif
|
||||
|
||||
virtual void openURL(const std::string& url) {}
|
||||
|
||||
virtual void finish() {}
|
||||
|
||||
virtual bool supportsTouchscreen() { return false; }
|
||||
|
||||
virtual void vibrate(int milliSeconds) {}
|
||||
|
||||
virtual std::string getPlatformStringVar(int stringId) = 0;
|
||||
|
||||
virtual void showKeyboard() { keyboardVisible = true; }
|
||||
|
||||
virtual void hideKeyboard() { keyboardVisible = false; }
|
||||
|
||||
virtual bool isKeyboardVisible() { return keyboardVisible; }
|
||||
|
||||
virtual void setTargetFPS(int fps) { m_targetFrametime = 1.0 / fps; }
|
||||
|
||||
bool isWindowSizeChanged() { return windowSizeChanged; }
|
||||
|
||||
virtual void setVSync(bool on) { vsync = on; }
|
||||
|
||||
protected:
|
||||
bool keyboardVisible;
|
||||
bool windowSizeChanged;
|
||||
bool vsync;
|
||||
|
||||
double m_targetFrametime;
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef LICENSECODES_H__
|
||||
#define LICENSECODES_H__
|
||||
|
||||
class LicenseCodes
|
||||
{
|
||||
@@ -1,502 +0,0 @@
|
||||
#include <Minecraft.hpp>
|
||||
#include "gamemode/CreativeMode.hpp"
|
||||
#include "gamemode/SurvivalMode.hpp"
|
||||
#include "gamemode/CreatorMode.hpp"
|
||||
#include "world/entity/player/Player.hpp"
|
||||
#include "world/item/Item.hpp"
|
||||
#include "world/item/ItemInstance.hpp"
|
||||
#include "world/item/crafting/Recipes.hpp"
|
||||
#include "world/level/Level.hpp"
|
||||
#include "world/level/tile/entity/TileEntity.hpp"
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
#include "client/gui/Screen.hpp"
|
||||
#include "world/level/storage/ExternalFileLevelStorageSource.hpp"
|
||||
|
||||
#if defined(APPLE_DEMO_PROMOTION)
|
||||
#define NO_NETWORK
|
||||
#endif
|
||||
|
||||
#if defined(RPI)
|
||||
#define CREATORMODE
|
||||
#endif
|
||||
#include "network/RakNetInstance.hpp"
|
||||
#include "network/ClientSideNetworkHandler.hpp"
|
||||
#include "network/ServerSideNetworkHandler.hpp"
|
||||
//#include "network/Packet.hpp"
|
||||
#include "world/entity/player/Inventory.hpp"
|
||||
#include "world/level/tile/Tile.hpp"
|
||||
#include "world/level/storage/LevelStorageSource.hpp"
|
||||
#include "world/level/storage/LevelStorage.hpp"
|
||||
#include "world/level/chunk/ChunkSource.hpp"
|
||||
|
||||
#include "platform/CThread.hpp"
|
||||
#include <IPlatform.hpp>
|
||||
#include "util/PerfTimer.hpp"
|
||||
#include "util/PerfRenderer.hpp"
|
||||
|
||||
#include "world/entity/MobFactory.hpp"
|
||||
#include "world/level/MobSpawner.hpp"
|
||||
#include "util/Mth.hpp"
|
||||
#include "world/entity/MobCategory.hpp"
|
||||
#include "server/ServerLevel.hpp"
|
||||
|
||||
#ifdef CREATORMODE
|
||||
#include "server/CreatorLevel.hpp"
|
||||
#endif
|
||||
|
||||
#include "network/command/CommandServer.hpp"
|
||||
|
||||
/*static*/
|
||||
const char* Minecraft::progressMessages[] = {
|
||||
"Locating server",
|
||||
"Building terrain",
|
||||
"Preparing",
|
||||
"Saving chunks"
|
||||
};
|
||||
|
||||
// int Minecraft::customDebugId = Minecraft::CDI_NONE;
|
||||
bool Minecraft::_hasInitedStatics = false;
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning( disable : 4355 ) // 'this' pointer in initialization list which is perfectly legal
|
||||
#endif
|
||||
|
||||
// Minecraft::Minecraft() :
|
||||
// #ifdef __APPLE__
|
||||
// _isSuperFast(false),
|
||||
// #endif
|
||||
|
||||
|
||||
// #if defined(NO_NETWORK)
|
||||
// raknetInstance = new IRakNetInstance();
|
||||
// #else
|
||||
// raknetInstance = new RakNetInstance();
|
||||
// #endif
|
||||
// #ifndef STANDALONE_SERVER
|
||||
// soundEngine = new SoundEngine(20.0f);
|
||||
// soundEngine->init(this, &options);
|
||||
// #endif
|
||||
// //setupPieces();
|
||||
|
||||
// #if defined(ANDROID) || defined(__APPLE__) || defined(RPI)
|
||||
// signal(SIGPIPE, SIG_IGN);
|
||||
// #endif
|
||||
|
||||
// externalCacheStoragePath = '.';
|
||||
// externalCacheStoragePath = '.';
|
||||
// }
|
||||
|
||||
Minecraft::~Minecraft() {
|
||||
delete netCallback;
|
||||
delete raknetInstance;
|
||||
delete gameMode;
|
||||
|
||||
if (level != NULL) {
|
||||
level->saveGame();
|
||||
if (level->getChunkSource())
|
||||
level->getChunkSource()->saveAll(true);
|
||||
delete level->getLevelStorage();
|
||||
delete level;
|
||||
level = NULL;
|
||||
}
|
||||
|
||||
//delete player;
|
||||
delete storageSource;
|
||||
delete _commandServer;
|
||||
|
||||
MobFactory::clearStaticTestMobs();
|
||||
|
||||
// Note: Don't tear down statics if we run on Android
|
||||
// (we might change this in the future)
|
||||
#ifndef ANDROID
|
||||
Biome::teardownBiomes();
|
||||
Item ::teardownItems();
|
||||
Tile ::teardownTiles();
|
||||
Material::teardownMaterials();
|
||||
Recipes ::teardownRecipes();
|
||||
TileEntity::teardownTileEntities();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Only called by server
|
||||
void Minecraft::selectLevel( const std::string& levelId, const std::string& levelName, const LevelSettings& settings ) {
|
||||
level = (Level*)new ServerLevel(
|
||||
storageSource->selectLevel(levelId, false),
|
||||
levelName,
|
||||
settings,
|
||||
SharedConstants::GeneratorVersion
|
||||
);
|
||||
|
||||
// note: settings is useless beyond this point, since it's
|
||||
// either copied to LevelData (or LevelData read from file)
|
||||
setLevel(level, "Generating level");
|
||||
setIsCreativeMode(level->getLevelData()->getGameType() == GameType::Creative);
|
||||
_running = true;
|
||||
}
|
||||
|
||||
void Minecraft::setLevel(Level* level, const std::string& message, Player* forceInsertPlayer) {
|
||||
LOGI("Seed is %ld\n", level->getSeed());
|
||||
|
||||
if (level != NULL) {
|
||||
level->raknetInstance = raknetInstance;
|
||||
gameMode->initLevel(level);
|
||||
|
||||
this->level = level;
|
||||
_hasSignaledGeneratingLevelFinished = false;
|
||||
#ifdef STANDALONE_SERVER
|
||||
const bool threadedLevelCreation = false;
|
||||
#else
|
||||
const bool threadedLevelCreation = true;
|
||||
#endif
|
||||
|
||||
if (threadedLevelCreation) {
|
||||
// Threaded
|
||||
// "Lock"
|
||||
isGeneratingLevel = true;
|
||||
generateLevelThread = new CThread(Minecraft::prepareLevel_tspawn, this);
|
||||
} else {
|
||||
// Non-threaded
|
||||
generateLevel("Currently not used", level);
|
||||
}
|
||||
}
|
||||
|
||||
this->lastTickTime = 0;
|
||||
this->_running = true;
|
||||
}
|
||||
|
||||
void Minecraft::prepareLevel(const std::string& title) {
|
||||
LOGI("status: 1\n");
|
||||
progressStageStatusId = 1;
|
||||
|
||||
Stopwatch A, B, C, D;
|
||||
A.start();
|
||||
|
||||
Stopwatch L;
|
||||
|
||||
// Dont update lights if we load the level (ok, actually just with leveldata version=1.+(?))
|
||||
if (!level->isNew())
|
||||
level->setUpdateLights(false);
|
||||
|
||||
int Max = CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH;
|
||||
int pp = 0;
|
||||
for (int x = 8; x < (CHUNK_CACHE_WIDTH * CHUNK_WIDTH); x += CHUNK_WIDTH) {
|
||||
for (int z = 8; z < (CHUNK_CACHE_WIDTH * CHUNK_WIDTH); z += CHUNK_WIDTH) {
|
||||
progressStagePercentage = 100 * pp++ / Max;
|
||||
//printf("level generation progress %d\n", progressStagePercentage);
|
||||
B.start();
|
||||
level->getTile(x, 64, z);
|
||||
B.stop();
|
||||
L.start();
|
||||
if (level->isNew())
|
||||
while (level->updateLights())
|
||||
;
|
||||
L.stop();
|
||||
}
|
||||
}
|
||||
A.stop();
|
||||
level->setUpdateLights(true);
|
||||
|
||||
C.start();
|
||||
for (int x = 0; x < CHUNK_CACHE_WIDTH; x++)
|
||||
{
|
||||
for (int z = 0; z < CHUNK_CACHE_WIDTH; z++)
|
||||
{
|
||||
LevelChunk* chunk = level->getChunk(x, z);
|
||||
if (chunk && !chunk->createdFromSave)
|
||||
{
|
||||
chunk->unsaved = false;
|
||||
chunk->clearUpdateMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
C.stop();
|
||||
|
||||
LOGI("status: 3\n");
|
||||
progressStageStatusId = 3;
|
||||
if (level->isNew()) {
|
||||
level->setInitialSpawn(); // @note: should obviously be called from Level itself
|
||||
level->saveLevelData();
|
||||
level->getChunkSource()->saveAll(false);
|
||||
level->saveGame();
|
||||
} else {
|
||||
level->saveLevelData();
|
||||
level->loadEntities();
|
||||
}
|
||||
|
||||
progressStagePercentage = -1;
|
||||
progressStageStatusId = 2;
|
||||
LOGI("status: 2\n");
|
||||
|
||||
D.start();
|
||||
level->prepare();
|
||||
D.stop();
|
||||
|
||||
A.print("Generate level: ");
|
||||
L.print(" - light: ");
|
||||
B.print(" - getTl: ");
|
||||
C.print(" - clear: ");
|
||||
D.print(" - prepr: ");
|
||||
progressStageStatusId = 0;
|
||||
}
|
||||
|
||||
void Minecraft::update() {
|
||||
|
||||
timer.advanceTime();
|
||||
raknetInstance->runEvents(netCallback);
|
||||
|
||||
TIMER_PUSH("tick");
|
||||
int toTick = timer.ticks;
|
||||
timer.ticks = 0;
|
||||
for (int i = 0; i < toTick; ++i, ++ticks) tick(i, toTick-1);
|
||||
|
||||
TIMER_POP_PUSH("updatelights");
|
||||
{
|
||||
if (level && !isGeneratingLevel) {
|
||||
level->updateLights();
|
||||
}
|
||||
}
|
||||
TIMER_POP();
|
||||
|
||||
|
||||
// Restart the server if (our modded) RakNet reports an error
|
||||
if (level && raknetInstance->isProbablyBroken() && raknetInstance->isServer()) {
|
||||
restartServer();
|
||||
}
|
||||
}
|
||||
|
||||
void Minecraft::restartServer() {
|
||||
if (!level) return;
|
||||
|
||||
raknetInstance->resetIsBroken();
|
||||
|
||||
hostMultiplayer();
|
||||
if (netCallback) netCallback->levelGenerated(level);
|
||||
}
|
||||
|
||||
void Minecraft::tick(int nTick, int maxTick) {
|
||||
if (missTime > 0) missTime--;
|
||||
|
||||
TIMER_PUSH("gameMode");
|
||||
if (level) {
|
||||
gameMode->tick();
|
||||
}
|
||||
|
||||
TIMER_POP_PUSH("commandServer");
|
||||
if (level && _commandServer) {
|
||||
_commandServer->tick();
|
||||
}
|
||||
|
||||
//
|
||||
// Ongoing level generation in a (perhaps) different thread. When it's
|
||||
// ready, _levelGenerated() is called once and any threads are deleted.
|
||||
//
|
||||
if (isGeneratingLevel) {
|
||||
return;
|
||||
} else if (!_hasSignaledGeneratingLevelFinished) {
|
||||
if (generateLevelThread) {
|
||||
delete generateLevelThread;
|
||||
generateLevelThread = NULL;
|
||||
}
|
||||
_levelGenerated();
|
||||
}
|
||||
|
||||
//
|
||||
// Normal game loop, run before or efter level generation
|
||||
//
|
||||
if (level != NULL) {
|
||||
TIMER_POP_PUSH("level");
|
||||
level->tickEntities();
|
||||
level->tick();
|
||||
}
|
||||
|
||||
TIMER_POP();
|
||||
}
|
||||
|
||||
bool Minecraft::isOnlineClient() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Minecraft::isOnline() {
|
||||
return netCallback != NULL;
|
||||
}
|
||||
|
||||
void Minecraft::init()
|
||||
{
|
||||
// WHY DO WE NEED THIS ON MODERN PLATFORMS :sob:
|
||||
// Global initialization goes here
|
||||
Mth::initMth();
|
||||
|
||||
if (raknetInstance != nullptr) {
|
||||
delete raknetInstance;
|
||||
}
|
||||
|
||||
raknetInstance = new RakNetInstance();
|
||||
|
||||
// If we're running Android, only initialize
|
||||
// the first time class is instanced
|
||||
#ifdef ANDROID
|
||||
if (!_hasInitedStatics) {
|
||||
_hasInitedStatics = true;
|
||||
#endif
|
||||
Material::initMaterials();
|
||||
MobCategory::initMobCategories();
|
||||
Tile::initTiles();
|
||||
Item::initItems();
|
||||
Biome::initBiomes();
|
||||
TileEntity::initTileEntities();
|
||||
|
||||
#ifdef ANDROID
|
||||
}
|
||||
#endif
|
||||
|
||||
setIsCreativeMode(false); // false means it's Survival Mode
|
||||
|
||||
#if !defined(NO_STORAGE)
|
||||
storageSource = new ExternalFileLevelStorageSource(externalStoragePath, externalCacheStoragePath);
|
||||
#else
|
||||
storageSource = new MemoryLevelStorageSource();
|
||||
#endif
|
||||
|
||||
// Server-only featire @todo server class app
|
||||
hostMultiplayer();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Multiplayer
|
||||
//
|
||||
|
||||
void Minecraft::hostMultiplayer(int port) {
|
||||
// Tear down last instance
|
||||
raknetInstance->disconnect();
|
||||
delete netCallback;
|
||||
netCallback = nullptr;
|
||||
|
||||
#if !defined(NO_NETWORK)
|
||||
netCallback = new ServerSideNetworkHandler(this, raknetInstance);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Level generation
|
||||
//
|
||||
/*static*/
|
||||
|
||||
void* Minecraft::prepareLevel_tspawn(void *p_param) {
|
||||
Minecraft* mc = (Minecraft*) p_param;
|
||||
mc->generateLevel("Currently not used", mc->level);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Minecraft::generateLevel( const std::string& message, Level* level ) {
|
||||
Stopwatch s;
|
||||
s.start();
|
||||
prepareLevel(message);
|
||||
s.stop();
|
||||
s.print("Level generated: ");
|
||||
|
||||
// "Unlock"
|
||||
isGeneratingLevel = false;
|
||||
}
|
||||
|
||||
void Minecraft::_levelGenerated() {
|
||||
level->validateSpawn();
|
||||
|
||||
if (raknetInstance->isServer())
|
||||
raknetInstance->announceServer(getServerName());
|
||||
|
||||
if (netCallback) {
|
||||
netCallback->levelGenerated(level);
|
||||
}
|
||||
|
||||
_hasSignaledGeneratingLevelFinished = true;
|
||||
}
|
||||
|
||||
Player* Minecraft::respawnPlayer(int playerId) {
|
||||
for (unsigned int i = 0; i < level->players.size(); ++i) {
|
||||
if (level->players[i]->entityId == playerId) {
|
||||
resetPlayer(level->players[i]);
|
||||
return level->players[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Minecraft::resetPlayer(Player* player) {
|
||||
level->validateSpawn();
|
||||
player->reset();
|
||||
|
||||
Pos p;
|
||||
if(player->hasRespawnPosition()) {
|
||||
p = player->getRespawnPosition();
|
||||
}
|
||||
else {
|
||||
p = level->getSharedSpawnPos();
|
||||
}
|
||||
player->setPos((float)p.x + 0.5f, (float)p.y + 1.0f, (float)p.z + 0.5f);
|
||||
player->resetPos(true);
|
||||
|
||||
if (isCreativeMode())
|
||||
player->inventory->clearInventoryWithDefault();
|
||||
}
|
||||
|
||||
int Minecraft::getProgressStatusId() {
|
||||
return progressStageStatusId;
|
||||
}
|
||||
|
||||
const char* Minecraft::getProgressMessage()
|
||||
{
|
||||
return progressMessages[progressStageStatusId];
|
||||
}
|
||||
|
||||
bool Minecraft::isLevelGenerated()
|
||||
{
|
||||
return level != NULL && !isGeneratingLevel;
|
||||
}
|
||||
|
||||
LevelStorageSource* Minecraft::getLevelSource()
|
||||
{
|
||||
return storageSource;
|
||||
}
|
||||
|
||||
void Minecraft::setIsCreativeMode(bool isCreative)
|
||||
{
|
||||
#ifdef CREATORMODE
|
||||
delete gameMode;
|
||||
gameMode = new CreatorMode(this);
|
||||
_isCreativeMode = true;
|
||||
#else
|
||||
if (!gameMode || isCreative != _isCreativeMode)
|
||||
{
|
||||
delete gameMode;
|
||||
if (isCreative) gameMode = new CreativeMode(*this);
|
||||
else gameMode = new SurvivalMode(*this);
|
||||
_isCreativeMode = isCreative;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Minecraft::isCreativeMode() {
|
||||
return _isCreativeMode;
|
||||
}
|
||||
|
||||
ICreator* Minecraft::getCreator()
|
||||
{
|
||||
#ifdef CREATORMODE
|
||||
return ((CreatorMode*)gameMode)->getCreator();
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Minecraft::optionUpdated(OptionId option, bool value ) {
|
||||
if(netCallback != NULL && option == OPTIONS_SERVER_VISIBLE) {
|
||||
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) netCallback;
|
||||
ss->allowIncomingConnections(value);
|
||||
}
|
||||
}
|
||||
|
||||
void Minecraft::optionUpdated(OptionId option, float value ) {}
|
||||
|
||||
void Minecraft::optionUpdated(OptionId option, int value ) {}
|
||||
@@ -1,138 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "client/Options.hpp"
|
||||
#include "client/Timer.hpp"
|
||||
|
||||
//#include "../network/RakNetInstance.hpp"
|
||||
#include "world/phys/HitResult.hpp"
|
||||
|
||||
#include "App.hpp"
|
||||
#include <cstddef>
|
||||
|
||||
class Level;
|
||||
class LocalPlayer;
|
||||
class IInputHolder;
|
||||
class Mob;
|
||||
class Player;
|
||||
class Entity;
|
||||
class ICreator;
|
||||
class GameMode;
|
||||
class CThread;
|
||||
class LevelStorageSource;
|
||||
class BuildActionIntention;
|
||||
class PerfRenderer;
|
||||
class LevelSettings;
|
||||
class IRakNetInstance;
|
||||
class NetEventCallback;
|
||||
class CommandServer;
|
||||
struct PingedCompatibleServer;
|
||||
|
||||
class Minecraft: public App {
|
||||
public:
|
||||
using App::App;
|
||||
virtual ~Minecraft();
|
||||
|
||||
virtual void init();
|
||||
virtual void update();
|
||||
virtual void restartServer();
|
||||
virtual void tick(int nTick, int maxTick);
|
||||
|
||||
virtual bool isOnlineClient();
|
||||
virtual bool isOnline();
|
||||
|
||||
virtual void setIsCreativeMode(bool isCreative);
|
||||
|
||||
virtual void optionUpdated(OptionId option, bool value);
|
||||
virtual void optionUpdated(OptionId option, float value);
|
||||
virtual void optionUpdated(OptionId option, int value);
|
||||
|
||||
/**
|
||||
* @brief Get public name that will be listed in JoinGame menu
|
||||
*/
|
||||
virtual std::string getServerName() { return "Unknown"; }
|
||||
|
||||
void toggleDimension() {}
|
||||
bool isCreativeMode();
|
||||
|
||||
virtual void selectLevel(const std::string& levelId, const std::string& levelName, const LevelSettings& settings);
|
||||
virtual void setLevel(Level* level, const std::string& message = "", Player* forceInsertPlayer = NULL);
|
||||
|
||||
virtual void onBlockDestroyed(Player* player, int x, int y, int z, int face) {}
|
||||
|
||||
void generateLevel( const std::string& message, Level* level );
|
||||
LevelStorageSource* getLevelSource();
|
||||
|
||||
virtual void hostMultiplayer(int port=19132);
|
||||
Player* respawnPlayer(int playerId);
|
||||
void respawnPlayer();
|
||||
void resetPlayer(Player* player);
|
||||
void doActuallyRespawnPlayer();
|
||||
|
||||
void prepareLevel(const std::string& message);
|
||||
|
||||
int getProgressStatusId();
|
||||
const char* getProgressMessage();
|
||||
|
||||
ICreator* getCreator();
|
||||
|
||||
bool isLevelGenerated();
|
||||
|
||||
#ifdef __APPLE__
|
||||
bool _isSuperFast = false;
|
||||
bool isSuperFast() { return _isSuperFast; }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void _levelGenerated();
|
||||
|
||||
private:
|
||||
static void* prepareLevel_tspawn(void *p_param);
|
||||
public:
|
||||
Level* level = nullptr;
|
||||
CommandServer* _commandServer = nullptr;
|
||||
GameMode* gameMode = nullptr;
|
||||
IRakNetInstance* raknetInstance = nullptr;
|
||||
NetEventCallback* netCallback = nullptr;
|
||||
|
||||
int commandPort = 4711;
|
||||
|
||||
int lastTime = 0;
|
||||
int lastTickTime = -1;
|
||||
int missTime = 0;
|
||||
int ticks = 0;
|
||||
|
||||
CThread* generateLevelThread = nullptr;
|
||||
// static int customDebugId;
|
||||
|
||||
HitResult hitResult;
|
||||
volatile int progressStagePercentage = 0;
|
||||
|
||||
// This field is initialized in main()
|
||||
// It sets the base path to where worlds can be written (sdcard on android)
|
||||
std::string externalStoragePath;
|
||||
std::string externalCacheStoragePath;
|
||||
protected:
|
||||
Timer timer{20};
|
||||
// @note @attn @warn: this is dangerous as fuck!
|
||||
volatile bool isGeneratingLevel = false;
|
||||
bool _hasSignaledGeneratingLevelFinished = true;
|
||||
|
||||
LevelStorageSource* storageSource;
|
||||
bool _running;
|
||||
|
||||
protected:
|
||||
volatile int progressStageStatusId = 0;
|
||||
static const char* progressMessages[];
|
||||
|
||||
int _licenseId;
|
||||
|
||||
bool _isCreativeMode;
|
||||
Player* _pendingRemovePlayer; // @attn @todo @fix: remove this shait and fix the respawn behaviour
|
||||
|
||||
// from NinecraftApp
|
||||
bool _verbose = true;
|
||||
int _lastTickMs = 0;
|
||||
|
||||
static bool _hasInitedStatics;
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,142 +0,0 @@
|
||||
#pragma once
|
||||
#include "client/gui/Font.hpp"
|
||||
#include "client/gui/Screen.hpp"
|
||||
#include "client/particle/ParticleEngine.hpp"
|
||||
#include "client/player/LocalPlayer.hpp"
|
||||
#include "client/renderer/GameRenderer.hpp"
|
||||
#include "client/renderer/Textures.hpp"
|
||||
#include "client/sound/SoundEngine.hpp"
|
||||
#include <Minecraft.hpp>
|
||||
|
||||
#include <client/MouseHandler.hpp>
|
||||
#include <client/gui/Gui.hpp>
|
||||
#include <client/gui/screens/ScreenChooser.hpp>
|
||||
#include <client/PixelCalc.hpp>
|
||||
#include <client/renderer/LevelRenderer.hpp>
|
||||
|
||||
class MinecraftClient : public Minecraft {
|
||||
public:
|
||||
using Minecraft::Minecraft;
|
||||
~MinecraftClient();
|
||||
|
||||
void init() override;
|
||||
|
||||
void update() override;
|
||||
|
||||
void setSize(int width, int height);
|
||||
void reloadOptions();
|
||||
|
||||
bool supportNonTouchScreen();
|
||||
bool useTouchscreen();
|
||||
void grabMouse();
|
||||
void releaseMouse();
|
||||
|
||||
void setScreen(Screen*);
|
||||
void leaveGame(bool renameLevel = false);
|
||||
|
||||
void setLevel(Level* level, const std::string& message = "", Player* forceInsertPlayer = NULL) override;
|
||||
|
||||
void updateStats();
|
||||
|
||||
void restartServer() override;
|
||||
|
||||
bool handleBack(bool isDown) override;
|
||||
|
||||
void onGraphicsReset();
|
||||
void initGLStates();
|
||||
|
||||
void tick(int nTick, int maxTick) override;
|
||||
void tickInput();
|
||||
|
||||
void handleBuildAction(BuildActionIntention* action);
|
||||
|
||||
bool isOnlineClient() override;
|
||||
|
||||
void pauseGame(bool isBackPaused);
|
||||
void gameLostFocus();
|
||||
|
||||
void respawnPlayer();
|
||||
|
||||
void audioEngineOn() override;
|
||||
void audioEngineOff() override;
|
||||
|
||||
void setIsCreativeMode(bool isCreative) override;
|
||||
|
||||
void optionUpdated(OptionId option, bool value) override;
|
||||
void optionUpdated(OptionId option, float value) override;
|
||||
void optionUpdated(OptionId option, int value) override;
|
||||
|
||||
LocalPlayer* getPlayer() { return player; }
|
||||
Font* getFont() { return font; }
|
||||
Textures& textures() { return m_textures; }
|
||||
Options& options() { return m_options;}
|
||||
Screen* getScreen() { return m_screen; }
|
||||
Gui& gui() { return m_gui; }
|
||||
ParticleEngine* getParticleEngine() {return particleEngine; }
|
||||
|
||||
int getScreenWidth() { return width; }
|
||||
int getScreenHeigth() { return height; }
|
||||
|
||||
virtual void hostMultiplayer(int port) override;
|
||||
|
||||
bool isPowerVR() { return _powerVr; }
|
||||
bool isKindleFire(int kindleVersion);
|
||||
bool transformResolution(int* w, int* h);
|
||||
|
||||
virtual std::string getServerName() override;
|
||||
|
||||
void locateMultiplayer();
|
||||
void cancelLocateMultiplayer();
|
||||
bool joinMultiplayer(const PingedCompatibleServer& server);
|
||||
bool joinMultiplayerFromString(const std::string& server);
|
||||
|
||||
void onBlockDestroyed(Player* player, int x, int y, int z, int face) override;
|
||||
|
||||
protected:
|
||||
void _reloadInput();
|
||||
void _levelGenerated() override;
|
||||
|
||||
int width = 1, height = 1;
|
||||
|
||||
Font* font = nullptr;
|
||||
// @warn This is unsafe cuz Gui may call some MinecraftClient method while MinecraftClient is not ready
|
||||
MouseHandler mouseHandler;
|
||||
|
||||
LevelRenderer* levelRenderer = nullptr;
|
||||
GameRenderer* gameRenderer = nullptr;
|
||||
ParticleEngine* particleEngine = nullptr;
|
||||
SoundEngine* soundEngine = nullptr;
|
||||
PerfRenderer* _perfRenderer = nullptr;
|
||||
|
||||
bool mouseGrabbed = false;
|
||||
|
||||
PixelCalc pixelCalc;
|
||||
PixelCalc pixelCalcUi;
|
||||
|
||||
Screen* m_screen = nullptr;
|
||||
|
||||
bool screenMutex = false;
|
||||
bool hasScheduledScreen = false;
|
||||
Screen* scheduledScreen = nullptr;
|
||||
|
||||
int m_frames = 0;
|
||||
|
||||
volatile bool pause = false;
|
||||
|
||||
// @todo make static
|
||||
LocalPlayer* player = nullptr;
|
||||
IInputHolder* inputHolder = nullptr;
|
||||
Mob* cameraTargetPlayer = nullptr;
|
||||
|
||||
bool _supportsNonTouchscreen = false;
|
||||
bool isLookingForMultiplayer = false;
|
||||
bool _powerVr = false;
|
||||
|
||||
Options m_options{*this};
|
||||
|
||||
Textures m_textures{m_options, *m_platform};
|
||||
|
||||
ScreenChooser screenChooser{*this};
|
||||
|
||||
Gui m_gui{*this};
|
||||
};
|
||||
@@ -1,15 +0,0 @@
|
||||
#include "MinecraftServer.hpp"
|
||||
#include <Minecraft.hpp>
|
||||
#include <network/RakNetInstance.hpp>
|
||||
|
||||
|
||||
void MinecraftServer::hostMultiplayer(int port) {
|
||||
Minecraft::hostMultiplayer(port);
|
||||
|
||||
raknetInstance->host("Server", port, 16);
|
||||
}
|
||||
|
||||
std::string MinecraftServer::getServerName() {
|
||||
// @todo read server name from config
|
||||
return "Dedicated server 0.6.1";
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
#pragma once
|
||||
#include <Minecraft.hpp>
|
||||
|
||||
class MinecraftServer : public Minecraft {
|
||||
public:
|
||||
using Minecraft::Minecraft;
|
||||
|
||||
void hostMultiplayer(int port) override;
|
||||
std::string getServerName() override;
|
||||
};
|
||||
425
src/NinecraftApp.cpp
Executable file
425
src/NinecraftApp.cpp
Executable file
@@ -0,0 +1,425 @@
|
||||
#include "NinecraftApp.h"
|
||||
//#include <EGL/egl.h>
|
||||
|
||||
#ifdef RPI
|
||||
//#define NO_STORAGE
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include "platform/input/Mouse.h"
|
||||
#include "platform/input/Multitouch.h"
|
||||
|
||||
#include "world/item/Item.h"
|
||||
#include "world/level/Level.h"
|
||||
#include "world/level/biome/Biome.h"
|
||||
#include "world/level/material/Material.h"
|
||||
#include "world/entity/MobCategory.h"
|
||||
//#include "world/level/storage/FolderMethods.h"
|
||||
#ifndef STANDALONE_SERVER
|
||||
#include "client/gui/screens/StartMenuScreen.h"
|
||||
#include "client/gui/screens/UsernameScreen.h"
|
||||
#endif
|
||||
#include "client/player/LocalPlayer.h"
|
||||
#ifndef STANDALONE_SERVER
|
||||
#include "client/renderer/gles.h"
|
||||
#include "client/renderer/Chunk.h"
|
||||
#include "client/renderer/LevelRenderer.h"
|
||||
#include "client/renderer/Tesselator.h"
|
||||
#endif
|
||||
// sorry for raknet dependency, but I'm too lazy to find another getTime method
|
||||
#include "raknet/GetTime.h"
|
||||
#include "network/RakNetInstance.h"
|
||||
#include "network/ClientSideNetworkHandler.h"
|
||||
#include "client/gui/screens/ProgressScreen.h"
|
||||
|
||||
//#include "world/entity/player/Inventory2.h"
|
||||
|
||||
#if !defined(DEMO_MODE) && !defined(APPLE_DEMO_PROMOTION) && !defined(NO_STORAGE)
|
||||
#include "world/level/storage/ExternalFileLevelStorageSource.h"
|
||||
#else
|
||||
#include "world/level/storage/MemoryLevelStorageSource.h"
|
||||
#endif
|
||||
#ifndef STANDALONE_SERVER
|
||||
#include "client/renderer/Textures.h"
|
||||
#include "client/renderer/entity/ItemRenderer.h"
|
||||
#endif
|
||||
#include "world/item/crafting/Recipes.h"
|
||||
#include "world/level/tile/entity/TileEntity.h"
|
||||
#ifndef STANDALONE_SERVER
|
||||
#include "client/renderer/EntityTileRenderer.h"
|
||||
#endif
|
||||
|
||||
bool NinecraftApp::_hasInitedStatics = false;
|
||||
|
||||
NinecraftApp::NinecraftApp()
|
||||
: _verbose(true),
|
||||
_lastTickMs(0),
|
||||
_frames(0)
|
||||
{
|
||||
#if defined(ANDROID) || defined(__APPLE__) || defined(RPI)
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
#endif
|
||||
}
|
||||
|
||||
NinecraftApp::~NinecraftApp()
|
||||
{
|
||||
teardown();
|
||||
}
|
||||
|
||||
void NinecraftApp::init()
|
||||
{
|
||||
// Global initialization goes here
|
||||
Mth::initMth();
|
||||
|
||||
//#ifdef DEMO_MODE
|
||||
//writeDemoFile();
|
||||
//#endif
|
||||
|
||||
// If we're running Android, only initialize
|
||||
// the first time class is instanced
|
||||
#ifdef ANDROID
|
||||
if (!_hasInitedStatics) {
|
||||
_hasInitedStatics = true;
|
||||
#endif
|
||||
Material::initMaterials();
|
||||
MobCategory::initMobCategories();
|
||||
Tile::initTiles();
|
||||
Item::initItems();
|
||||
Biome::initBiomes();
|
||||
TileEntity::initTileEntities();
|
||||
|
||||
#ifdef ANDROID
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef STANDALONE_SERVER
|
||||
initGLStates();
|
||||
Tesselator::instance.init();
|
||||
I18n::loadLanguage(platform(), "en_US");
|
||||
#endif
|
||||
|
||||
Minecraft::init();
|
||||
|
||||
#if !defined(DEMO_MODE) && !defined(APPLE_DEMO_PROMOTION) && !defined(NO_STORAGE)
|
||||
storageSource = new ExternalFileLevelStorageSource(externalStoragePath, externalCacheStoragePath);
|
||||
#else
|
||||
storageSource = new MemoryLevelStorageSource();
|
||||
#endif
|
||||
_running = false;
|
||||
|
||||
#ifndef STANDALONE_SERVER
|
||||
LOGI("This: %p\n", this);
|
||||
screenChooser.setScreen(SCREEN_STARTMENU);
|
||||
|
||||
if (options.getBooleanValue(OPTIONS_FIRST_LAUNCH)) {
|
||||
options.toggle(OPTIONS_FIRST_LAUNCH);
|
||||
setScreen(new UsernameScreen());
|
||||
}
|
||||
#else
|
||||
user->name = "Server";
|
||||
hostMultiplayer();
|
||||
#endif
|
||||
}
|
||||
|
||||
void NinecraftApp::teardown()
|
||||
{
|
||||
// Note: Don't tear down statics if we run on Android
|
||||
// (we might change this in the future)
|
||||
#ifndef ANDROID
|
||||
Biome::teardownBiomes();
|
||||
Item ::teardownItems();
|
||||
Tile ::teardownTiles();
|
||||
Material::teardownMaterials();
|
||||
Recipes ::teardownRecipes();
|
||||
TileEntity::teardownTileEntities();
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
ItemRenderer::teardown_static();
|
||||
if (EntityTileRenderer::instance != NULL) {
|
||||
delete EntityTileRenderer::instance;
|
||||
EntityTileRenderer::instance = NULL;
|
||||
}
|
||||
TileEntityRenderDispatcher::destroy();
|
||||
#endif
|
||||
}
|
||||
|
||||
void NinecraftApp::update()
|
||||
{
|
||||
++_frames;
|
||||
|
||||
// Generate Multitouch active pointer list
|
||||
Multitouch::commit();
|
||||
|
||||
#ifndef ANDROID_PUBLISH
|
||||
//testCreationAndDestruction();
|
||||
//testJoiningAndDestruction();
|
||||
#endif /*ANDROID_PUBLISH*/
|
||||
|
||||
Minecraft::update();
|
||||
|
||||
swapBuffers();
|
||||
Mouse::reset2();
|
||||
|
||||
// Restart the server if (our modded) RakNet reports an error
|
||||
if (level && raknetInstance->isProbablyBroken() && raknetInstance->isServer()) {
|
||||
restartServer();
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
updateStats();
|
||||
#endif
|
||||
}
|
||||
|
||||
void NinecraftApp::updateStats()
|
||||
{
|
||||
#ifndef STANDALONE_SERVER
|
||||
if (Options::debugGl)
|
||||
LOGI("--------------------------------------------\n");
|
||||
|
||||
//*
|
||||
int now = getTimeMs();
|
||||
//int since = now - _lastTickMs;
|
||||
|
||||
if (now >= lastTime + 1000)
|
||||
{
|
||||
if (player) {
|
||||
LOGI("%d fps \t%3d chunk updates. (%.2f, %.2f, %.2f)\n",
|
||||
_frames, Chunk::updates, player->x, player->y, player->z);
|
||||
Chunk::resetUpdates();
|
||||
|
||||
//static int _n = 0;
|
||||
//if (++_n % 5 == -1) { // @note: -1
|
||||
// static char filename[256];
|
||||
// sprintf(filename, "%s/games/com.mojang/img_%.4d.jpg", externalStoragePath.c_str(), _n/5);
|
||||
// _context.platform->saveScreenshot(filename, width, height);
|
||||
//}
|
||||
|
||||
LOGI("%s", levelRenderer->gatherStats1().c_str());
|
||||
//printf("Texture swaps (this frame): %d\n", Textures::textureChanges);
|
||||
} else {
|
||||
LOGI("%d fps\n", _frames);
|
||||
}
|
||||
|
||||
//const int* pointerIds;
|
||||
//int pointerCount = Multitouch::getActivePointerIds(&pointerIds);
|
||||
//if (pointerCount) {
|
||||
// std::string s = "Pointers (";
|
||||
// s += (char)(48 + pointerCount);
|
||||
// s += ": ";
|
||||
// for (int i = 0; i < pointerCount; ++i) {
|
||||
// s += (char)(48 + pointerIds[i]);
|
||||
// s += ", ";
|
||||
// }
|
||||
// LOGI("%s\n", s.c_str());
|
||||
//}
|
||||
|
||||
lastTime = now;
|
||||
_frames = 0;
|
||||
#ifdef GLDEBUG
|
||||
while (1) {
|
||||
int error = glGetError();
|
||||
if (error == GL_NO_ERROR) break;
|
||||
|
||||
LOGI("#################### GL-ERROR: %d\t#####################\n", error);
|
||||
LOGI("#################### GL-ERROR: %d\t#####################\n", error);
|
||||
LOGI("#################### GL-ERROR: %d\t#####################\n", error);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
Textures::textureChanges = 0;
|
||||
/**/
|
||||
#endif /* STANDALONE_SERVER */
|
||||
}
|
||||
|
||||
void NinecraftApp::initGLStates()
|
||||
{
|
||||
#ifndef STANDALONE_SERVER
|
||||
//glShadeModel2(GL_SMOOTH);
|
||||
//glClearDepthf(1.0f);
|
||||
glEnable2(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glDepthRangef(0, 1);
|
||||
glEnable2(GL_ALPHA_TEST);
|
||||
glAlphaFunc(GL_GREATER, 0.1f);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
glEnable2(GL_TEXTURE_2D);
|
||||
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST);
|
||||
|
||||
// Both updates isPowerVR flag in java and returns if the graphics chip is PowerVR SGX or not
|
||||
_powerVr = platform()->isPowerVR();
|
||||
#ifdef __APPLE__
|
||||
_isSuperFast = platform()->isSuperFast();
|
||||
#endif
|
||||
//glLineWidth(4);
|
||||
#endif /* STANDALONE_SERVER */
|
||||
}
|
||||
|
||||
void NinecraftApp::restartServer() {
|
||||
if (!level) return;
|
||||
|
||||
for (int i = level->players.size()-1; i >= 0; --i) {
|
||||
Player* p = level->players[i];
|
||||
if (p != player)
|
||||
level->removeEntity(p);
|
||||
}
|
||||
|
||||
raknetInstance->resetIsBroken();
|
||||
#ifndef STANDALONE_SERVER
|
||||
gui.addMessage("This server has restarted!");
|
||||
#endif
|
||||
hostMultiplayer();
|
||||
if (netCallback) netCallback->levelGenerated(level);
|
||||
}
|
||||
|
||||
bool NinecraftApp::handleBack(bool isDown)
|
||||
{
|
||||
if (isGeneratingLevel)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (level)
|
||||
{
|
||||
if (!isDown)
|
||||
{
|
||||
if (screen)
|
||||
{
|
||||
if (!screen->handleBackEvent(isDown))
|
||||
{
|
||||
if (player->containerMenu) player->closeContainer();
|
||||
setScreen(NULL);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
pauseGame(true);
|
||||
}
|
||||
//leaveGame();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else if (screen)
|
||||
{
|
||||
return screen->handleBackEvent(isDown);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void NinecraftApp::onGraphicsReset()
|
||||
{
|
||||
#ifndef STANDALONE_SERVER
|
||||
initGLStates();
|
||||
Tesselator::instance.init();
|
||||
|
||||
Minecraft::onGraphicsReset();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef ANDROID_PUBLISH
|
||||
|
||||
static int _state = -1;
|
||||
static int _stateTicksLeft = 0;
|
||||
void NinecraftApp::testCreationAndDestruction()
|
||||
{
|
||||
if (_state == -1) {
|
||||
_stateTicksLeft = 100;
|
||||
_state = 0;
|
||||
}
|
||||
if (_state == 0) {
|
||||
if (--_stateTicksLeft <= 0)
|
||||
_state = 1;
|
||||
}
|
||||
else if (_state == 1) {
|
||||
getLevelSource()->deleteLevel("perf");
|
||||
int seed = getEpochTimeS();
|
||||
LOGI(">seed %d\n", seed);
|
||||
selectLevel("perf", "perf", LevelSettings(seed, GameType::Creative));
|
||||
hostMultiplayer();
|
||||
#ifndef STANDALONE_SERVER
|
||||
setScreen(new ProgressScreen());
|
||||
#endif
|
||||
_state = 2;
|
||||
_stateTicksLeft = 1000;//25000;//00;
|
||||
}
|
||||
else if (_state == 2) {
|
||||
if (isLevelGenerated()) {
|
||||
if (--_stateTicksLeft <= 0) {
|
||||
_state = 3;
|
||||
}
|
||||
}
|
||||
} else if (_state == 3) {
|
||||
leaveGame();
|
||||
_state = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NinecraftApp::testJoiningAndDestruction()
|
||||
{
|
||||
if (_state == -1) {
|
||||
//LightUpdate sz[2] = { LightUpdate(LightLayer::Block, 0, 0, 0, 1, 1, 1),
|
||||
// LightUpdate(LightLayer::Sky, 0, 0, 0, 1, 1, 1) };
|
||||
//LOGI("size of lightupdate: %lu == %d\n", sizeof(LightUpdate), (const char*)&sz[1] - (const char*)&sz[0]);
|
||||
_stateTicksLeft = 100;
|
||||
_state = 0;
|
||||
}
|
||||
if (_state == 0) {
|
||||
if (--_stateTicksLeft <= 0) {
|
||||
raknetInstance->clearServerList();
|
||||
locateMultiplayer();
|
||||
_state = 1;
|
||||
}
|
||||
}
|
||||
else if (_state == 1) {
|
||||
if (!raknetInstance->getServerList().empty()) {
|
||||
PingedCompatibleServer s = raknetInstance->getServerList().at(0);
|
||||
if (s.name.GetLength() > 0) {
|
||||
joinMultiplayer(s);
|
||||
#ifndef STANDALONE_SERVER
|
||||
setScreen(new ProgressScreen());
|
||||
#endif
|
||||
_state = 2;
|
||||
_stateTicksLeft = 80;//1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (_state == 2) {
|
||||
if (isLevelGenerated()) {
|
||||
if (--_stateTicksLeft <= 0) {
|
||||
_state = 3;
|
||||
}
|
||||
}
|
||||
} else if (_state == 3) {
|
||||
leaveGame();
|
||||
_stateTicksLeft = 50;
|
||||
_state = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*ANDROID_PUBLISH*/
|
||||
|
||||
/*
|
||||
void NinecraftApp::writeDemoFile() {
|
||||
std::string path = externalStoragePath + "/games";
|
||||
|
||||
if (createFolderIfNotExists(path.c_str())) {
|
||||
path += "/com.mojang";
|
||||
if (createFolderIfNotExists(path.c_str())) {
|
||||
path += "/minecraftpe";
|
||||
if (createFolderIfNotExists(path.c_str())) {
|
||||
path += "/played_demo";
|
||||
FILE* fp = fopen(path.c_str(), "w");
|
||||
if (fp) fclose(fp);
|
||||
}}}
|
||||
}
|
||||
|
||||
bool NinecraftApp::hasPlayedDemo() {
|
||||
std::string filename = externalStoragePath + "/games/com.mojang/minecraftpe/played_demo";
|
||||
FILE* fp = fopen(filename.c_str(), "r");
|
||||
if (!fp) return false;
|
||||
fclose(fp);
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
52
src/NinecraftApp.h
Executable file
52
src/NinecraftApp.h
Executable file
@@ -0,0 +1,52 @@
|
||||
#ifndef NINECRAFTAPP_H__
|
||||
#define NINECRAFTAPP_H__
|
||||
|
||||
#include "world/Pos.h"
|
||||
#include "App.h"
|
||||
#include "client/Minecraft.h"
|
||||
#include "world/level/storage/MemoryLevelStorage.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
class Level;
|
||||
class LocalPlayer;
|
||||
class ExternalFileLevelStorageSource;
|
||||
|
||||
class NinecraftApp: public Minecraft
|
||||
{
|
||||
public:
|
||||
NinecraftApp();
|
||||
~NinecraftApp();
|
||||
|
||||
void init();
|
||||
void teardown();
|
||||
|
||||
void update();
|
||||
|
||||
virtual bool handleBack(bool isDown);
|
||||
|
||||
protected:
|
||||
void onGraphicsReset();
|
||||
|
||||
private:
|
||||
void initGLStates();
|
||||
void restartServer();
|
||||
|
||||
void updateStats();
|
||||
|
||||
//void writeDemoFile();
|
||||
//bool hasPlayedDemo();
|
||||
|
||||
#ifndef ANDROID_PUBLISH
|
||||
void testCreationAndDestruction();
|
||||
void testJoiningAndDestruction();
|
||||
#endif /*ANDROID_PUBLISH*/
|
||||
|
||||
bool _verbose;
|
||||
int _frames;
|
||||
int _lastTickMs;
|
||||
|
||||
static bool _hasInitedStatics;
|
||||
};
|
||||
|
||||
#endif//NINECRAFTAPP_H__
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "Performance.hpp"
|
||||
#include "Performance.h"
|
||||
|
||||
/*static*/
|
||||
StopwatchHandler Performance::watches;
|
||||
|
||||
12
src/Performance.h
Executable file
12
src/Performance.h
Executable file
@@ -0,0 +1,12 @@
|
||||
#ifndef PERFORMANCE_H__
|
||||
#define PERFORMANCE_H__
|
||||
|
||||
#include "platform/time.h"
|
||||
|
||||
class Performance
|
||||
{
|
||||
public:
|
||||
static StopwatchHandler watches;
|
||||
};
|
||||
|
||||
#endif /*PERFORMANCE_H__*/
|
||||
@@ -1,10 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "platform/time.hpp"
|
||||
|
||||
class Performance
|
||||
{
|
||||
public:
|
||||
static StopwatchHandler watches;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "SharedConstants.hpp"
|
||||
#include "SharedConstants.h"
|
||||
|
||||
namespace Common {
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef NET_MINECRAFT_SharedConstants_H__
|
||||
#define NET_MINECRAFT_SharedConstants_H__
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -30,3 +31,4 @@ namespace SharedConstants
|
||||
//int FULLBRIGHT_LIGHTVALUE = 15 << 20 | 15 << 4;
|
||||
}
|
||||
|
||||
#endif /*NET_MINECRAFT_SharedConstants_H__*/
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "IConfigListener.hpp"
|
||||
#include "Minecraft.hpp"
|
||||
#include "IConfigListener.h"
|
||||
#include "Minecraft.h"
|
||||
#ifndef STANDALONE_SERVER
|
||||
#include "gui/Gui.hpp"
|
||||
#include "gui/Gui.h"
|
||||
#endif /* STANDALONE_SERVER */
|
||||
Config createConfig(Minecraft* mc) {
|
||||
Config c;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#ifndef CONFIGLISTENER_H__
|
||||
#define CONFIGLISTENER_H__
|
||||
|
||||
#include "PixelCalc.hpp"
|
||||
#include "PixelCalc.h"
|
||||
class Minecraft;
|
||||
class Options;
|
||||
|
||||
@@ -44,3 +45,4 @@ public:
|
||||
virtual void onConfigChanged(const Config& config) = 0;
|
||||
};
|
||||
|
||||
#endif /*CONFIGLISTENER_H__*/
|
||||
21
src/client/KeyMapping.h
Normal file
21
src/client/KeyMapping.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef NET_MINECRAFT_CLIENT__KeyMapping_H__
|
||||
#define NET_MINECRAFT_CLIENT__KeyMapping_H__
|
||||
|
||||
//package net.minecraft.client;
|
||||
#include <string>
|
||||
|
||||
class KeyMapping
|
||||
{
|
||||
public:
|
||||
std::string name;
|
||||
int key;
|
||||
|
||||
KeyMapping() {}
|
||||
|
||||
KeyMapping(const std::string& name_, int key_)
|
||||
: name(name_),
|
||||
key(key_)
|
||||
{}
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT__KeyMapping_H__*/
|
||||
1590
src/client/Minecraft.cpp
Executable file
1590
src/client/Minecraft.cpp
Executable file
File diff suppressed because it is too large
Load Diff
230
src/client/Minecraft.h
Executable file
230
src/client/Minecraft.h
Executable file
@@ -0,0 +1,230 @@
|
||||
#ifndef NET_MINECRAFT_CLIENT__Minecraft_H__
|
||||
#define NET_MINECRAFT_CLIENT__Minecraft_H__
|
||||
|
||||
#include "Options.h"
|
||||
#ifndef STANDALONE_SERVER
|
||||
#include "MouseHandler.h"
|
||||
#include "gui/Gui.h"
|
||||
#include "gui/screens/ScreenChooser.h"
|
||||
#endif
|
||||
|
||||
#include "Timer.h"
|
||||
|
||||
//#include "../network/RakNetInstance.h"
|
||||
#include "../world/phys/HitResult.h"
|
||||
|
||||
class User;
|
||||
class Level;
|
||||
class LocalPlayer;
|
||||
class IInputHolder;
|
||||
class Mob;
|
||||
class Player;
|
||||
class LevelRenderer;
|
||||
class GameRenderer;
|
||||
class ParticleEngine;
|
||||
class Entity;
|
||||
class ICreator;
|
||||
class GameMode;
|
||||
class Textures;
|
||||
class CThread;
|
||||
class SoundEngine;
|
||||
class Screen;
|
||||
class Font;
|
||||
class LevelStorageSource;
|
||||
class BuildActionIntention;
|
||||
class PerfRenderer;
|
||||
class LevelSettings;
|
||||
class IRakNetInstance;
|
||||
class NetEventCallback;
|
||||
class CommandServer;
|
||||
struct PingedCompatibleServer;
|
||||
//class ExternalFileLevelStorageSource;
|
||||
|
||||
|
||||
#include "../App.h"
|
||||
#include "PixelCalc.h"
|
||||
class AppPlatform;
|
||||
class AppPlatform_android;
|
||||
|
||||
class Minecraft: public App
|
||||
{
|
||||
protected:
|
||||
Minecraft();
|
||||
public:
|
||||
virtual ~Minecraft();
|
||||
|
||||
void init();
|
||||
void setSize(int width, int height);
|
||||
void reloadOptions();
|
||||
|
||||
bool supportNonTouchScreen();
|
||||
bool useTouchscreen();
|
||||
void grabMouse();
|
||||
void releaseMouse();
|
||||
|
||||
void handleBuildAction(BuildActionIntention*);
|
||||
|
||||
void toggleDimension(){}
|
||||
bool isCreativeMode();
|
||||
void setIsCreativeMode(bool isCreative);
|
||||
void setScreen(Screen*);
|
||||
|
||||
virtual void selectLevel(const std::string& levelId, const std::string& levelName, const LevelSettings& settings);
|
||||
virtual void setLevel(Level* level, const std::string& message = "", LocalPlayer* forceInsertPlayer = NULL);
|
||||
|
||||
void generateLevel( const std::string& message, Level* level );
|
||||
LevelStorageSource* getLevelSource();
|
||||
|
||||
bool isLookingForMultiplayer;
|
||||
void locateMultiplayer();
|
||||
void cancelLocateMultiplayer();
|
||||
bool joinMultiplayer(const PingedCompatibleServer& server);
|
||||
bool joinMultiplayerFromString(const std::string& server);
|
||||
void hostMultiplayer(int port=19132);
|
||||
Player* respawnPlayer(int playerId);
|
||||
void respawnPlayer();
|
||||
void resetPlayer(Player* player);
|
||||
void doActuallyRespawnPlayer();
|
||||
|
||||
void update();
|
||||
|
||||
void tick(int nTick, int maxTick);
|
||||
void tickInput();
|
||||
|
||||
bool isOnlineClient();
|
||||
bool isOnline();
|
||||
void pauseGame(bool isBackPaused);
|
||||
void gameLostFocus();
|
||||
|
||||
void prepareLevel(const std::string& message);
|
||||
|
||||
void leaveGame(bool renameLevel = false);
|
||||
|
||||
int getProgressStatusId();
|
||||
const char* getProgressMessage();
|
||||
|
||||
ICreator* getCreator();
|
||||
|
||||
// void onGraphicsLost() {}
|
||||
void onGraphicsReset();
|
||||
|
||||
bool isLevelGenerated();
|
||||
|
||||
void audioEngineOn();
|
||||
void audioEngineOff();
|
||||
|
||||
bool isPowerVR() { return _powerVr; }
|
||||
bool isKindleFire(int kindleVersion);
|
||||
bool transformResolution(int* w, int* h);
|
||||
void optionUpdated(OptionId option, bool value);
|
||||
void optionUpdated(OptionId option, float value);
|
||||
void optionUpdated(OptionId option, int value);
|
||||
#ifdef __APPLE__
|
||||
bool _isSuperFast;
|
||||
bool isSuperFast() { return _isSuperFast; }
|
||||
#endif
|
||||
|
||||
protected:
|
||||
void _levelGenerated();
|
||||
|
||||
private:
|
||||
static void* prepareLevel_tspawn(void *p_param);
|
||||
|
||||
void _reloadInput();
|
||||
public:
|
||||
int width;
|
||||
int height;
|
||||
|
||||
// Vars that the platform is allowed to use in the future
|
||||
int commandPort;
|
||||
int reserved_d1, reserved_d2;
|
||||
float reserved_f1, reserved_f2;
|
||||
|
||||
Options options;
|
||||
|
||||
static bool useAmbientOcclusion;
|
||||
//static bool threadInterrupt;
|
||||
|
||||
volatile bool pause;
|
||||
|
||||
LevelRenderer* levelRenderer;
|
||||
GameRenderer* gameRenderer;
|
||||
ParticleEngine* particleEngine;
|
||||
SoundEngine* soundEngine;
|
||||
|
||||
GameMode* gameMode;
|
||||
#ifndef STANDALONE_SERVER
|
||||
Textures* textures;
|
||||
ScreenChooser screenChooser;
|
||||
Font* font;
|
||||
#endif
|
||||
IRakNetInstance* raknetInstance;
|
||||
NetEventCallback* netCallback;
|
||||
|
||||
int lastTime;
|
||||
int lastTickTime;
|
||||
float ticksSinceLastUpdate;
|
||||
|
||||
User* user;
|
||||
Level* level;
|
||||
|
||||
LocalPlayer* player;
|
||||
IInputHolder* inputHolder;
|
||||
Mob* cameraTargetPlayer;
|
||||
#ifndef STANDALONE_SERVER
|
||||
Gui gui;
|
||||
#endif
|
||||
CThread* generateLevelThread;
|
||||
Screen* screen;
|
||||
static int customDebugId;
|
||||
|
||||
static const int CDI_NONE = 0;
|
||||
static const int CDI_GRAPHICS = 1;
|
||||
#ifndef STANDALONE_SERVER
|
||||
MouseHandler mouseHandler;
|
||||
#endif
|
||||
bool mouseGrabbed;
|
||||
|
||||
PixelCalc pixelCalc;
|
||||
PixelCalc pixelCalcUi;
|
||||
|
||||
HitResult hitResult;
|
||||
volatile int progressStagePercentage;
|
||||
|
||||
// This field is initialized in main()
|
||||
// It sets the base path to where worlds can be written (sdcard on android)
|
||||
std::string externalStoragePath;
|
||||
std::string externalCacheStoragePath;
|
||||
protected:
|
||||
Timer timer;
|
||||
// @note @attn @warn: this is dangerous as fuck!
|
||||
volatile bool isGeneratingLevel;
|
||||
bool _hasSignaledGeneratingLevelFinished;
|
||||
|
||||
LevelStorageSource* storageSource;
|
||||
bool _running;
|
||||
bool _powerVr;
|
||||
|
||||
private:
|
||||
volatile int progressStageStatusId;
|
||||
static const char* progressMessages[];
|
||||
|
||||
int missTime;
|
||||
int ticks;
|
||||
bool screenMutex;
|
||||
bool hasScheduledScreen;
|
||||
Screen* scheduledScreen;
|
||||
|
||||
int _licenseId;
|
||||
bool _supportsNonTouchscreen;
|
||||
|
||||
bool _isCreativeMode;
|
||||
//int _respawnPlayerTicks;
|
||||
Player* _pendingRemovePlayer; // @attn @todo @fix: remove this shait and fix the respawn behaviour
|
||||
// shit* lmao
|
||||
|
||||
PerfRenderer* _perfRenderer;
|
||||
CommandServer* _commandServer;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT__Minecraft_H__*/
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "MouseHandler.hpp"
|
||||
#include "player/input/ITurnInput.hpp"
|
||||
#include "MouseHandler.h"
|
||||
#include "player/input/ITurnInput.h"
|
||||
|
||||
#ifdef RPI
|
||||
#include <SDL/SDL.h>
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
||||
#ifdef PLATFORM_GLFW
|
||||
#include <GLFW/glfw3.h>
|
||||
#endif
|
||||
|
||||
@@ -34,7 +34,7 @@ void MouseHandler::grab() {
|
||||
SDL_ShowCursor(0);
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
||||
#ifdef PLATFORM_GLFW
|
||||
glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR, GLFW_CURSOR_DISABLED);
|
||||
#endif
|
||||
}
|
||||
@@ -46,7 +46,7 @@ void MouseHandler::release() {
|
||||
SDL_ShowCursor(1);
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
||||
#ifdef PLATFORM_GLFW
|
||||
glfwSetInputMode(glfwGetCurrentContext(), GLFW_CURSOR, GLFW_CURSOR_NORMAL);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef NET_MINECRAFT_CLIENT__MouseHandler_H__
|
||||
#define NET_MINECRAFT_CLIENT__MouseHandler_H__
|
||||
|
||||
//package net.minecraft.client;
|
||||
|
||||
@@ -24,3 +25,4 @@ private:
|
||||
ITurnInput* _turnInput;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT__MouseHandler_H__*/
|
||||
@@ -1,8 +1,5 @@
|
||||
#include "Option.hpp"
|
||||
#include "Option.h"
|
||||
#include <sstream>
|
||||
#include <cstdio>
|
||||
|
||||
Option::~Option() {}
|
||||
|
||||
bool Option::parse_bool_like(const std::string& value, bool& out) {
|
||||
if (value == "true" || value == "YES") {
|
||||
@@ -26,7 +23,7 @@ bool OptionFloat::parse(const std::string& value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return sscanf(value.c_str(), "%f", &m_value) == 1;
|
||||
return std::sscanf(value.c_str(), "%f", &m_value) == 1;
|
||||
}
|
||||
bool OptionInt::parse(const std::string& value) {
|
||||
bool b;
|
||||
@@ -35,7 +32,7 @@ bool OptionInt::parse(const std::string& value) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return sscanf(value.c_str(), "%d", &m_value) == 1;
|
||||
return std::sscanf(value.c_str(), "%d", &m_value) == 1;
|
||||
}
|
||||
bool OptionBool::parse(const std::string& value) {
|
||||
if (value == "0") {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
#include <util/Mth.hpp>
|
||||
#include "Mth.h"
|
||||
/*
|
||||
template<typename T>
|
||||
struct is_option_type : std::false_type {};
|
||||
@@ -21,7 +21,7 @@ template<> struct is_min_max_option<float> : std::true_type {};
|
||||
class Option {
|
||||
public:
|
||||
Option(const std::string& key) : m_key("options." + key) {}
|
||||
virtual ~Option();
|
||||
virtual ~Option() = default;
|
||||
|
||||
const std::string& getStringId() { return m_key; }
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "OptionStrings.hpp"
|
||||
#include "OptionStrings.h"
|
||||
|
||||
const char* OptionStrings::Multiplayer_Username = "mp_username";
|
||||
const char* OptionStrings::Multiplayer_ServerVisible = "mp_server_visible_default";
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef NET_MINECRAFT_CLIENT__OptionStrings_H__
|
||||
#define NET_MINECRAFT_CLIENT__OptionStrings_H__
|
||||
|
||||
class OptionStrings {
|
||||
public:
|
||||
@@ -32,3 +33,4 @@ public:
|
||||
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT__OptionsStrings_H__*/
|
||||
@@ -1,6 +1,11 @@
|
||||
#include "Options.hpp"
|
||||
#include "world/Difficulty.hpp"
|
||||
#include <MinecraftClient.hpp>
|
||||
#include "Options.h"
|
||||
#include "OptionStrings.h"
|
||||
#include "Minecraft.h"
|
||||
#include "../platform/log.h"
|
||||
#include "../world/Difficulty.h"
|
||||
#include <cmath>
|
||||
|
||||
#include <memory>
|
||||
|
||||
bool Options::debugGl = false;
|
||||
|
||||
@@ -15,7 +20,6 @@ OptionBool fixedCamera("fixedCamera", false);
|
||||
OptionBool isFlying("isflying", false);
|
||||
OptionBool barOnTop("barOnTop", false);
|
||||
OptionBool allowSprint("allowSprint", true);
|
||||
OptionBool rpiCursor("rpiCursor", false);
|
||||
OptionBool autoJump("autoJump", true);
|
||||
|
||||
|
||||
@@ -154,7 +158,6 @@ void Options::initTable() {
|
||||
|
||||
m_options[OPTIONS_BAR_ON_TOP] = &barOnTop;
|
||||
m_options[OPTIONS_ALLOW_SPRINT] = &allowSprint;
|
||||
m_options[OPTIONS_RPI_CURSOR] = &rpiCursor;
|
||||
|
||||
m_options[OPTIONS_AUTOJUMP] = &autoJump;
|
||||
m_options[OPTIONS_LAST_IP] = &lastIp;
|
||||
@@ -165,7 +168,9 @@ void Options::set(OptionId key, const std::string& value) {
|
||||
|
||||
if (option) {
|
||||
option->set(value);
|
||||
|
||||
notifyOptionUpdate(key, value);
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +179,9 @@ void Options::set(OptionId key, float value) {
|
||||
|
||||
if (option) {
|
||||
option->set(value);
|
||||
|
||||
notifyOptionUpdate(key, value);
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +190,9 @@ void Options::set(OptionId key, int value) {
|
||||
|
||||
if (option) {
|
||||
option->set(value);
|
||||
|
||||
notifyOptionUpdate(key, value);
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +201,9 @@ void Options::toggle(OptionId key) {
|
||||
|
||||
if (option) {
|
||||
option->toggle();
|
||||
|
||||
notifyOptionUpdate(key, option->get());
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -280,18 +291,14 @@ void Options::save() {
|
||||
optionsFile.save(stringVec);
|
||||
}
|
||||
|
||||
void Options::setOptionsFilePath(const std::string& path) {
|
||||
optionsFile.setOptionsPath(path + "/options.txt");
|
||||
}
|
||||
|
||||
void Options::notifyOptionUpdate(OptionId key, bool value) {
|
||||
minecraft.optionUpdated(key, value);
|
||||
minecraft->optionUpdated(key, value);
|
||||
}
|
||||
|
||||
void Options::notifyOptionUpdate(OptionId key, float value) {
|
||||
minecraft.optionUpdated(key, value);
|
||||
minecraft->optionUpdated(key, value);
|
||||
}
|
||||
|
||||
void Options::notifyOptionUpdate(OptionId key, int value) {
|
||||
minecraft.optionUpdated(key, value);
|
||||
minecraft->optionUpdated(key, value);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef NET_MINECRAFT_CLIENT__Options_H__
|
||||
#define NET_MINECRAFT_CLIENT__Options_H__
|
||||
|
||||
#define SOUND_MIN_VALUE 0.0f
|
||||
#define SOUND_MAX_VALUE 1.0f
|
||||
@@ -11,13 +12,14 @@
|
||||
|
||||
//package net.minecraft.client;
|
||||
|
||||
//#include "locale/Language.hpp"
|
||||
//#include "locale/Language.h"
|
||||
|
||||
#include <string>
|
||||
#include <platform/input/Keyboard.hpp>
|
||||
#include <util/StringUtils.hpp>
|
||||
#include "OptionsFile.hpp"
|
||||
#include "Option.hpp"
|
||||
#include <cstdio>
|
||||
#include "../platform/input/Keyboard.h"
|
||||
#include "../util/StringUtils.h"
|
||||
#include "OptionsFile.h"
|
||||
#include "Option.h"
|
||||
#include <array>
|
||||
|
||||
enum OptionId {
|
||||
@@ -81,28 +83,33 @@ enum OptionId {
|
||||
OPTIONS_FIRST_LAUNCH,
|
||||
OPTIONS_LAST_IP,
|
||||
|
||||
OPTIONS_RPI_CURSOR,
|
||||
// Should be last!
|
||||
OPTIONS_COUNT
|
||||
};
|
||||
|
||||
class MinecraftClient;
|
||||
class Minecraft;
|
||||
typedef std::vector<std::string> StringVector;
|
||||
|
||||
class Options
|
||||
{
|
||||
public:
|
||||
|
||||
static bool debugGl;
|
||||
|
||||
Options(MinecraftClient& minecraft, const std::string& workingDirectory = "")
|
||||
Options(Minecraft* minecraft, const std::string& workingDirectory = "")
|
||||
: minecraft(minecraft) {
|
||||
// elements werent initialized so i was getting a garbage pointer and a crash
|
||||
m_options.fill(nullptr);
|
||||
initTable();
|
||||
// load() is deferred to init() where path is configured correctly
|
||||
load();
|
||||
}
|
||||
|
||||
void initTable();
|
||||
void initTable();
|
||||
|
||||
void set(OptionId key, int value);
|
||||
void set(OptionId key, float value);
|
||||
void set(OptionId key, const std::string& value);
|
||||
void toggle(OptionId key);
|
||||
|
||||
int getIntValue(OptionId key) {
|
||||
auto option = opt<OptionInt>(key);
|
||||
@@ -138,11 +145,6 @@ public:
|
||||
|
||||
void load();
|
||||
void save();
|
||||
void set(OptionId key, int value);
|
||||
void set(OptionId key, float value);
|
||||
void set(OptionId key, const std::string& value);
|
||||
void setOptionsFilePath(const std::string& path);
|
||||
void toggle(OptionId key);
|
||||
|
||||
void notifyOptionUpdate(OptionId key, bool value);
|
||||
void notifyOptionUpdate(OptionId key, float value);
|
||||
@@ -155,10 +157,13 @@ private:
|
||||
if (m_options[key] == nullptr) return nullptr;
|
||||
return dynamic_cast<T*>(m_options[key]);
|
||||
}
|
||||
|
||||
// apple stuff
|
||||
float sound;
|
||||
float music;
|
||||
std::array<Option*, OPTIONS_COUNT> m_options;
|
||||
OptionsFile optionsFile;
|
||||
|
||||
MinecraftClient& minecraft;
|
||||
Minecraft* minecraft;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT__Options_H__*/
|
||||
@@ -1,76 +1,30 @@
|
||||
#include "OptionsFile.hpp"
|
||||
#include "OptionsFile.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <platform/log.hpp>
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <direct.h>
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#include <platform/log.h>
|
||||
|
||||
OptionsFile::OptionsFile() {
|
||||
#ifdef __APPLE__
|
||||
settingsPath = "./Documents/options.txt";
|
||||
#elif defined(ANDROID)
|
||||
settingsPath = "options.txt";
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
settingsPath = "/games/com.mojang/options.txt";
|
||||
#else
|
||||
settingsPath = "options.txt";
|
||||
#endif
|
||||
}
|
||||
|
||||
void OptionsFile::setOptionsPath(const std::string& path) {
|
||||
settingsPath = path;
|
||||
}
|
||||
|
||||
std::string OptionsFile::getOptionsPath() const {
|
||||
return settingsPath;
|
||||
}
|
||||
void OptionsFile::save(const StringVector& settings) {
|
||||
FILE* pFile = fopen(settingsPath.c_str(), "w");
|
||||
|
||||
if (!pFile && errno == ENOENT) {
|
||||
std::string dir = settingsPath;
|
||||
size_t fpos = dir.find_last_of("/\\");
|
||||
if (fpos != std::string::npos) {
|
||||
dir.resize(fpos);
|
||||
|
||||
std::string toCreate;
|
||||
for (size_t i = 0; i <= dir.size(); ++i) {
|
||||
if (i == dir.size() || dir[i] == '/' || dir[i] == '\\') {
|
||||
if (!toCreate.empty()) {
|
||||
#if defined(_WIN32)
|
||||
_mkdir(toCreate.c_str());
|
||||
#else
|
||||
mkdir(toCreate.c_str(), 0755);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (i < dir.size())
|
||||
toCreate.push_back(dir[i]);
|
||||
}
|
||||
}
|
||||
|
||||
pFile = fopen(settingsPath.c_str(), "w");
|
||||
}
|
||||
|
||||
if (!pFile) {
|
||||
LOGI("OptionsFile::save failed: %s", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
for (const auto& s : settings) {
|
||||
fprintf(pFile, "%s\n", s.c_str());
|
||||
}
|
||||
|
||||
fclose(pFile);
|
||||
FILE* pFile = fopen(settingsPath.c_str(), "w");
|
||||
if(pFile != NULL) {
|
||||
for(StringVector::const_iterator it = settings.begin(); it != settings.end(); ++it) {
|
||||
fprintf(pFile, "%s\n", it->c_str());
|
||||
}
|
||||
fclose(pFile);
|
||||
} else {
|
||||
LOGI("OptionsFile::save failed to open '%s' for writing: %s", settingsPath.c_str(), strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
StringVector OptionsFile::getOptionStrings() {
|
||||
StringVector returnVector;
|
||||
FILE* pFile = fopen(settingsPath.c_str(), "r");
|
||||
@@ -91,8 +45,7 @@ StringVector OptionsFile::getOptionStrings() {
|
||||
}
|
||||
fclose(pFile);
|
||||
} else {
|
||||
if (errno != ENOENT)
|
||||
LOGI("OptionsFile::getOptionStrings failed to open '%s' for reading: %s", settingsPath.c_str(), strerror(errno));
|
||||
LOGI("OptionsFile::getOptionStrings failed to open '%s' for reading: %s", settingsPath.c_str(), strerror(errno));
|
||||
}
|
||||
return returnVector;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef NET_MINECRAFT_CLIENT__OptionsFile_H__
|
||||
#define NET_MINECRAFT_CLIENT__OptionsFile_H__
|
||||
|
||||
//package net.minecraft.client;
|
||||
#include <string>
|
||||
@@ -10,10 +11,9 @@ public:
|
||||
OptionsFile();
|
||||
void save(const StringVector& settings);
|
||||
StringVector getOptionStrings();
|
||||
void setOptionsPath(const std::string& path);
|
||||
std::string getOptionsPath() const;
|
||||
|
||||
private:
|
||||
std::string settingsPath;
|
||||
};
|
||||
|
||||
#endif /* NET_MINECRAFT_CLIENT__OptionsFile_H__ */
|
||||
@@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
#ifndef NET_MINECRAFT_CLIENT__Timer_H__
|
||||
#define NET_MINECRAFT_CLIENT__Timer_H__
|
||||
|
||||
//package net.minecraft.client;
|
||||
#include "platform/time.hpp"
|
||||
#include "../platform/time.h"
|
||||
|
||||
class Timer
|
||||
{
|
||||
@@ -120,3 +121,4 @@ private:
|
||||
float adjustTime;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT__Timer_H__*/
|
||||
62
src/client/User.h
Executable file
62
src/client/User.h
Executable file
@@ -0,0 +1,62 @@
|
||||
#ifndef NET_MINECRAFT_CLIENT__User_H__
|
||||
#define NET_MINECRAFT_CLIENT__User_H__
|
||||
|
||||
//package net.minecraft.client;
|
||||
|
||||
#include "../world/level/tile/Tile.h"
|
||||
|
||||
class User
|
||||
{
|
||||
public:
|
||||
//static List<Tile> allowedTiles = /*new*/ ArrayList<Tile>();
|
||||
|
||||
//static {
|
||||
// allowedTiles.push_back(Tile::rock);
|
||||
// allowedTiles.push_back(Tile::stoneBrick);
|
||||
// allowedTiles.push_back(Tile::redBrick);
|
||||
// allowedTiles.push_back(Tile::dirt);
|
||||
// allowedTiles.push_back(Tile::wood);
|
||||
// allowedTiles.push_back(Tile::treeTrunk);
|
||||
// allowedTiles.push_back(Tile::leaves);
|
||||
// allowedTiles.push_back(Tile::torch);
|
||||
// allowedTiles.push_back(Tile::stoneSlabHalf);
|
||||
|
||||
// allowedTiles.push_back(Tile::glass);
|
||||
// allowedTiles.push_back(Tile::mossStone);
|
||||
// allowedTiles.push_back(Tile::sapling);
|
||||
// allowedTiles.push_back(Tile::flower);
|
||||
// allowedTiles.push_back(Tile::rose);
|
||||
// allowedTiles.push_back(Tile::mushroom1);
|
||||
// allowedTiles.push_back(Tile::mushroom2);
|
||||
// allowedTiles.push_back(Tile::sand);
|
||||
// allowedTiles.push_back(Tile::gravel);
|
||||
// allowedTiles.push_back(Tile::sponge);
|
||||
|
||||
// allowedTiles.push_back(Tile::cloth);
|
||||
// allowedTiles.push_back(Tile::coalOre);
|
||||
// allowedTiles.push_back(Tile::ironOre);
|
||||
// allowedTiles.push_back(Tile::goldOre);
|
||||
// allowedTiles.push_back(Tile::ironBlock);
|
||||
// allowedTiles.push_back(Tile::goldBlock);
|
||||
// allowedTiles.push_back(Tile::bookshelf);
|
||||
// allowedTiles.push_back(Tile::tnt);
|
||||
// allowedTiles.push_back(Tile::obsidian);
|
||||
|
||||
// // System.out.println(allowedTiles.size());
|
||||
//}
|
||||
|
||||
static bool isTileAllowed(const Tile& tile) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string name;
|
||||
std::string sessionId;
|
||||
//std::string mpPassword;
|
||||
|
||||
User(const std::string& name, const std::string& sessionId) {
|
||||
this->name = name;
|
||||
this->sessionId = sessionId;
|
||||
}
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT__User_H__*/
|
||||
69
src/client/gamemode/CreativeMode.cpp
Executable file
69
src/client/gamemode/CreativeMode.cpp
Executable file
@@ -0,0 +1,69 @@
|
||||
#include "CreativeMode.h"
|
||||
#include "../Minecraft.h"
|
||||
#ifndef STANDALONE_SERVER
|
||||
#include "../particle/ParticleEngine.h"
|
||||
#endif
|
||||
#include "../player/LocalPlayer.h"
|
||||
#ifndef STANDALONE_SERVER
|
||||
#include "../renderer/LevelRenderer.h"
|
||||
#include "../sound/SoundEngine.h"
|
||||
#endif
|
||||
#include "../../world/level/Level.h"
|
||||
//#include "../../network/Packet.h"
|
||||
#include "../../network/packet/RemoveBlockPacket.h"
|
||||
#include "../../world/entity/player/Abilities.h"
|
||||
|
||||
static const int DestructionTickDelay = 5;
|
||||
|
||||
CreativeMode::CreativeMode(Minecraft* minecraft)
|
||||
: super(minecraft)
|
||||
{
|
||||
}
|
||||
|
||||
void CreativeMode::startDestroyBlock(int x, int y, int z, int face) {
|
||||
if(minecraft->player->getCarriedItem() != NULL && minecraft->player->getCarriedItem()->id == Item::bow->id)
|
||||
return;
|
||||
|
||||
creativeDestroyBlock(x, y, z, face);
|
||||
destroyDelay = DestructionTickDelay;
|
||||
}
|
||||
|
||||
void CreativeMode::creativeDestroyBlock(int x, int y, int z, int face) {
|
||||
minecraft->level->extinguishFire(x, y, z, face);
|
||||
destroyBlock(x, y, z, face);
|
||||
}
|
||||
|
||||
void CreativeMode::continueDestroyBlock(int x, int y, int z, int face) {
|
||||
destroyDelay--;
|
||||
if (destroyDelay <= 0) {
|
||||
destroyDelay = DestructionTickDelay;
|
||||
creativeDestroyBlock(x, y, z, face);
|
||||
}
|
||||
}
|
||||
|
||||
void CreativeMode::stopDestroyBlock() {
|
||||
destroyDelay = 0;
|
||||
}
|
||||
|
||||
void CreativeMode::initAbilities( Abilities& abilities ) {
|
||||
abilities.mayfly = true;
|
||||
abilities.instabuild = true;
|
||||
abilities.invulnerable = true;
|
||||
}
|
||||
|
||||
bool CreativeMode::isCreativeType() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void CreativeMode::releaseUsingItem( Player* player ) {
|
||||
if(player->getCarriedItem() != NULL) {
|
||||
int oldItemId = player->getCarriedItem()->id;
|
||||
int oldAux = player->getAuxData();
|
||||
super::releaseUsingItem(player);
|
||||
if(player->getCarriedItem() != NULL && player->getCarriedItem()->id == oldItemId) {
|
||||
player->getCarriedItem()->setAuxValue(oldAux);
|
||||
}
|
||||
} else {
|
||||
super::releaseUsingItem(player);
|
||||
}
|
||||
}
|
||||
27
src/client/gamemode/CreativeMode.h
Executable file
27
src/client/gamemode/CreativeMode.h
Executable file
@@ -0,0 +1,27 @@
|
||||
#ifndef NET_MINECRAFT_CLIENT_GAMEMODE__CreativeMode_H__
|
||||
#define NET_MINECRAFT_CLIENT_GAMEMODE__CreativeMode_H__
|
||||
|
||||
//package net.minecraft.client.gamemode;
|
||||
|
||||
#include "GameMode.h"
|
||||
|
||||
class CreativeMode: public GameMode
|
||||
{
|
||||
typedef GameMode super;
|
||||
public:
|
||||
CreativeMode(Minecraft* minecraft);
|
||||
|
||||
void startDestroyBlock(int x, int y, int z, int face);
|
||||
void continueDestroyBlock(int x, int y, int z, int face);
|
||||
void stopDestroyBlock();
|
||||
|
||||
bool isCreativeType();
|
||||
|
||||
void initAbilities(Abilities& abilities);
|
||||
|
||||
void releaseUsingItem(Player* player);
|
||||
private:
|
||||
void creativeDestroyBlock(int x, int y, int z, int face);
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT_GAMEMODE__CreativeMode_H__*/
|
||||
@@ -1,8 +1,13 @@
|
||||
#include "CreatorMode.hpp"
|
||||
#include "world/entity/player/Player.hpp"
|
||||
#include "world/level/Level.hpp"
|
||||
#include <Minecraft.hpp>
|
||||
#include <world/entity/player/Abilities.hpp>
|
||||
#include "CreatorMode.h"
|
||||
#include "../Minecraft.h"
|
||||
#include "../particle/ParticleEngine.h"
|
||||
#include "../player/LocalPlayer.h"
|
||||
#include "../renderer/LevelRenderer.h"
|
||||
#include "../sound/SoundEngine.h"
|
||||
#include "../../world/level/Level.h"
|
||||
//#include "../../network/Packet.h"
|
||||
#include "../../network/packet/RemoveBlockPacket.h"
|
||||
#include "../../world/entity/player/Abilities.h"
|
||||
|
||||
static const int DestructionTickDelay = 5;
|
||||
|
||||
@@ -36,7 +41,7 @@ private:
|
||||
int _tickId;
|
||||
};
|
||||
|
||||
CreatorMode::CreatorMode(Minecraft& minecraft)
|
||||
CreatorMode::CreatorMode(Minecraft* minecraft)
|
||||
: super(minecraft)
|
||||
{
|
||||
_creator = new Creator();
|
||||
@@ -46,35 +51,34 @@ CreatorMode::~CreatorMode() {
|
||||
delete _creator;
|
||||
}
|
||||
|
||||
void CreatorMode::startDestroyBlock(Player* player, int x, int y, int z, int face) {
|
||||
if(player->getCarriedItem() != NULL && player->getCarriedItem()->id == Item::bow->id)
|
||||
void CreatorMode::startDestroyBlock(int x, int y, int z, int face) {
|
||||
if(minecraft->player->getCarriedItem() != NULL && minecraft->player->getCarriedItem()->id == Item::bow->id)
|
||||
return;
|
||||
|
||||
CreatorDestroyBlock(player, x, y, z, face);
|
||||
CreatorDestroyBlock(x, y, z, face);
|
||||
destroyDelay = DestructionTickDelay;
|
||||
}
|
||||
|
||||
void CreatorMode::CreatorDestroyBlock(Player* player, int x, int y, int z, int face) {
|
||||
minecraft.level->extinguishFire(x, y, z, face);
|
||||
destroyBlock(player, x, y, z, face);
|
||||
|
||||
void CreatorMode::CreatorDestroyBlock(int x, int y, int z, int face) {
|
||||
minecraft->level->extinguishFire(x, y, z, face);
|
||||
destroyBlock(x, y, z, face);
|
||||
}
|
||||
|
||||
void CreatorMode::continueDestroyBlock(Player* player, int x, int y, int z, int face) {
|
||||
void CreatorMode::continueDestroyBlock(int x, int y, int z, int face) {
|
||||
destroyDelay--;
|
||||
if (destroyDelay <= 0) {
|
||||
destroyDelay = DestructionTickDelay;
|
||||
CreatorDestroyBlock(player, x, y, z, face);
|
||||
CreatorDestroyBlock(x, y, z, face);
|
||||
}
|
||||
}
|
||||
|
||||
bool CreatorMode::useItemOn(Player* player, Level* level, ItemInstance* item, int x, int y, int z, int face, const Vec3& hit ) {
|
||||
bool CreatorMode::useItemOn( Player* player, Level* level, ItemInstance* item, int x, int y, int z, int face, const Vec3& hit ) {
|
||||
if (item && item->id == ((Item*)Item::sword_iron)->id)
|
||||
_creator->addevent_blockUse(player->entityId, x, y, z, face);
|
||||
return super::useItemOn(player, level, item, x, y, z, face, hit);
|
||||
}
|
||||
|
||||
void CreatorMode::stopDestroyBlock(Player* player) {
|
||||
void CreatorMode::stopDestroyBlock() {
|
||||
destroyDelay = 0;
|
||||
}
|
||||
|
||||
@@ -106,6 +110,6 @@ ICreator* CreatorMode::getCreator() {
|
||||
}
|
||||
|
||||
void CreatorMode::tick() {
|
||||
_creator->setTick(minecraft.level->getTime());
|
||||
_creator->setTick(minecraft->level->getTime());
|
||||
super::tick();
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
#pragma once
|
||||
#ifndef NET_MINECRAFT_CLIENT_GAMEMODE__CreatorMode_H__
|
||||
#define NET_MINECRAFT_CLIENT_GAMEMODE__CreatorMode_H__
|
||||
|
||||
//package net.minecraft.client.gamemode;
|
||||
|
||||
#include "GameMode.hpp"
|
||||
#include <world/PosTranslator.hpp>
|
||||
#include "GameMode.h"
|
||||
#include "../../world/PosTranslator.h"
|
||||
|
||||
class ICreator {
|
||||
public:
|
||||
@@ -101,12 +102,12 @@ class CreatorMode: public GameMode
|
||||
{
|
||||
typedef GameMode super;
|
||||
public:
|
||||
CreatorMode(Minecraft& minecraft);
|
||||
CreatorMode(Minecraft* minecraft);
|
||||
~CreatorMode();
|
||||
|
||||
void startDestroyBlock(Player* player, int x, int y, int z, int face);
|
||||
void continueDestroyBlock(Player* player, int x, int y, int z, int face);
|
||||
void stopDestroyBlock(Player* player);
|
||||
void startDestroyBlock(int x, int y, int z, int face);
|
||||
void continueDestroyBlock(int x, int y, int z, int face);
|
||||
void stopDestroyBlock();
|
||||
|
||||
bool useItemOn(Player* player, Level* level, ItemInstance* item, int x, int y, int z, int face, const Vec3& hit);
|
||||
|
||||
@@ -119,8 +120,9 @@ public:
|
||||
|
||||
void releaseUsingItem(Player* player);
|
||||
private:
|
||||
void CreatorDestroyBlock(Player* player, int x, int y, int z, int face);
|
||||
void CreatorDestroyBlock(int x, int y, int z, int face);
|
||||
|
||||
Creator* _creator;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT_GAMEMODE__CreatorMode_H__*/
|
||||
@@ -1,15 +1,34 @@
|
||||
#include "GameMode.hpp"
|
||||
#include <Minecraft.hpp>
|
||||
#include <network/packet/UseItemPacket.hpp>
|
||||
#include <network/packet/PlayerActionPacket.hpp>
|
||||
#include <world/level/Level.hpp>
|
||||
#include <world/item/ItemInstance.hpp>
|
||||
#include <client/player/LocalPlayer.hpp>
|
||||
#include <client/Options.hpp>
|
||||
#include <network/RakNetInstance.hpp>
|
||||
#include <network/packet/RemoveBlockPacket.hpp>
|
||||
#include <world/level/material/Material.hpp>
|
||||
#include "GameMode.h"
|
||||
#include "../Minecraft.h"
|
||||
#include "../../network/packet/UseItemPacket.h"
|
||||
#include "../../network/packet/PlayerActionPacket.h"
|
||||
#include "../../world/level/Level.h"
|
||||
#include "../../world/item/ItemInstance.h"
|
||||
#include "../player/LocalPlayer.h"
|
||||
#ifndef STANDALONE_SERVER
|
||||
#include "../sound/SoundEngine.h"
|
||||
#include "../particle/ParticleEngine.h"
|
||||
#endif
|
||||
#include "../../network/RakNetInstance.h"
|
||||
#include "../../network/packet/RemoveBlockPacket.h"
|
||||
#ifndef STANDALONE_SERVER
|
||||
#include "../renderer/LevelRenderer.h"
|
||||
#endif
|
||||
#include "../../world/level/material/Material.h"
|
||||
|
||||
GameMode::GameMode( Minecraft* minecraft)
|
||||
: minecraft(minecraft),
|
||||
destroyProgress(0),
|
||||
oDestroyProgress(0),
|
||||
destroyTicks(0),
|
||||
destroyDelay(0)
|
||||
{
|
||||
}
|
||||
|
||||
/*virtual*/
|
||||
Player* GameMode::createPlayer(Level* level) {
|
||||
return new LocalPlayer(minecraft, level, minecraft->user, level->dimension->id, isCreativeType());
|
||||
}
|
||||
|
||||
/*virtual*/
|
||||
void GameMode::interact(Player* player, Entity* entity) {
|
||||
@@ -18,24 +37,23 @@ void GameMode::interact(Player* player, Entity* entity) {
|
||||
|
||||
/*virtual*/
|
||||
void GameMode::attack(Player* player, Entity* entity) {
|
||||
if (minecraft.level->adventureSettings.noPvP && entity->isPlayer())
|
||||
if (minecraft->level->adventureSettings.noPvP && entity->isPlayer())
|
||||
return;
|
||||
if (minecraft.level->adventureSettings.noPvM && entity->isMob())
|
||||
if (minecraft->level->adventureSettings.noPvM && entity->isMob())
|
||||
return;
|
||||
player->attack(entity);
|
||||
}
|
||||
|
||||
/* virtual */
|
||||
void GameMode::startDestroyBlock(Player* player, int x, int y, int z, int face ) {
|
||||
if(player->getCarriedItem() != NULL && player->getCarriedItem()->id == Item::bow->id)
|
||||
void GameMode::startDestroyBlock( int x, int y, int z, int face ) {
|
||||
if(minecraft->player->getCarriedItem() != NULL && minecraft->player->getCarriedItem()->id == Item::bow->id)
|
||||
return;
|
||||
|
||||
destroyBlock(player, x, y, z, face);
|
||||
destroyBlock(x, y, z, face);
|
||||
}
|
||||
|
||||
/*virtual*/
|
||||
bool GameMode::destroyBlock(Player* player, int x, int y, int z, int face) {
|
||||
Level* level = minecraft.level;
|
||||
bool GameMode::destroyBlock(int x, int y, int z, int face) {
|
||||
Level* level = minecraft->level;
|
||||
Tile* oldTile = Tile::tiles[level->getTile(x, y, z)];
|
||||
if (!oldTile)
|
||||
return false;
|
||||
@@ -46,12 +64,22 @@ bool GameMode::destroyBlock(Player* player, int x, int y, int z, int face) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef STANDALONE_SERVER
|
||||
minecraft->particleEngine->destroy(x, y, z);
|
||||
#endif
|
||||
int data = level->getData(x, y, z);
|
||||
bool changed = level->setTile(x, y, z, 0);
|
||||
if (changed) {
|
||||
#ifndef STANDALONE_SERVER
|
||||
minecraft->soundEngine->play(oldTile->soundType->getBreakSound(), x + 0.5f, y + 0.5f, z + 0.5f, (oldTile->soundType->getVolume() + 1) / 2, oldTile->soundType->getPitch() * 0.8f);
|
||||
#endif
|
||||
oldTile->destroy(level, x, y, z, data);
|
||||
minecraft.onBlockDestroyed(player, x, y, z, face);
|
||||
if (minecraft->options.getBooleanValue(OPTIONS_DESTROY_VIBRATION)) minecraft->platform()->vibrate(24);
|
||||
|
||||
if (minecraft->isOnline()) {
|
||||
RemoveBlockPacket packet(minecraft->player, x, y, z);
|
||||
minecraft->raknetInstance->send(packet);
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
@@ -63,7 +91,7 @@ bool GameMode::useItemOn(Player* player, Level* level, ItemInstance* item, int x
|
||||
item = player->inventory->getSelected();
|
||||
if(level->isClientSide) {
|
||||
UseItemPacket packet(x, y, z, face, item, player->entityId, clickX, clickY, clickZ);
|
||||
minecraft.raknetInstance->send(packet);
|
||||
minecraft->raknetInstance->send(packet);
|
||||
}
|
||||
int t = level->getTile(x, y, z);
|
||||
if (t == Tile::invisible_bedrock->id) return false;
|
||||
@@ -89,7 +117,7 @@ bool GameMode::useItem( Player* player, Level* level, ItemInstance* item ) {
|
||||
ItemInstance* itemInstance = item->use(level, player);
|
||||
if(level->isClientSide) {
|
||||
UseItemPacket packet(item, player->entityId, player->aimDirection);
|
||||
minecraft.raknetInstance->send(packet);
|
||||
minecraft->raknetInstance->send(packet);
|
||||
}
|
||||
if (itemInstance != item || (itemInstance != NULL && itemInstance->count != oldCount)) {
|
||||
//player.inventory.items[player.inventory.selected] = itemInstance;
|
||||
@@ -120,9 +148,9 @@ void GameMode::initPlayer( Player* player ) {
|
||||
}
|
||||
|
||||
void GameMode::releaseUsingItem(Player* player){
|
||||
if(minecraft.level->isClientSide) {
|
||||
if(minecraft->level->isClientSide) {
|
||||
PlayerActionPacket packet(PlayerActionPacket::RELEASE_USE_ITEM, 0, 0, 0, 0, player->entityId);
|
||||
minecraft.raknetInstance->send(packet);
|
||||
minecraft->raknetInstance->send(packet);
|
||||
}
|
||||
player->releaseUsingItem();
|
||||
}
|
||||
@@ -131,3 +159,15 @@ void GameMode::tick() {
|
||||
oDestroyProgress = destroyProgress;
|
||||
}
|
||||
|
||||
void GameMode::render( float a ) {
|
||||
#ifndef STANDALONE_SERVER
|
||||
if (destroyProgress <= 0) {
|
||||
minecraft->gui.progress = 0;
|
||||
minecraft->levelRenderer->destroyProgress = 0;
|
||||
} else {
|
||||
float dp = oDestroyProgress + (destroyProgress - oDestroyProgress) * a;
|
||||
minecraft->gui.progress = dp;
|
||||
minecraft->levelRenderer->destroyProgress = dp;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
#ifndef NET_MINECRAFT_CLIENT_GAMEMODE__GameMode_H__
|
||||
#define NET_MINECRAFT_CLIENT_GAMEMODE__GameMode_H__
|
||||
|
||||
//package net.minecraft.client.gamemode;
|
||||
|
||||
#include <world/level/tile/Tile.hpp>
|
||||
#include "../../world/level/tile/Tile.h"
|
||||
|
||||
class ItemInstance;
|
||||
class Minecraft;
|
||||
@@ -10,22 +11,23 @@ class Level;
|
||||
class Player;
|
||||
class Abilities;
|
||||
|
||||
class GameMode {
|
||||
class GameMode
|
||||
{
|
||||
protected:
|
||||
Minecraft& minecraft;
|
||||
|
||||
Minecraft* minecraft;
|
||||
public:
|
||||
GameMode(Minecraft& minecraft) : minecraft(minecraft) {}
|
||||
GameMode(Minecraft* minecraft);
|
||||
virtual ~GameMode() {}
|
||||
|
||||
virtual void initLevel(Level* level) {}
|
||||
|
||||
virtual void startDestroyBlock(Player* player, int x, int y, int z, int face);
|
||||
virtual bool destroyBlock(Player* player, int x, int y, int z, int face);
|
||||
virtual void continueDestroyBlock(Player* player, int x, int y, int z, int face) = 0;
|
||||
virtual void stopDestroyBlock(Player* player) {}
|
||||
virtual void startDestroyBlock(int x, int y, int z, int face);
|
||||
virtual bool destroyBlock(int x, int y, int z, int face);
|
||||
virtual void continueDestroyBlock(int x, int y, int z, int face) = 0;
|
||||
virtual void stopDestroyBlock() {}
|
||||
|
||||
virtual void tick();
|
||||
virtual void render(float a);
|
||||
|
||||
virtual float getPickRange();
|
||||
/* void postLevelGen(LevelGen levelGen, Level level) {} */
|
||||
@@ -33,6 +35,7 @@ public:
|
||||
virtual bool useItem(Player* player, Level* level, ItemInstance* item);
|
||||
virtual bool useItemOn(Player* player, Level* level, ItemInstance* item, int x, int y, int z, int face, const Vec3& hit);
|
||||
|
||||
virtual Player* createPlayer(Level* level);
|
||||
virtual void initPlayer(Player* player);
|
||||
virtual void adjustPlayer(Player* player) {}
|
||||
virtual bool canHurtPlayer() { return false; }
|
||||
@@ -50,10 +53,11 @@ public:
|
||||
|
||||
virtual void releaseUsingItem(Player* player);
|
||||
|
||||
float oDestroyProgress = 0;
|
||||
float destroyProgress = 0;
|
||||
float oDestroyProgress;
|
||||
float destroyProgress;
|
||||
protected:
|
||||
int destroyTicks = 0;
|
||||
int destroyDelay = 0;
|
||||
int destroyTicks;
|
||||
int destroyDelay;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT_GAMEMODE__GameMode_H__*/
|
||||
98
src/client/gamemode/SurvivalMode.cpp
Executable file
98
src/client/gamemode/SurvivalMode.cpp
Executable file
@@ -0,0 +1,98 @@
|
||||
#include "SurvivalMode.h"
|
||||
#include "../Minecraft.h"
|
||||
#include "../player/LocalPlayer.h"
|
||||
#ifndef STANDALONE_SERVER
|
||||
#include "../particle/ParticleEngine.h"
|
||||
#include "../sound/SoundEngine.h"
|
||||
#endif
|
||||
#include "../../world/level/Level.h"
|
||||
#include "../../world/entity/player/Abilities.h"
|
||||
|
||||
SurvivalMode::SurvivalMode( Minecraft* minecraft )
|
||||
: super(minecraft),
|
||||
xDestroyBlock(-1),
|
||||
yDestroyBlock(-1),
|
||||
zDestroyBlock(-1)
|
||||
{
|
||||
}
|
||||
|
||||
void SurvivalMode::continueDestroyBlock( int x, int y, int z, int face ) {
|
||||
if (destroyDelay > 0) {
|
||||
destroyDelay--;
|
||||
return;
|
||||
}
|
||||
|
||||
if (x == xDestroyBlock && y == yDestroyBlock && z == zDestroyBlock) {
|
||||
int t = minecraft->level->getTile(x, y, z);
|
||||
if (t == 0) return;
|
||||
Tile* tile = Tile::tiles[t];
|
||||
|
||||
destroyProgress += tile->getDestroyProgress(minecraft->player);
|
||||
|
||||
if ((++destroyTicks & 3) == 1) {
|
||||
#ifndef STANDALONE_SERVER
|
||||
if (tile != NULL) {
|
||||
minecraft->soundEngine->play(tile->soundType->getStepSound(), x + 0.5f, y + 0.5f, z + 0.5f, (tile->soundType->getVolume() + 1) / 8, tile->soundType->getPitch() * 0.5f);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (destroyProgress >= 1) {
|
||||
destroyBlock(x, y, z, face);
|
||||
destroyProgress = 0;
|
||||
oDestroyProgress = 0;
|
||||
destroyTicks = 0;
|
||||
destroyDelay = 5;
|
||||
}
|
||||
} else {
|
||||
destroyProgress = 0;
|
||||
oDestroyProgress = 0;
|
||||
destroyTicks = 0;
|
||||
xDestroyBlock = x;
|
||||
yDestroyBlock = y;
|
||||
zDestroyBlock = z;
|
||||
}
|
||||
}
|
||||
|
||||
bool SurvivalMode::destroyBlock( int x, int y, int z, int face ) {
|
||||
int t = minecraft->level->getTile(x, y, z);
|
||||
int data = minecraft->level->getData(x, y, z);
|
||||
bool changed = GameMode::destroyBlock(x, y, z, face);
|
||||
bool couldDestroy = minecraft->player->canDestroy(Tile::tiles[t]);
|
||||
|
||||
ItemInstance* item = minecraft->player->inventory->getSelected();
|
||||
if (item != NULL) {
|
||||
item->mineBlock(t, x, y, z);
|
||||
if (item->count == 0) {
|
||||
//item->snap(minecraft->player);
|
||||
minecraft->player->inventory->clearSlot(minecraft->player->inventory->selected);
|
||||
}
|
||||
}
|
||||
if (changed && couldDestroy) {
|
||||
ItemInstance instance(t, 1, data);
|
||||
Tile::tiles[t]->playerDestroy(minecraft->level, minecraft->player, x, y, z, data);
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
void SurvivalMode::stopDestroyBlock() {
|
||||
destroyProgress = 0;
|
||||
destroyDelay = 0;
|
||||
}
|
||||
|
||||
void SurvivalMode::initAbilities( Abilities& abilities ) {
|
||||
abilities.flying = false;
|
||||
abilities.mayfly = false;
|
||||
abilities.instabuild = false;
|
||||
abilities.invulnerable = false;
|
||||
}
|
||||
|
||||
void SurvivalMode::startDestroyBlock( int x, int y, int z, int face ) {
|
||||
if(minecraft->player->getCarriedItem() != NULL && minecraft->player->getCarriedItem()->id == Item::bow->id)
|
||||
return;
|
||||
|
||||
int t = minecraft->level->getTile(x, y, z);
|
||||
if (t > 0 && destroyProgress == 0) Tile::tiles[t]->attack(minecraft->level, x, y, z, minecraft->player);
|
||||
if (t > 0 && Tile::tiles[t]->getDestroyProgress(minecraft->player) >= 1)
|
||||
destroyBlock(x, y, z, face);
|
||||
}
|
||||
31
src/client/gamemode/SurvivalMode.h
Executable file
31
src/client/gamemode/SurvivalMode.h
Executable file
@@ -0,0 +1,31 @@
|
||||
#ifndef NET_MINECRAFT_CLIENT_GAMEMODE__SurvivalMode_H__
|
||||
#define NET_MINECRAFT_CLIENT_GAMEMODE__SurvivalMode_H__
|
||||
|
||||
#include "GameMode.h"
|
||||
|
||||
class Abilities;
|
||||
class Minecraft;
|
||||
|
||||
class SurvivalMode: public GameMode
|
||||
{
|
||||
typedef GameMode super;
|
||||
public:
|
||||
SurvivalMode(Minecraft* minecraft);
|
||||
|
||||
bool destroyBlock(int x, int y, int z, int face);
|
||||
void startDestroyBlock(int x, int y, int z, int face);
|
||||
void continueDestroyBlock(int x, int y, int z, int face);
|
||||
void stopDestroyBlock();
|
||||
|
||||
bool canHurtPlayer() { return true; }
|
||||
|
||||
bool isSurvivalType() { return true; }
|
||||
|
||||
void initAbilities( Abilities& abilities );
|
||||
private:
|
||||
int xDestroyBlock;
|
||||
int yDestroyBlock;
|
||||
int zDestroyBlock;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT_GAMEMODE__SurvivalMode_H__*/
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "Font.hpp"
|
||||
#include "Font.h"
|
||||
|
||||
//#include "SharedConstants.hpp"
|
||||
#include "client/Options.hpp"
|
||||
#include "client/renderer/Textures.hpp"
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "util/Mth.hpp"
|
||||
//#include "SharedConstants.h"
|
||||
#include "../Options.h"
|
||||
#include "../renderer/Textures.h"
|
||||
#include "../renderer/Tesselator.h"
|
||||
#include "../../util/Mth.h"
|
||||
#include <cstring>
|
||||
|
||||
Font::Font( Options* options, const std::string& name, Textures* textures )
|
||||
@@ -186,7 +186,7 @@ void Font::draw( const std::string& str, float x, float y, int color, bool darke
|
||||
glPushMatrix2();
|
||||
glTranslatef2((GLfloat)x, (GLfloat)y, 0.0f);
|
||||
for (unsigned int i = 0; i < str.length(); i++) {
|
||||
while (str.length() > i + 1 && str[i] == '\xa7') {
|
||||
while (str.length() > i + 1 && str[i] == '<EFBFBD>') {
|
||||
int cc = hex.find((char)tolower(str[i + 1]));
|
||||
if (cc < 0 || cc > 15) cc = 15;
|
||||
lists[index++] = listPos + 256 + cc + (darken ? 16 : 0);
|
||||
@@ -235,7 +235,7 @@ int Font::width( const std::string& str )
|
||||
int len = 0;
|
||||
|
||||
for (unsigned int i = 0; i < str.length(); i++) {
|
||||
if (str[i] == '\xa7') {
|
||||
if (str[i] == '<EFBFBD>') {
|
||||
i++;
|
||||
} else {
|
||||
//int ch = SharedConstants.acceptableLetters.indexOf(str.charAt(i));
|
||||
@@ -274,7 +274,7 @@ std::string Font::sanitize( const std::string& str )
|
||||
int j = 0;
|
||||
|
||||
for (unsigned int i = 0; i < str.length(); i++) {
|
||||
if (str[i] == '\xa7') {
|
||||
if (str[i] == '<EFBFBD>') {
|
||||
i++;
|
||||
//} else if (SharedConstants.acceptableLetters.indexOf(str.charAt(i)) >= 0) {
|
||||
} else {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#pragma once
|
||||
#ifndef NET_MINECRAFT_CLIENT_GUI__Font_H__
|
||||
#define NET_MINECRAFT_CLIENT_GUI__Font_H__
|
||||
|
||||
//package net.minecraft.client.gui;
|
||||
|
||||
#include <string>
|
||||
#include <cctype>
|
||||
|
||||
#include "client/renderer/gles.hpp"
|
||||
#include "../renderer/gles.h"
|
||||
|
||||
class Textures;
|
||||
class Options;
|
||||
@@ -59,3 +60,4 @@ private:
|
||||
unsigned char _charOffset;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT_GUI__Font_H__*/
|
||||
@@ -1,36 +1,32 @@
|
||||
#include "Gui.hpp"
|
||||
#include "Font.hpp"
|
||||
#include "MinecraftClient.hpp"
|
||||
#include "client/Options.hpp"
|
||||
#include "platform/input/Keyboard.hpp"
|
||||
#include "screens/IngameBlockSelectionScreen.hpp"
|
||||
#include "screens/ChatScreen.hpp"
|
||||
#include "screens/ConsoleScreen.hpp"
|
||||
#include <Minecraft.hpp>
|
||||
#include "client/player/LocalPlayer.hpp"
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "client/renderer/TileRenderer.hpp"
|
||||
#include "client/renderer/LevelRenderer.hpp"
|
||||
#include "client/renderer/GameRenderer.hpp"
|
||||
#include "client/renderer/entity/ItemRenderer.hpp"
|
||||
#include "client/player/input/IInputHolder.hpp"
|
||||
#include "client/gamemode/GameMode.hpp"
|
||||
#include "client/gamemode/CreativeMode.hpp"
|
||||
#include "client/renderer/Textures.hpp"
|
||||
#include "AppConstants.hpp"
|
||||
#include "world/entity/player/Inventory.hpp"
|
||||
#include "world/level/material/Material.hpp"
|
||||
#include "world/item/Item.hpp"
|
||||
#include "world/item/ItemInstance.hpp"
|
||||
#include "platform/input/Mouse.hpp"
|
||||
#include "world/level/Level.hpp"
|
||||
#include "world/PosTranslator.hpp"
|
||||
#include "platform/time.hpp"
|
||||
#include "Gui.h"
|
||||
#include "Font.h"
|
||||
#include "Options.h"
|
||||
#include "Keyboard.h"
|
||||
#include "screens/IngameBlockSelectionScreen.h"
|
||||
#include "screens/ChatScreen.h"
|
||||
#include "screens/ConsoleScreen.h"
|
||||
#include "../Minecraft.h"
|
||||
#include "../player/LocalPlayer.h"
|
||||
#include "../renderer/Tesselator.h"
|
||||
#include "../renderer/TileRenderer.h"
|
||||
#include "../renderer/LevelRenderer.h"
|
||||
#include "../renderer/GameRenderer.h"
|
||||
#include "../renderer/entity/ItemRenderer.h"
|
||||
#include "../player/input/IInputHolder.h"
|
||||
#include "../gamemode/GameMode.h"
|
||||
#include "../gamemode/CreativeMode.h"
|
||||
#include "../renderer/Textures.h"
|
||||
#include "../../AppConstants.h"
|
||||
#include "../../world/entity/player/Inventory.h"
|
||||
#include "../../world/level/material/Material.h"
|
||||
#include "../../world/item/Item.h"
|
||||
#include "../../world/item/ItemInstance.h"
|
||||
#include "../../platform/input/Mouse.h"
|
||||
#include "../../world/level/Level.h"
|
||||
#include "../../world/PosTranslator.h"
|
||||
#include "../../platform/time.h"
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
|
||||
#define MAX_MESSAGE_WIDTH 240
|
||||
|
||||
float Gui::InvGuiScale = 1.0f / 3.0f;
|
||||
float Gui::GuiScale = 1.0f / Gui::InvGuiScale;
|
||||
@@ -38,15 +34,32 @@ const float Gui::DropTicks = 40.0f;
|
||||
|
||||
//#include <android/log.h>
|
||||
|
||||
// @todo virtual controlConfigurationChanged() when player switches from keyboard to touch for example
|
||||
Gui::Gui(MinecraftClient& minecraft) : minecraft(minecraft), _openInventorySlot(minecraft.useTouchscreen()) {
|
||||
Gui::Gui(Minecraft* minecraft)
|
||||
: minecraft(minecraft),
|
||||
tickCount(0),
|
||||
progress(0),
|
||||
overlayMessageTime(0),
|
||||
animateOverlayMessageColor(false),
|
||||
chatScrollOffset(0),
|
||||
tbr(1),
|
||||
_inventoryNeedsUpdate(true),
|
||||
_flashSlotId(-1),
|
||||
_flashSlotStartTime(-1),
|
||||
_slotFont(NULL),
|
||||
_numSlots(4),
|
||||
_currentDropTicks(-1),
|
||||
_currentDropSlot(-1),
|
||||
MAX_MESSAGE_WIDTH(240),
|
||||
itemNameOverlayTime(2)
|
||||
{
|
||||
glGenBuffers2(1, &_inventoryRc.vboId);
|
||||
glGenBuffers2(1, &rcFeedbackInner.vboId);
|
||||
glGenBuffers2(1, &rcFeedbackOuter.vboId);
|
||||
//Gui::InvGuiScale = 1.0f / (int) (3 * Minecraft::width / 854);
|
||||
}
|
||||
|
||||
Gui::~Gui() {
|
||||
Gui::~Gui()
|
||||
{
|
||||
if (_slotFont)
|
||||
delete _slotFont;
|
||||
|
||||
@@ -54,16 +67,20 @@ Gui::~Gui() {
|
||||
}
|
||||
|
||||
void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
||||
if (!minecraft.level || !minecraft.getPlayer())
|
||||
|
||||
if (!minecraft->level || !minecraft->player)
|
||||
return;
|
||||
|
||||
//minecraft->gameRenderer->setupGuiScreen();
|
||||
Font* font = minecraft.getFont();
|
||||
Font* font = minecraft->font;
|
||||
|
||||
const bool isTouchInterface = minecraft.useTouchscreen();
|
||||
|
||||
const int screenWidth = (int)(minecraft.getScreenWidth() * InvGuiScale);
|
||||
const int screenHeight = (int)(minecraft.getScreenHeigth() * InvGuiScale);
|
||||
#ifdef PLATFORM_DESKTOP
|
||||
const bool isTouchInterface = false;
|
||||
#else
|
||||
const bool isTouchInterface = minecraft->useTouchscreen();
|
||||
#endif
|
||||
const int screenWidth = (int)(minecraft->width * InvGuiScale);
|
||||
const int screenHeight = (int)(minecraft->height * InvGuiScale);
|
||||
blitOffset = -90;
|
||||
renderProgressIndicator(isTouchInterface, screenWidth, screenHeight, a);
|
||||
|
||||
@@ -75,9 +92,9 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
||||
// F: 3
|
||||
int ySlot = screenHeight - 16 - 3;
|
||||
|
||||
if (!minecraft.options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||
if (minecraft.gameMode->canHurtPlayer()) {
|
||||
minecraft.getTextures()->loadAndBindTexture("gui/icons.png");
|
||||
if (!minecraft->options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||
if (minecraft->gameMode->canHurtPlayer()) {
|
||||
minecraft->textures->loadAndBindTexture("gui/icons.png");
|
||||
Tesselator& t = Tesselator::instance;
|
||||
t.beginOverride();
|
||||
t.colorABGR(0xffffffff);
|
||||
@@ -87,7 +104,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
||||
}
|
||||
}
|
||||
|
||||
if(minecraft.getPlayer()->getSleepTimer() > 0) {
|
||||
if(minecraft->player->getSleepTimer() > 0) {
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glDisable(GL_ALPHA_TEST);
|
||||
|
||||
@@ -96,7 +113,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) {
|
||||
glEnable(GL_ALPHA_TEST);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
}
|
||||
if (!minecraft.options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||
if (!minecraft->options.getBooleanValue(OPTIONS_HIDEGUI)) {
|
||||
renderToolBar(a, ySlot, screenWidth);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
@@ -188,10 +205,16 @@ void Gui::handleClick(int button, int x, int y) {
|
||||
if (button != MouseAction::ACTION_LEFT) return;
|
||||
|
||||
int slot = getSlotIdAt(x, y);
|
||||
if (slot != -1) {
|
||||
if (_openInventorySlot && slot == (getNumSlots()-1)) {
|
||||
if (slot != -1)
|
||||
{
|
||||
#ifndef PLATFORM_DESKTOP
|
||||
if (slot == (getNumSlots()-1))
|
||||
{
|
||||
minecraft->screenChooser.setScreen(SCREEN_BLOCKSELECTION);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
minecraft->player->inventory->selectSlot(slot);
|
||||
itemNameOverlayTime = 0;
|
||||
}
|
||||
@@ -325,7 +348,7 @@ void Gui::setNowPlaying(const std::string& string) {
|
||||
void Gui::displayClientMessage(const std::string& messageId) {
|
||||
//Language language = Language.getInstance();
|
||||
//std::string languageString = language.getElement(messageId);
|
||||
addMessage(messageId);
|
||||
addMessage(std::string("Client message: ") + messageId);
|
||||
}
|
||||
|
||||
void Gui::renderVignette(float br, int w, int h) {
|
||||
@@ -406,9 +429,9 @@ void Gui::onConfigChanged( const Config& c ) {
|
||||
// Create outer feedback circle
|
||||
//
|
||||
#ifdef ANDROID
|
||||
const float mm = 50; //20
|
||||
const float mm = 12;
|
||||
#else
|
||||
const float mm = 50; //20
|
||||
const float mm = 12;
|
||||
#endif
|
||||
const float maxRadius = minecraft->pixelCalcUi.millimetersToPixels(mm);
|
||||
const float radius = Mth::Min(80.0f/2, maxRadius);
|
||||
@@ -513,7 +536,11 @@ void Gui::tickItemDrop()
|
||||
static bool isCurrentlyActive = false;
|
||||
isCurrentlyActive = false;
|
||||
|
||||
int slots = getNumSlots() - _openInventorySlot;
|
||||
int slots = getNumSlots();
|
||||
|
||||
#ifndef PLATFORM_DESKTOP
|
||||
slots--;
|
||||
#endif
|
||||
|
||||
if (Mouse::isButtonDown(MouseAction::ACTION_LEFT)) {
|
||||
int slot = getSlotIdAt(Mouse::getX(), Mouse::getY());
|
||||
@@ -814,9 +841,7 @@ void Gui::renderPlayerList(Font* font, int screenWidth, int screenHeight) {
|
||||
}
|
||||
|
||||
// player count title
|
||||
std::ostringstream titleStream;
|
||||
titleStream << "Players (" << playerNames.size() << ")";
|
||||
std::string titleText = titleStream.str();
|
||||
std::string titleText = "Players (" + std::to_string(playerNames.size()) + ")";
|
||||
float titleWidth = font->width(titleText);
|
||||
|
||||
if (titleWidth > maxNameWidth)
|
||||
@@ -1055,7 +1080,13 @@ void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
|
||||
|
||||
float x = baseItemX;
|
||||
|
||||
int slots = getNumSlots() - _openInventorySlot;
|
||||
int slots = getNumSlots();
|
||||
|
||||
// TODO: if using touchscreen
|
||||
|
||||
#ifndef PLATFORM_DESKTOP
|
||||
slots--;
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < slots; i++) {
|
||||
renderSlot(i, (int)x, ySlot, a);
|
||||
@@ -1063,10 +1094,9 @@ void Gui::renderToolBar( float a, int ySlot, const int screenWidth ) {
|
||||
}
|
||||
_inventoryNeedsUpdate = false;
|
||||
|
||||
|
||||
if (_openInventorySlot) {
|
||||
blit(screenWidth / 2 + 10 * getNumSlots() - 20 + 4, ySlot + 6, 242, 252, 14, 4, 14, 4);
|
||||
}
|
||||
#ifndef PLATFORM_DESKTOP
|
||||
blit(screenWidth / 2 + 10 * getNumSlots() - 20 + 4, ySlot + 6, 242, 252, 14, 4, 14, 4);
|
||||
#endif
|
||||
|
||||
minecraft->textures->loadAndBindTexture("gui/gui_blocks.png");
|
||||
t.endOverrideAndDraw();
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
#pragma once
|
||||
#ifndef NET_MINECRAFT_CLIENT_GUI__Gui_H__
|
||||
#define NET_MINECRAFT_CLIENT_GUI__Gui_H__
|
||||
|
||||
//package net.minecraft.client.gui;
|
||||
|
||||
#include "GuiComponent.hpp"
|
||||
#include "Font.hpp"
|
||||
#include "client/player/input/touchscreen/TouchAreaModel.hpp"
|
||||
#include "client/renderer/RenderChunk.hpp"
|
||||
#include "util/Random.hpp"
|
||||
#include "client/IConfigListener.hpp"
|
||||
#include "GuiComponent.h"
|
||||
#include "Font.h"
|
||||
#include "../player/input/touchscreen/TouchAreaModel.h"
|
||||
#include "../renderer/RenderChunk.h"
|
||||
#include "../../util/Random.h"
|
||||
#include "../IConfigListener.h"
|
||||
|
||||
class MinecraftClient;
|
||||
class Minecraft;
|
||||
class ItemInstance;
|
||||
class Textures;
|
||||
class Tesselator;
|
||||
@@ -26,7 +27,7 @@ typedef std::vector<GuiMessage> GuiMessageList;
|
||||
class Gui: public GuiComponent, IConfigListener
|
||||
{
|
||||
public:
|
||||
Gui(MinecraftClient& minecraft);
|
||||
Gui(Minecraft* minecraft);
|
||||
~Gui();
|
||||
|
||||
int getSlotIdAt(int x, int y);
|
||||
@@ -89,43 +90,43 @@ private:
|
||||
void tickItemDrop();
|
||||
float cubeSmoothStep(float percentage, float min, float max);
|
||||
public:
|
||||
float progress = 0.f;
|
||||
float progress;
|
||||
std::string selectedName;
|
||||
static float InvGuiScale;
|
||||
static float GuiScale;
|
||||
|
||||
private:
|
||||
int MAX_MESSAGE_WIDTH;
|
||||
//ItemRenderer itemRenderer;
|
||||
GuiMessageList guiMessages;
|
||||
int chatScrollOffset = 0;
|
||||
int chatScrollOffset;
|
||||
Random random;
|
||||
|
||||
MinecraftClient& minecraft;
|
||||
int tickCount = 0;
|
||||
float itemNameOverlayTime = 2;
|
||||
Minecraft* minecraft;
|
||||
int tickCount;
|
||||
float itemNameOverlayTime;
|
||||
std::string overlayMessageString;
|
||||
int overlayMessageTime = 0;
|
||||
bool animateOverlayMessageColor = false;
|
||||
int overlayMessageTime;
|
||||
bool animateOverlayMessageColor;
|
||||
|
||||
float tbr = 1.f;
|
||||
float tbr;
|
||||
|
||||
RenderChunk _inventoryRc;
|
||||
bool _inventoryNeedsUpdate = true;
|
||||
bool _inventoryNeedsUpdate;
|
||||
|
||||
int _flashSlotId = -1;
|
||||
float _flashSlotStartTime = -1;
|
||||
int _flashSlotId;
|
||||
float _flashSlotStartTime;
|
||||
|
||||
Font* _slotFont = nullptr;
|
||||
int _numSlots = 4;
|
||||
Font* _slotFont;
|
||||
int _numSlots;
|
||||
|
||||
RenderChunk rcFeedbackOuter;
|
||||
RenderChunk rcFeedbackInner;
|
||||
|
||||
// For dropping
|
||||
static const float DropTicks;
|
||||
float _currentDropTicks = -1;
|
||||
int _currentDropSlot = -1;
|
||||
|
||||
bool _openInventorySlot;
|
||||
float _currentDropTicks;
|
||||
int _currentDropSlot;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT_GUI__Gui_H__*/
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "GuiComponent.hpp"
|
||||
#include "GuiComponent.h"
|
||||
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "client/renderer/gles.hpp"
|
||||
#include "Font.hpp"
|
||||
#include "../renderer/Tesselator.h"
|
||||
#include "../renderer/gles.h"
|
||||
#include "Font.h"
|
||||
|
||||
|
||||
GuiComponent::GuiComponent()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef NET_MINECRAFT_CLIENT_GUI__GuiComponent_H__
|
||||
#define NET_MINECRAFT_CLIENT_GUI__GuiComponent_H__
|
||||
|
||||
//package net.minecraft.client.gui;
|
||||
|
||||
@@ -30,3 +31,4 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT_GUI__GuiComponent_H__*/
|
||||
@@ -1,12 +1,12 @@
|
||||
#include "Screen.hpp"
|
||||
#include "components/Button.hpp"
|
||||
#include "components/TextBox.hpp"
|
||||
#include <Minecraft.hpp>
|
||||
#include "client/renderer/Tesselator.hpp"
|
||||
#include "client/sound/SoundEngine.hpp"
|
||||
#include "platform/input/Keyboard.hpp"
|
||||
#include "platform/input/Mouse.hpp"
|
||||
#include "client/renderer/Textures.hpp"
|
||||
#include "Screen.h"
|
||||
#include "components/Button.h"
|
||||
#include "components/TextBox.h"
|
||||
#include "../Minecraft.h"
|
||||
#include "../renderer/Tesselator.h"
|
||||
#include "../sound/SoundEngine.h"
|
||||
#include "../../platform/input/Keyboard.h"
|
||||
#include "../../platform/input/Mouse.h"
|
||||
#include "../renderer/Textures.h"
|
||||
|
||||
Screen::Screen()
|
||||
: passEvents(false),
|
||||
@@ -177,11 +177,9 @@ void Screen::keyPressed( int eventKey )
|
||||
textbox->keyPressed(minecraft, eventKey);
|
||||
}
|
||||
|
||||
#ifdef TABBING
|
||||
if (minecraft->useTouchscreen())
|
||||
return;
|
||||
|
||||
|
||||
// "Tabbing" the buttons (walking with keys)
|
||||
const int tabButtonCount = tabButtons.size();
|
||||
if (!tabButtonCount)
|
||||
@@ -201,7 +199,6 @@ void Screen::keyPressed( int eventKey )
|
||||
}
|
||||
|
||||
updateTabButtonSelection();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Screen::charPressed(char inputChar) {
|
||||
@@ -212,13 +209,11 @@ void Screen::charPressed(char inputChar) {
|
||||
|
||||
void Screen::updateTabButtonSelection()
|
||||
{
|
||||
#ifdef TABBING
|
||||
if (minecraft->useTouchscreen())
|
||||
return;
|
||||
|
||||
for (unsigned int i = 0; i < tabButtons.size(); ++i)
|
||||
tabButtons[i]->selected = (i == tabButtonIndex);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Screen::mouseClicked( int x, int y, int buttonNum )
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#pragma once
|
||||
#ifndef NET_MINECRAFT_CLIENT_GUI__Screen_H__
|
||||
#define NET_MINECRAFT_CLIENT_GUI__Screen_H__
|
||||
|
||||
//package net.minecraft.client.gui;
|
||||
|
||||
#include <vector>
|
||||
#include "GuiComponent.hpp"
|
||||
#include "GuiComponent.h"
|
||||
|
||||
class Font;
|
||||
class Minecraft;
|
||||
@@ -79,3 +80,4 @@ private:
|
||||
Button* clickedButton;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT_GUI__Screen_H__*/
|
||||
11
src/client/gui/TweenData.h
Executable file
11
src/client/gui/TweenData.h
Executable file
@@ -0,0 +1,11 @@
|
||||
#ifndef NET_MINECRAFT_CLIENT_GUI__TweenData_H__
|
||||
#define NET_MINECRAFT_CLIENT_GUI__TweenData_H__
|
||||
|
||||
typedef struct TweenData {
|
||||
float cur;
|
||||
float dur;
|
||||
float start;
|
||||
float stop;
|
||||
} TweenData;
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT_GUI__TweenData_H__*/
|
||||
@@ -1,9 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
typedef struct TweenData {
|
||||
float cur;
|
||||
float dur;
|
||||
float start;
|
||||
float stop;
|
||||
} TweenData;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "Button.hpp"
|
||||
#include "client/Minecraft.hpp"
|
||||
#include "client/renderer/Textures.hpp"
|
||||
#include "Button.h"
|
||||
#include "../../Minecraft.h"
|
||||
#include "../../renderer/Textures.h"
|
||||
|
||||
Button::Button(int id, const std::string& msg)
|
||||
: GuiElement(true, true, 0, 0, 200, 24),
|
||||
@@ -95,7 +95,7 @@ void Button::renderBg( Minecraft* minecraft, int xm, int ym )
|
||||
}
|
||||
|
||||
bool Button::hovered(Minecraft* minecraft, int xm , int ym) {
|
||||
return minecraft->useTouchscreen()? (_currentlyDown && isInside(xm, ym)) : isInside(xm, ym);
|
||||
return minecraft->useTouchscreen()? (_currentlyDown && isInside(xm, ym)) : false;
|
||||
}
|
||||
|
||||
bool Button::isInside( int xm, int ym ) {
|
||||
@@ -143,8 +143,7 @@ TButton::TButton( int id, int x, int y, int w, int h, const std::string& msg )
|
||||
|
||||
void TButton::renderBg( Minecraft* minecraft, int xm, int ym )
|
||||
{
|
||||
bool hovered = active && (minecraft->useTouchscreen()? (_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height) : isInside(xm, ym));
|
||||
// bool hovered = active && (_currentlyDown && isInside(xm, ym));
|
||||
bool hovered = active && (minecraft->useTouchscreen()? (_currentlyDown && xm >= x && ym >= y && xm < x + width && ym < y + height) : false);
|
||||
|
||||
minecraft->textures->loadAndBindTexture("gui/touchgui.png");
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#pragma once
|
||||
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__Button_H__
|
||||
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__Button_H__
|
||||
|
||||
//package net.minecraft.client.gui;
|
||||
|
||||
#include <string>
|
||||
#include "GuiElement.hpp"
|
||||
#include "client/Options.hpp"
|
||||
#include "GuiElement.h"
|
||||
#include "../../Options.h"
|
||||
|
||||
class Font;
|
||||
class Minecraft;
|
||||
@@ -76,3 +77,4 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__Button_H__*/
|
||||
@@ -1 +1 @@
|
||||
#include "GuiElement.hpp"
|
||||
#include "GuiElement.h"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "Button.hpp"
|
||||
#ifndef NET_MINECRAFT_CLIENT_GUI__GButton_H__
|
||||
#define NET_MINECRAFT_CLIENT_GUI__GButton_H__
|
||||
#include "Button.h"
|
||||
|
||||
class GButton: public Button {
|
||||
typedef Button super;
|
||||
@@ -51,3 +52,4 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT_GUI__GButton_H__*/
|
||||
@@ -1,4 +1,4 @@
|
||||
#include "GuiElement.hpp"
|
||||
#include "GuiElement.h"
|
||||
|
||||
GuiElement::GuiElement( bool active/*=false*/, bool visible/*=true*/, int x /*= 0*/, int y /*= 0*/, int width/*=24*/, int height/*=24*/ )
|
||||
: active(active),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "client/gui/GuiComponent.hpp"
|
||||
#ifndef NET_MINECRAFT_CLIENT_GUI__GuiElement_H__
|
||||
#define NET_MINECRAFT_CLIENT_GUI__GuiElement_H__
|
||||
#include "../GuiComponent.h"
|
||||
|
||||
class Tesselator;
|
||||
class Minecraft;
|
||||
@@ -30,3 +31,4 @@ public:
|
||||
int height;
|
||||
};
|
||||
|
||||
#endif /*NET_MINECRAFT_CLIENT_GUI__GuiElement_H__*/
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user