Compare commits
5 Commits
ios-suppor
...
c62daa9c1c
| Author | SHA1 | Date | |
|---|---|---|---|
| c62daa9c1c | |||
| f6377bc5a2 | |||
| 431b2a2704 | |||
| 67acd7f9a6 | |||
| 6f1ca8fc3b |
@@ -3,10 +3,10 @@ project(MinecraftPE)
|
||||
|
||||
include(cmake/CPM.cmake)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||
set(CMAKE_POLICY_VERSION_MINIMUM 3.10)
|
||||
|
||||
add_definitions(-DLUA_USE_DLOPEN)
|
||||
include(cmake/EnumOption.cmake)
|
||||
|
||||
if(EMSCRIPTEN)
|
||||
@@ -95,6 +95,46 @@ else()
|
||||
"GLFW_BUILD_TESTS OFF"
|
||||
"GLFW_BUILD_DOCS OFF"
|
||||
)
|
||||
|
||||
CPMAddPackage("gh:halx99/sol2#support-lua-5.5")
|
||||
CPMAddPackage("gh:lua/lua#master")
|
||||
|
||||
add_library(
|
||||
lua STATIC
|
||||
${lua_SOURCE_DIR}/lapi.c
|
||||
${lua_SOURCE_DIR}/lauxlib.c
|
||||
${lua_SOURCE_DIR}/lbaselib.c
|
||||
${lua_SOURCE_DIR}/lcode.c
|
||||
${lua_SOURCE_DIR}/lcorolib.c
|
||||
${lua_SOURCE_DIR}/lctype.c
|
||||
${lua_SOURCE_DIR}/ldblib.c
|
||||
${lua_SOURCE_DIR}/ldebug.c
|
||||
${lua_SOURCE_DIR}/ldo.c
|
||||
${lua_SOURCE_DIR}/ldump.c
|
||||
${lua_SOURCE_DIR}/lfunc.c
|
||||
${lua_SOURCE_DIR}/lgc.c
|
||||
${lua_SOURCE_DIR}/linit.c
|
||||
${lua_SOURCE_DIR}/liolib.c
|
||||
${lua_SOURCE_DIR}/llex.c
|
||||
${lua_SOURCE_DIR}/lmathlib.c
|
||||
${lua_SOURCE_DIR}/lmem.c
|
||||
${lua_SOURCE_DIR}/loadlib.c
|
||||
${lua_SOURCE_DIR}/lobject.c
|
||||
${lua_SOURCE_DIR}/lopcodes.c
|
||||
${lua_SOURCE_DIR}/loslib.c
|
||||
${lua_SOURCE_DIR}/lparser.c
|
||||
${lua_SOURCE_DIR}/lstate.c
|
||||
${lua_SOURCE_DIR}/lstring.c
|
||||
${lua_SOURCE_DIR}/lstrlib.c
|
||||
${lua_SOURCE_DIR}/ltable.c
|
||||
${lua_SOURCE_DIR}/ltablib.c
|
||||
${lua_SOURCE_DIR}/ltm.c
|
||||
${lua_SOURCE_DIR}/lua.c
|
||||
${lua_SOURCE_DIR}/lundump.c
|
||||
${lua_SOURCE_DIR}/lutf8lib.c
|
||||
${lua_SOURCE_DIR}/lvm.c
|
||||
${lua_SOURCE_DIR}/lzio.c
|
||||
)
|
||||
endif()
|
||||
|
||||
CPMAddPackage(
|
||||
@@ -215,6 +255,8 @@ file(GLOB SERVER_SOURCES
|
||||
|
||||
"src/world/phys/HitResult.cpp"
|
||||
"src/commands/*.cpp"
|
||||
|
||||
"src/plugins/*.cpp"
|
||||
)
|
||||
|
||||
file(GLOB CLIENT_SOURCES
|
||||
@@ -300,6 +342,8 @@ file(GLOB CLIENT_SOURCES
|
||||
"src/main.cpp"
|
||||
|
||||
"src/commands/*.cpp"
|
||||
"src/plugins/*.cpp"
|
||||
|
||||
)
|
||||
|
||||
if (${PLATFORM} STREQUAL "Desktop")
|
||||
@@ -308,17 +352,20 @@ endif()
|
||||
|
||||
# Server
|
||||
add_executable("${PROJECT_NAME}-server" ${SERVER_SOURCES})
|
||||
|
||||
set_target_properties("${PROJECT_NAME}-server" PROPERTIES ENABLE_EXPORTS TRUE)
|
||||
target_compile_definitions("${PROJECT_NAME}-server" PUBLIC "STANDALONE_SERVER" "SERVER_PROFILER")
|
||||
|
||||
target_include_directories("${PROJECT_NAME}-server" PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/src/"
|
||||
"${lua_SOURCE_DIR}/"
|
||||
|
||||
"project/lib_projects/raknet/jni/RaknetSources"
|
||||
)
|
||||
|
||||
target_link_libraries("${PROJECT_NAME}-server" ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_LIBS})
|
||||
target_link_libraries("${PROJECT_NAME}-server" ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_LIBS} lua sol2::sol2)
|
||||
|
||||
add_executable(${PROJECT_NAME} ${CLIENT_SOURCES})
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES ENABLE_EXPORTS TRUE)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC ${PLATFORM_CPP})
|
||||
|
||||
@@ -328,6 +375,8 @@ target_include_directories(${PROJECT_NAME} PUBLIC
|
||||
"${openal_SOURCE_DIR}/include"
|
||||
"${glfw_SOURCE_DIR}/include"
|
||||
"lib/include"
|
||||
"${lua_SOURCE_DIR}/"
|
||||
|
||||
)
|
||||
|
||||
if(${PLATFORM} MATCHES "Web")
|
||||
@@ -375,7 +424,7 @@ endif()
|
||||
|
||||
# Client
|
||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "OPENGL_ES" "NO_EGL" ${PLATFORM})
|
||||
target_link_libraries(${PROJECT_NAME} zlib ${PNG_LIB} OpenAL::OpenAL glfw ${EXTRA_LIBS})
|
||||
target_link_libraries(${PROJECT_NAME} zlib ${PNG_LIB} OpenAL::OpenAL glfw ${EXTRA_LIBS} lua sol2::sol2)
|
||||
|
||||
if (OpenSSL_FOUND)
|
||||
target_link_libraries(${PROJECT_NAME} OpenSSL::SSL OpenSSL::Crypto)
|
||||
|
||||
44
README.md
44
README.md
@@ -1,6 +1,6 @@
|
||||
# MinecraftPE
|
||||
> [!Warning]
|
||||
> [Github repository](https://github.com/Minecraft-PE-0-6-1/minecraft-pe-0.6.1-on-all) **isnt main**. All issues and pull requests should be send in [Gitea Repository](https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1).
|
||||
> Github repository **isnt main**. All issues and pull requests should be send in [Gitea Repository](https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1).
|
||||
|
||||
> [!Important]
|
||||
> We have a discord server, where you can report bugs or send feedback https://discord.gg/c58YesBxve
|
||||
@@ -9,20 +9,23 @@ Source code for **Minecraft Pocket Edition 0.6.1 alpha** with various fixes and
|
||||
|
||||
This project aims to preserve and improve this early version of Minecraft PE.
|
||||
|
||||
# Features
|
||||
- Support for modern IOS and Android, Linux, Web
|
||||
- Improved Dedicated Server (Windows build, anticheat, commands, etc)
|
||||
- Features from Beta version of Minecraft (Grass tint, Beta sky, Smooth lighting, etc) and other tweaks
|
||||
|
||||
# Screenshots
|
||||
<p align="center">
|
||||
|
||||
<img width="49%" alt="menu" src="https://sffempire.ru/mcpe-screenshots/menu.png" />
|
||||
<img width="49%" alt="settings" src="https://sffempire.ru/mcpe-screenshots/settings.png" />
|
||||
<img width="49%" alt="worlds" src="https://sffempire.ru/mcpe-screenshots/worlds.png" />
|
||||
<img width="49%" alt="gameplay" src="https://sffempire.ru/mcpe-screenshots/gameplay.png" />
|
||||
|
||||
</p>
|
||||
# TODO / Roadmap
|
||||
- [x] Add platform GLFW
|
||||
- [x] Compile for Linux
|
||||
- [x] Compile for android aarch64
|
||||
- [x] Touch control improvements
|
||||
- [ ] Screen fixes
|
||||
- [ ] Rewrite platform logic
|
||||
- [x] Fix sound
|
||||
- [x] Do a server connection GUI
|
||||
- [ ] Controller support
|
||||
- [x] Minecraft server hosting
|
||||
- [x] Screen fixess
|
||||
- [x] Fix fog
|
||||
- [x] Add sprinting
|
||||
- [x] Chat (semi working) and commands
|
||||
- [x] Implementing options
|
||||
- [x] Better F3
|
||||
|
||||
# Build
|
||||
|
||||
@@ -76,14 +79,8 @@ cmake --build .
|
||||
```
|
||||
C:\android-ndk-r14b
|
||||
```
|
||||
3. Install **Build tools 35** with [SDKManager](https://dl.google.com/android/repository/commandlinetools-win-15859902_latest.zip) (build-tools should be in AppData):
|
||||
|
||||
```powershell
|
||||
sdkmanager "build-tools;35.0.0" --sdk_root="%LocalAppData%\Android\Sdk"
|
||||
sdkmanager "build-tools;android-36" --sdk_root="%LocalAppData%\Android\Sdk"
|
||||
```
|
||||
|
||||
4. Run the build script:
|
||||
3. Run the build script:
|
||||
|
||||
```powershell
|
||||
# Full build (NDK + Java + APK + install)
|
||||
@@ -157,6 +154,7 @@ sdkmanager "build-tools;android-36" --sdk_root="%LocalAppData%\Android\Sdk"
|
||||
|
||||
```bash
|
||||
35.0.0
|
||||
33.0.2
|
||||
```
|
||||
|
||||
6. Download **Android NDK r14b**:
|
||||
@@ -202,7 +200,7 @@ sdkmanager "build-tools;android-36" --sdk_root="%LocalAppData%\Android\Sdk"
|
||||
```
|
||||
## iOS
|
||||
### Xcode
|
||||
> [!Note]
|
||||
> [Note!]
|
||||
> There's a precompiled IPA artifact in the GitHub mirror under Actions for those who either don't have Macs or don't want to build themself. But if you want to build youself, you'll need a Mac with Xcode. Download Xcode from the Mac App Store.
|
||||
|
||||
### 1. Clone
|
||||
|
||||
@@ -47,8 +47,6 @@
|
||||
9D293CE816071C08000305C8 /* CreateNewWorld_iphone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9D293CE616071C08000305C8 /* CreateNewWorld_iphone.xib */; };
|
||||
9D293CEB160720D6000305C8 /* worldname_iphone5_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 9D293CEA160720D6000305C8 /* worldname_iphone5_3.png */; };
|
||||
9D293CEC160720D6000305C8 /* worldname_iphone5_3.png in Resources */ = {isa = PBXBuildFile; fileRef = 9D293CEA160720D6000305C8 /* worldname_iphone5_3.png */; };
|
||||
BEEF202614CFF670005F0002 /* Lighting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEEF202614CFF670005F0001 /* Lighting.cpp */; };
|
||||
BEEF202614CFF670005F0003 /* Lighting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEEF202614CFF670005F0001 /* Lighting.cpp */; };
|
||||
D506D3E2161288BD0099FA65 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 9D959AFF16036BEE00E23A6F /* Default-568h@2x.png */; };
|
||||
D51DC73614581D4E00E3D761 /* itemframe.png in Resources */ = {isa = PBXBuildFile; fileRef = D51DC73514581D4E00E3D761 /* itemframe.png */; };
|
||||
D51DC74314592B8B00E3D761 /* PVRTexture.m in Sources */ = {isa = PBXBuildFile; fileRef = D51DC74214592B8A00E3D761 /* PVRTexture.m */; };
|
||||
@@ -1181,19 +1179,8 @@
|
||||
F99F0FAD2F8436CE00F2B29A /* FoliageColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99F0FAB2F8436CE00F2B29A /* FoliageColor.cpp */; };
|
||||
F99F0FAF2F8436EB00F2B29A /* Color.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99F0FAE2F8436EB00F2B29A /* Color.cpp */; };
|
||||
F99F0FB02F8436EB00F2B29A /* Color.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99F0FAE2F8436EB00F2B29A /* Color.cpp */; };
|
||||
F9E5A772300E7A8700164066 /* LevelConstants.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F9E5A771300E7A8700164066 /* LevelConstants.cpp */; };
|
||||
F9E5A775300E7AB700164066 /* CommandManager.hpp in Sources */ = {isa = PBXBuildFile; fileRef = F9E5A773300E7AB700164066 /* CommandManager.hpp */; };
|
||||
F9E5A776300E7AB700164066 /* CommandManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F9E5A774300E7AB700164066 /* CommandManager.cpp */; };
|
||||
F9E5A779300E7AD500164066 /* CommandBan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F9E5A777300E7AD500164066 /* CommandBan.cpp */; };
|
||||
F9E5A77A300E7AD500164066 /* CommandBan.hpp in Sources */ = {isa = PBXBuildFile; fileRef = F9E5A778300E7AD500164066 /* CommandBan.hpp */; };
|
||||
F9E5A77D300E7AF400164066 /* CommandHelp.hpp in Sources */ = {isa = PBXBuildFile; fileRef = F9E5A77B300E7AF400164066 /* CommandHelp.hpp */; };
|
||||
F9E5A77E300E7AF400164066 /* CommandHelp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F9E5A77C300E7AF400164066 /* CommandHelp.cpp */; };
|
||||
F9E5A783300E7B0B00164066 /* CommandKick.hpp in Sources */ = {isa = PBXBuildFile; fileRef = F9E5A77F300E7B0A00164066 /* CommandKick.hpp */; };
|
||||
F9E5A784300E7B0B00164066 /* CommandOp.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F9E5A780300E7B0A00164066 /* CommandOp.cpp */; };
|
||||
F9E5A785300E7B0B00164066 /* CommandKick.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F9E5A781300E7B0B00164066 /* CommandKick.cpp */; };
|
||||
F9E5A786300E7B0B00164066 /* CommandOp.hpp in Sources */ = {isa = PBXBuildFile; fileRef = F9E5A782300E7B0B00164066 /* CommandOp.hpp */; };
|
||||
F9E5A789300E7B3400164066 /* Command.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F9E5A787300E7B3400164066 /* Command.cpp */; };
|
||||
F9E5A78A300E7B3400164066 /* Command.hpp in Sources */ = {isa = PBXBuildFile; fileRef = F9E5A788300E7B3400164066 /* Command.hpp */; };
|
||||
BEEF202614CFF670005F0002 /* Lighting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEEF202614CFF670005F0001 /* Lighting.cpp */; };
|
||||
BEEF202614CFF670005F0003 /* Lighting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEEF202614CFF670005F0001 /* Lighting.cpp */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@@ -1261,7 +1248,6 @@
|
||||
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>"; };
|
||||
9D959AFF16036BEE00E23A6F /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = "<group>"; };
|
||||
BEEF202614CFF670005F0001 /* Lighting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Lighting.cpp; sourceTree = "<group>"; };
|
||||
D51A8B01146A200000E5D720 /* minecraftpedemo-info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "minecraftpedemo-info.plist"; sourceTree = "<group>"; };
|
||||
D51DC73514581D4E00E3D761 /* itemframe.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = itemframe.png; sourceTree = "<group>"; };
|
||||
D51DC74114592B8A00E3D761 /* PVRTexture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PVRTexture.h; sourceTree = "<group>"; };
|
||||
@@ -2482,19 +2468,7 @@
|
||||
F99F0FA82F84369F00F2B29A /* GrassColor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GrassColor.cpp; sourceTree = "<group>"; };
|
||||
F99F0FAB2F8436CE00F2B29A /* FoliageColor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FoliageColor.cpp; sourceTree = "<group>"; };
|
||||
F99F0FAE2F8436EB00F2B29A /* Color.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Color.cpp; sourceTree = "<group>"; };
|
||||
F9E5A771300E7A8700164066 /* LevelConstants.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = LevelConstants.cpp; path = ../../src/world/level/LevelConstants.cpp; sourceTree = "<group>"; };
|
||||
F9E5A773300E7AB700164066 /* CommandManager.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = CommandManager.hpp; path = ../../src/commands/CommandManager.hpp; sourceTree = "<group>"; };
|
||||
F9E5A774300E7AB700164066 /* CommandManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = CommandManager.cpp; path = ../../src/commands/CommandManager.cpp; sourceTree = "<group>"; };
|
||||
F9E5A777300E7AD500164066 /* CommandBan.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = CommandBan.cpp; path = ../../src/commands/CommandBan.cpp; sourceTree = "<group>"; };
|
||||
F9E5A778300E7AD500164066 /* CommandBan.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = CommandBan.hpp; path = ../../src/commands/CommandBan.hpp; sourceTree = "<group>"; };
|
||||
F9E5A77B300E7AF400164066 /* CommandHelp.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = CommandHelp.hpp; path = ../../src/commands/CommandHelp.hpp; sourceTree = "<group>"; };
|
||||
F9E5A77C300E7AF400164066 /* CommandHelp.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = CommandHelp.cpp; path = ../../src/commands/CommandHelp.cpp; sourceTree = "<group>"; };
|
||||
F9E5A77F300E7B0A00164066 /* CommandKick.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = CommandKick.hpp; path = ../../src/commands/CommandKick.hpp; sourceTree = "<group>"; };
|
||||
F9E5A780300E7B0A00164066 /* CommandOp.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = CommandOp.cpp; path = ../../src/commands/CommandOp.cpp; sourceTree = "<group>"; };
|
||||
F9E5A781300E7B0B00164066 /* CommandKick.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = CommandKick.cpp; path = ../../src/commands/CommandKick.cpp; sourceTree = "<group>"; };
|
||||
F9E5A782300E7B0B00164066 /* CommandOp.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = CommandOp.hpp; path = ../../src/commands/CommandOp.hpp; sourceTree = "<group>"; };
|
||||
F9E5A787300E7B3400164066 /* Command.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Command.cpp; path = ../../src/commands/Command.cpp; sourceTree = "<group>"; };
|
||||
F9E5A788300E7B3400164066 /* Command.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = Command.hpp; path = ../../src/commands/Command.hpp; sourceTree = "<group>"; };
|
||||
BEEF202614CFF670005F0001 /* Lighting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Lighting.cpp; path = Lighting.cpp; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -4345,19 +4319,6 @@
|
||||
D5CF9C37144C225000E4244F = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
F9E5A788300E7B3400164066 /* Command.hpp */,
|
||||
F9E5A787300E7B3400164066 /* Command.cpp */,
|
||||
F9E5A77F300E7B0A00164066 /* CommandKick.hpp */,
|
||||
F9E5A781300E7B0B00164066 /* CommandKick.cpp */,
|
||||
F9E5A782300E7B0B00164066 /* CommandOp.hpp */,
|
||||
F9E5A780300E7B0A00164066 /* CommandOp.cpp */,
|
||||
F9E5A77B300E7AF400164066 /* CommandHelp.hpp */,
|
||||
F9E5A77C300E7AF400164066 /* CommandHelp.cpp */,
|
||||
F9E5A778300E7AD500164066 /* CommandBan.hpp */,
|
||||
F9E5A777300E7AD500164066 /* CommandBan.cpp */,
|
||||
F9E5A773300E7AB700164066 /* CommandManager.hpp */,
|
||||
F9E5A774300E7AB700164066 /* CommandManager.cpp */,
|
||||
F9E5A771300E7A8700164066 /* LevelConstants.cpp */,
|
||||
F99D344D2F7372A100DC153E /* Launch Screen.storyboard */,
|
||||
D5E1BA9A1451C8A0007DCC4F /* Default@2x.png */,
|
||||
9D959AFF16036BEE00E23A6F /* Default-568h@2x.png */,
|
||||
@@ -5490,19 +5451,6 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F9E5A789300E7B3400164066 /* Command.cpp in Sources */,
|
||||
F9E5A78A300E7B3400164066 /* Command.hpp in Sources */,
|
||||
F9E5A783300E7B0B00164066 /* CommandKick.hpp in Sources */,
|
||||
F9E5A784300E7B0B00164066 /* CommandOp.cpp in Sources */,
|
||||
F9E5A785300E7B0B00164066 /* CommandKick.cpp in Sources */,
|
||||
F9E5A786300E7B0B00164066 /* CommandOp.hpp in Sources */,
|
||||
F9E5A77D300E7AF400164066 /* CommandHelp.hpp in Sources */,
|
||||
F9E5A77E300E7AF400164066 /* CommandHelp.cpp in Sources */,
|
||||
F9E5A779300E7AD500164066 /* CommandBan.cpp in Sources */,
|
||||
F9E5A77A300E7AD500164066 /* CommandBan.hpp in Sources */,
|
||||
F9E5A775300E7AB700164066 /* CommandManager.hpp in Sources */,
|
||||
F9E5A776300E7AB700164066 /* CommandManager.cpp in Sources */,
|
||||
F9E5A772300E7A8700164066 /* LevelConstants.cpp in Sources */,
|
||||
F912B8CF2F6C3D5200BC60DF /* TextBox.h in Sources */,
|
||||
D5CF9C57144C225000E4244F /* main.mm in Sources */,
|
||||
D5CF9C5B144C225000E4244F /* minecraftpeAppDelegate.mm in Sources */,
|
||||
|
||||
@@ -142,8 +142,8 @@ void seedMT( unsigned int seed, unsigned int *state, unsigned int *&next, int &l
|
||||
// so-- that's why the only change I made is to restrict to odd seeds.
|
||||
//
|
||||
|
||||
register unsigned int x = ( seed | 1U ) & 0xFFFFFFFFU, *s = state;
|
||||
register int j;
|
||||
unsigned int x = ( seed | 1U ) & 0xFFFFFFFFU, *s = state;
|
||||
int j;
|
||||
|
||||
for ( left = 0, *s++ = x, j = N; --j;
|
||||
*s++ = ( x *= 69069U ) & 0xFFFFFFFFU )
|
||||
@@ -154,8 +154,8 @@ void seedMT( unsigned int seed, unsigned int *state, unsigned int *&next, int &l
|
||||
|
||||
unsigned int reloadMT( unsigned int *state, unsigned int *&next, int &left )
|
||||
{
|
||||
register unsigned int * p0 = state, *p2 = state + 2, *pM = state + M, s0, s1;
|
||||
register int j;
|
||||
unsigned int * p0 = state, *p2 = state + 2, *pM = state + M, s0, s1;
|
||||
int j;
|
||||
|
||||
if ( left < -1 )
|
||||
seedMT( 4357U );
|
||||
|
||||
@@ -1214,6 +1214,8 @@ void Minecraft::init()
|
||||
checkGlError("Init complete");
|
||||
#endif
|
||||
|
||||
PluginsManager::get().init(*this);
|
||||
|
||||
options.load();
|
||||
|
||||
setIsCreativeMode(false); // false means it's Survival Mode
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "Options.h"
|
||||
#include "commands/CommandManager.hpp"
|
||||
#include <plugins/PluginsManager.hpp>
|
||||
|
||||
#ifndef STANDALONE_SERVER
|
||||
#include "MouseHandler.h"
|
||||
#include "gui/Gui.h"
|
||||
|
||||
@@ -257,7 +257,7 @@ void EntityRenderer::renderShadow(Entity* e, float x, float y, float z, float po
|
||||
//Textures* textures = entityRenderDispatcher->textures;
|
||||
//textures->bind(textures->loadTexture("%clamp%/environment/shadow.png"));
|
||||
Textures* textures = entityRenderDispatcher->textures;
|
||||
textures->loadAndBindTexture("misc/shadow.png");
|
||||
textures->loadAndBindTexture("/misc/shadow.png");
|
||||
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
@@ -298,7 +298,6 @@ void EntityRenderer::renderShadow(Entity* e, float x, float y, float z, float po
|
||||
tt.draw();
|
||||
|
||||
glColor4f2(1, 1, 1, 1);
|
||||
// tt.color(1.f, 1.f, 1.f, 1.f);
|
||||
glDisable2(GL_BLEND);
|
||||
glDepthMask(true);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
@@ -316,7 +315,7 @@ void EntityRenderer::renderTileShadow(Tile* tt, float x, float y, float z, int x
|
||||
float a = ((pow - (y - (yt + yo)) / 2) * 0.5f) * getLevel()->getBrightness(xt, yt, zt);
|
||||
if (a < 0) return;
|
||||
if (a > 1) a = 1;
|
||||
// t.color(1.f, 1.f, 1.f, (float) a);
|
||||
// t.color(1, 1, 1, (float) a);
|
||||
glColor4f2(1, 1, 1, (float) a);
|
||||
|
||||
float x0 = xt + tt->xx0 + xo;
|
||||
|
||||
@@ -15,15 +15,16 @@
|
||||
#include "platform/time.h"
|
||||
#include "SharedConstants.h"
|
||||
#include "world/level/LevelConstants.h"
|
||||
#include <plugins/PluginsManager.hpp>
|
||||
|
||||
#define MAIN_CLASS NinecraftApp
|
||||
static App* g_app = 0;
|
||||
static int g_exitCode = 0;
|
||||
void signal_callback_handler(int signum) {
|
||||
std::cout << "Signum caught: " << signum << std::endl;
|
||||
if(signum == 2 || signum == 3){ // SIGINT || SIGQUIT
|
||||
|
||||
if(g_app != 0) {
|
||||
if (signum == 2 || signum == 3) { // SIGINT || SIGQUIT
|
||||
if (g_app != 0) {
|
||||
g_app->quit();
|
||||
} else {
|
||||
exit(g_exitCode);
|
||||
@@ -64,7 +65,6 @@ std::string findStringInConfig(std::string line, std::string config) {
|
||||
return valueStr;
|
||||
}
|
||||
|
||||
|
||||
int main(int numArguments, char* pszArgs[]) {
|
||||
std::ifstream serverProperties("server.properties");
|
||||
|
||||
@@ -148,7 +148,7 @@ int main(int numArguments, char* pszArgs[]) {
|
||||
}
|
||||
|
||||
printf("Level Name: %s\n", levelName.c_str());
|
||||
|
||||
|
||||
AppContext appContext;
|
||||
appContext.platform = new AppPlatform();
|
||||
App* app = new MAIN_CLASS();
|
||||
@@ -162,6 +162,7 @@ int main(int numArguments, char* pszArgs[]) {
|
||||
float startTime = getTimeS();
|
||||
((MAIN_CLASS*)g_app)->selectLevel(levelDir, levelName, settings);
|
||||
((MAIN_CLASS*)g_app)->hostMultiplayer(port);
|
||||
PluginsManager::get().loadPlugins();
|
||||
|
||||
// Reading ops
|
||||
std::ifstream ops("ops.txt");
|
||||
@@ -204,6 +205,7 @@ int main(int numArguments, char* pszArgs[]) {
|
||||
std::cout << "Level has been generated in " << getTimeS() - startTime << std::endl;
|
||||
((MAIN_CLASS*)g_app)->level->saveLevelData();
|
||||
std::cout << "Level has been saved!" << std::endl;
|
||||
PluginsManager::get().emit("ServerLoaded");
|
||||
|
||||
while(!app->wantToQuit()) {
|
||||
app->update();
|
||||
@@ -238,6 +240,7 @@ int main(int numArguments, char* pszArgs[]) {
|
||||
delete app;
|
||||
appContext.platform->finish();
|
||||
delete appContext.platform;
|
||||
PluginsManager::get().emit("ServerShutdown");
|
||||
|
||||
std::cout << "Quit correctly" << std::endl;
|
||||
return g_exitCode;
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
#endif
|
||||
#include "../server/ServerPlayer.h"
|
||||
#include "../world/entity/item/FallingTile.h"
|
||||
#include <plugins/LuaPlayer.hpp>
|
||||
|
||||
#define TIMES(x) for(int itc ## __LINE__ = 0; itc ## __LINE__ < x; ++ itc ## __LINE__)
|
||||
|
||||
@@ -163,12 +164,12 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, ChatPack
|
||||
|
||||
if (packet->message[0] == '/') {
|
||||
// This is a command
|
||||
|
||||
ChatPacket resp(minecraft->commandManager().execute(*minecraft, *player, Util::stringTrim(packet->message.substr(1))));
|
||||
return sendPrivate(resp, source);
|
||||
}
|
||||
|
||||
displayGameMessage("<" + player->name + "> " + packet->message);
|
||||
PluginsManager::get().emit("Message", LuaPlayer(source), packet->message);
|
||||
}
|
||||
|
||||
void ServerSideNetworkHandler::onNewClient(const RakNet::RakNetGUID& clientGuid)
|
||||
@@ -193,6 +194,7 @@ void ServerSideNetworkHandler::onDisconnect(const RakNet::RakNetGUID& guid)
|
||||
std::string message = player->name;
|
||||
message += " disconnected from the game";
|
||||
displayGameMessage(message);
|
||||
PluginsManager::get().emit("PlayerDisconnect", LuaPlayer(guid));
|
||||
|
||||
//RemoveEntityPacket packet(player->entityId);
|
||||
//raknetInstance->send(packet);
|
||||
@@ -226,7 +228,6 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, LoginPac
|
||||
std::string nicknameLower = packet->clientName.C_String();
|
||||
std::transform(nicknameLower.begin(), nicknameLower.end(), nicknameLower.begin(), ::tolower);
|
||||
|
||||
printf("%s lower \n", nicknameLower.c_str());
|
||||
for (int i = 0; i < level->players.size(); i++) {
|
||||
ServerPlayer* player = (ServerPlayer*) level->players.at(i);
|
||||
|
||||
@@ -306,8 +307,6 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, ReadyPac
|
||||
|
||||
if (packet->type == ReadyPacket::READY_REQUESTEDCHUNKS)
|
||||
onReady_RequestedChunks(source);
|
||||
|
||||
LOGI("Ready player two ready ready player two!!\n ");
|
||||
}
|
||||
|
||||
void ServerSideNetworkHandler::onReady_ClientGeneration(const RakNet::RakNetGUID& source)
|
||||
@@ -352,6 +351,7 @@ void ServerSideNetworkHandler::onReady_ClientGeneration(const RakNet::RakNetGUID
|
||||
#else
|
||||
LOGW("%s joined the game\n", newPlayer->name.c_str());
|
||||
#endif
|
||||
PluginsManager::get().emit("PlayerJoin", LuaPlayer(source));
|
||||
|
||||
// Send all Entities to the new player
|
||||
for (unsigned int i = 0; i < level->entities.size(); ++i) {
|
||||
@@ -461,7 +461,7 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, MovePlay
|
||||
}
|
||||
}
|
||||
|
||||
void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, RemoveBlockPacket* packet){
|
||||
void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, RemoveBlockPacket* packet) {
|
||||
if (!level) return;
|
||||
|
||||
Player* player = getPlayer(source);
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
Player* popPendingPlayer(const RakNet::RakNetGUID& source);
|
||||
|
||||
void displayGameMessage(const std::string& message);
|
||||
private:
|
||||
|
||||
/**
|
||||
* @brief Send packet to all players
|
||||
*/
|
||||
@@ -78,6 +78,8 @@ private:
|
||||
void sendPrivate(Packet& packet, const RakNet::RakNetGUID& source);
|
||||
|
||||
Player* getPlayer(const RakNet::RakNetGUID& source);
|
||||
|
||||
private:
|
||||
|
||||
Minecraft* minecraft;
|
||||
Level* level;
|
||||
|
||||
54
src/plugins/LuaPlayer.hpp
Normal file
54
src/plugins/LuaPlayer.hpp
Normal file
@@ -0,0 +1,54 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <raknet/RakNetTypes.h>
|
||||
#include <plugins/PluginsManager.hpp>
|
||||
#include <network/ServerSideNetworkHandler.h>
|
||||
#include <world/entity/player/Player.h>
|
||||
#include <client/Minecraft.h>
|
||||
|
||||
class LuaPlayer {
|
||||
public:
|
||||
LuaPlayer(const RakNet::RakNetGUID source) : m_source(source) {}
|
||||
|
||||
std::string getNickname() {
|
||||
auto mc = PluginsManager::get().getMinecraft();
|
||||
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) mc->netCallback;
|
||||
|
||||
auto plr = ss->getPlayer(m_source);
|
||||
if (plr != nullptr) return plr->name;
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
float getX() {
|
||||
auto mc = PluginsManager::get().getMinecraft();
|
||||
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) mc->netCallback;
|
||||
|
||||
auto plr = ss->getPlayer(m_source);
|
||||
if (plr != nullptr) return plr->x;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
float getY() {
|
||||
auto mc = PluginsManager::get().getMinecraft();
|
||||
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) mc->netCallback;
|
||||
|
||||
auto plr = ss->getPlayer(m_source);
|
||||
if (plr != nullptr) return plr->y;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
float getZ() {
|
||||
auto mc = PluginsManager::get().getMinecraft();
|
||||
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) mc->netCallback;
|
||||
|
||||
auto plr = ss->getPlayer(m_source);
|
||||
if (plr != nullptr) return plr->z;
|
||||
|
||||
return 0;
|
||||
}
|
||||
private:
|
||||
const RakNet::RakNetGUID m_source;
|
||||
};
|
||||
11
src/plugins/LuaServer.cpp
Normal file
11
src/plugins/LuaServer.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <plugins/LuaServer.hpp>
|
||||
#include <plugins/PluginsManager.hpp>
|
||||
#include <network/ServerSideNetworkHandler.h>
|
||||
#include <client/Minecraft.h>
|
||||
|
||||
void LuaServer::sendServerMessage(std::string msg) {
|
||||
auto mc = PluginsManager::get().getMinecraft();
|
||||
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) mc->netCallback;
|
||||
|
||||
ss->displayGameMessage(msg);
|
||||
}
|
||||
7
src/plugins/LuaServer.hpp
Normal file
7
src/plugins/LuaServer.hpp
Normal file
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
class LuaServer {
|
||||
public:
|
||||
void sendServerMessage(std::string msg);
|
||||
};
|
||||
48
src/plugins/PluginsManager.cpp
Normal file
48
src/plugins/PluginsManager.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#include <plugins/PluginsManager.hpp>
|
||||
#include <plugins/LuaPlayer.hpp>
|
||||
#include <plugins/LuaServer.hpp>
|
||||
|
||||
#include <client/Minecraft.h>
|
||||
#include <filesystem>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
void PluginsManager::init(Minecraft& minecraft) {
|
||||
m_lua.open_libraries(sol::lib::base, sol::lib::package, sol::lib::string, sol::lib::math, sol::lib::table);
|
||||
registerTypes();
|
||||
|
||||
m_minecraft = &minecraft;
|
||||
}
|
||||
|
||||
void PluginsManager::registerTypes() {
|
||||
// @note you cant just do that, because lua doesnt have access to the class in this case
|
||||
// m_lua.set_function("subscribe", &PluginsManager::subscribe);
|
||||
|
||||
m_lua.set_function("subscribe", [this](std::string event, sol::protected_function func) {
|
||||
// @note: why the .at() not working?
|
||||
m_callbacks[event].push_back(func);
|
||||
});
|
||||
|
||||
m_lua.new_usertype<LuaServer>(
|
||||
"Server",
|
||||
"sendMessage", &LuaServer::sendServerMessage
|
||||
);
|
||||
|
||||
m_lua.new_usertype<LuaPlayer>(
|
||||
"Player",
|
||||
"getNickname", &LuaPlayer::getNickname,
|
||||
"getX", &LuaPlayer::getX,
|
||||
"getY", &LuaPlayer::getY,
|
||||
"getZ", &LuaPlayer::getZ
|
||||
);
|
||||
|
||||
m_lua["Server"] = &m_srv;
|
||||
}
|
||||
|
||||
void PluginsManager::loadPlugins() {
|
||||
std::string path = "plugins/";
|
||||
|
||||
for (const auto & entry : fs::directory_iterator(path)) {
|
||||
m_lua.script_file(entry.path().string());
|
||||
}
|
||||
}
|
||||
50
src/plugins/PluginsManager.hpp
Normal file
50
src/plugins/PluginsManager.hpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#pragma once
|
||||
#include <unordered_map>
|
||||
#include <sol/sol.hpp>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <plugins/LuaServer.hpp>
|
||||
|
||||
class Minecraft;
|
||||
|
||||
class PluginsManager {
|
||||
public:
|
||||
static inline PluginsManager& get() {
|
||||
static PluginsManager inst;
|
||||
return inst;
|
||||
}
|
||||
|
||||
void init(Minecraft& minecraft);
|
||||
|
||||
void registerTypes();
|
||||
|
||||
void loadPlugins();
|
||||
|
||||
// @ai @note maybe we should rewrite it...
|
||||
// problem that i dont know how to pass args in sol::function dynamically
|
||||
// so i used ai
|
||||
// sry :(
|
||||
template<typename... Args>
|
||||
void emit(std::string event, Args&&... args) {
|
||||
auto it = m_callbacks.find(event);
|
||||
|
||||
if (it == m_callbacks.end()) return;
|
||||
|
||||
for (auto& callback : it->second) {
|
||||
sol::protected_function_result result = callback(std::forward<Args>(args)...);
|
||||
|
||||
if (!result.valid()) {
|
||||
sol::error err = result;
|
||||
std::cout << err.what() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Minecraft* getMinecraft() { return m_minecraft; }
|
||||
private:
|
||||
std::unordered_map<std::string, std::vector<sol::function>> m_callbacks;
|
||||
|
||||
LuaServer m_srv;
|
||||
sol::state m_lua;
|
||||
Minecraft* m_minecraft;
|
||||
};
|
||||
@@ -142,8 +142,8 @@ void seedMT( unsigned int seed, unsigned int *state, unsigned int *&next, int &l
|
||||
// so-- that's why the only change I made is to restrict to odd seeds.
|
||||
//
|
||||
|
||||
register unsigned int x = ( seed | 1U ) & 0xFFFFFFFFU, *s = state;
|
||||
register int j;
|
||||
unsigned int x = ( seed | 1U ) & 0xFFFFFFFFU, *s = state;
|
||||
int j;
|
||||
|
||||
for ( left = 0, *s++ = x, j = N; --j;
|
||||
*s++ = ( x *= 69069U ) & 0xFFFFFFFFU )
|
||||
@@ -154,8 +154,8 @@ void seedMT( unsigned int seed, unsigned int *state, unsigned int *&next, int &l
|
||||
|
||||
unsigned int reloadMT( unsigned int *state, unsigned int *&next, int &left )
|
||||
{
|
||||
register unsigned int * p0 = state, *p2 = state + 2, *pM = state + M, s0, s1;
|
||||
register int j;
|
||||
unsigned int * p0 = state, *p2 = state + 2, *pM = state + M, s0, s1;
|
||||
int j;
|
||||
|
||||
if ( left < -1 )
|
||||
seedMT( 4357U );
|
||||
|
||||
Reference in New Issue
Block a user