Compare commits
39 Commits
plugins-su
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| a489435cc5 | |||
| 6767011d50 | |||
| db4683f62a | |||
| 61ff4835ea | |||
| 1f252ac4b3 | |||
| 7104ba93ae | |||
| 5ef00eee9f | |||
| 9a743b9aea | |||
| d7a51b09f1 | |||
| 6452eacb34 | |||
| 47cab7d66b | |||
| 09cc2ceee4 | |||
| 7620d49489 | |||
| 381ef354c6 | |||
| 8be6e381d8 | |||
| 3ab30eefa4 | |||
| 325ab94a64 | |||
| 9434a48ae7 | |||
| 79be815827 | |||
| c616546e1e | |||
| 92f972d320 | |||
| 980fc2ccfb | |||
| 3b82c519d0 | |||
| 002bb40aae | |||
| 6f4a07a306 | |||
| d5a3871f56 | |||
| 0c32f620af | |||
| 93bf97a15e | |||
| 0ee809daf1 | |||
| a048a51300 | |||
| 365d8a10da | |||
| 3940c9ce1b | |||
| 156849eeb6 | |||
| 6a8b192024 | |||
| ce8ca15c56 | |||
| b3561e773d | |||
| 162ec7adfa | |||
| 4cfaa43d77 | |||
|
|
f1e8932fbd |
@@ -3,9 +3,10 @@ project(MinecraftPE)
|
|||||||
|
|
||||||
include(cmake/CPM.cmake)
|
include(cmake/CPM.cmake)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
||||||
set(CMAKE_POLICY_VERSION_MINIMUM 3.10)
|
set(CMAKE_POLICY_VERSION_MINIMUM 3.10)
|
||||||
|
|
||||||
include(cmake/EnumOption.cmake)
|
include(cmake/EnumOption.cmake)
|
||||||
|
|
||||||
if(EMSCRIPTEN)
|
if(EMSCRIPTEN)
|
||||||
@@ -15,7 +16,9 @@ endif()
|
|||||||
|
|
||||||
enum_option(PLATFORM "Desktop;Web" "Platform to build for.")
|
enum_option(PLATFORM "Desktop;Web" "Platform to build for.")
|
||||||
|
|
||||||
find_package(Threads REQUIRED)
|
if(NOT EMSCRIPTEN)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
endif()
|
||||||
find_package(OpenSSL)
|
find_package(OpenSSL)
|
||||||
|
|
||||||
if (${PLATFORM} STREQUAL "Desktop")
|
if (${PLATFORM} STREQUAL "Desktop")
|
||||||
@@ -33,11 +36,9 @@ if (${PLATFORM} STREQUAL "Desktop")
|
|||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
include_directories(misc/windows)
|
include_directories(misc/windows)
|
||||||
set(EXTRA_LIBS ws2_32 winhttp)
|
set(EXTRA_LIBS ws2_32 winhttp)
|
||||||
add_definitions(-DLUA_DL_DLL=1)
|
|
||||||
elseif(UNIX)
|
elseif(UNIX)
|
||||||
find_library(pthread NAMES pthread)
|
find_library(pthread NAMES pthread)
|
||||||
set(EXTRA_LIBS pthread m)
|
set(EXTRA_LIBS pthread m)
|
||||||
add_definitions(-DLUA_USE_DLOPEN=1)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
elseif (${PLATFORM} STREQUAL "Web")
|
elseif (${PLATFORM} STREQUAL "Web")
|
||||||
@@ -96,46 +97,6 @@ else()
|
|||||||
"GLFW_BUILD_TESTS OFF"
|
"GLFW_BUILD_TESTS OFF"
|
||||||
"GLFW_BUILD_DOCS 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()
|
endif()
|
||||||
|
|
||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
@@ -256,8 +217,6 @@ file(GLOB SERVER_SOURCES
|
|||||||
|
|
||||||
"src/world/phys/HitResult.cpp"
|
"src/world/phys/HitResult.cpp"
|
||||||
"src/commands/*.cpp"
|
"src/commands/*.cpp"
|
||||||
|
|
||||||
"src/plugins/*.cpp"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
file(GLOB CLIENT_SOURCES
|
file(GLOB CLIENT_SOURCES
|
||||||
@@ -343,8 +302,6 @@ file(GLOB CLIENT_SOURCES
|
|||||||
"src/main.cpp"
|
"src/main.cpp"
|
||||||
|
|
||||||
"src/commands/*.cpp"
|
"src/commands/*.cpp"
|
||||||
"src/plugins/*.cpp"
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (${PLATFORM} STREQUAL "Desktop")
|
if (${PLATFORM} STREQUAL "Desktop")
|
||||||
@@ -353,20 +310,21 @@ endif()
|
|||||||
|
|
||||||
# Server
|
# Server
|
||||||
add_executable("${PROJECT_NAME}-server" ${SERVER_SOURCES})
|
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_compile_definitions("${PROJECT_NAME}-server" PUBLIC "STANDALONE_SERVER" "SERVER_PROFILER")
|
||||||
|
|
||||||
target_include_directories("${PROJECT_NAME}-server" PUBLIC
|
target_include_directories("${PROJECT_NAME}-server" PUBLIC
|
||||||
"${CMAKE_SOURCE_DIR}/src/"
|
"${CMAKE_SOURCE_DIR}/src/"
|
||||||
"${lua_SOURCE_DIR}/"
|
|
||||||
|
|
||||||
"project/lib_projects/raknet/jni/RaknetSources"
|
"project/lib_projects/raknet/jni/RaknetSources"
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries("${PROJECT_NAME}-server" ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_LIBS} lua sol2::sol2)
|
target_link_libraries("${PROJECT_NAME}-server" ${CMAKE_THREAD_LIBS_INIT} ${EXTRA_LIBS})
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} ${CLIENT_SOURCES})
|
add_executable(${PROJECT_NAME} ${CLIENT_SOURCES})
|
||||||
set_target_properties(${PROJECT_NAME} PROPERTIES ENABLE_EXPORTS TRUE)
|
|
||||||
|
if(WIN32)
|
||||||
|
target_sources(${PROJECT_NAME} PRIVATE data/images/pe.rc)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_compile_definitions(${PROJECT_NAME} PUBLIC ${PLATFORM_CPP})
|
target_compile_definitions(${PROJECT_NAME} PUBLIC ${PLATFORM_CPP})
|
||||||
|
|
||||||
@@ -376,8 +334,6 @@ target_include_directories(${PROJECT_NAME} PUBLIC
|
|||||||
"${openal_SOURCE_DIR}/include"
|
"${openal_SOURCE_DIR}/include"
|
||||||
"${glfw_SOURCE_DIR}/include"
|
"${glfw_SOURCE_DIR}/include"
|
||||||
"lib/include"
|
"lib/include"
|
||||||
"${lua_SOURCE_DIR}/"
|
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(${PLATFORM} MATCHES "Web")
|
if(${PLATFORM} MATCHES "Web")
|
||||||
@@ -425,7 +381,7 @@ endif()
|
|||||||
|
|
||||||
# Client
|
# Client
|
||||||
target_compile_definitions(${PROJECT_NAME} PUBLIC "OPENGL_ES" "NO_EGL" ${PLATFORM})
|
target_compile_definitions(${PROJECT_NAME} PUBLIC "OPENGL_ES" "NO_EGL" ${PLATFORM})
|
||||||
target_link_libraries(${PROJECT_NAME} zlib ${PNG_LIB} OpenAL::OpenAL glfw ${EXTRA_LIBS} lua sol2::sol2)
|
target_link_libraries(${PROJECT_NAME} zlib ${PNG_LIB} OpenAL::OpenAL glfw ${EXTRA_LIBS})
|
||||||
|
|
||||||
if (OpenSSL_FOUND)
|
if (OpenSSL_FOUND)
|
||||||
target_link_libraries(${PROJECT_NAME} OpenSSL::SSL OpenSSL::Crypto)
|
target_link_libraries(${PROJECT_NAME} OpenSSL::SSL OpenSSL::Crypto)
|
||||||
|
|||||||
44
README.md
44
README.md
@@ -1,6 +1,6 @@
|
|||||||
# MinecraftPE
|
# MinecraftPE
|
||||||
> [!Warning]
|
> [!Warning]
|
||||||
> 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).
|
> [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).
|
||||||
|
|
||||||
> [!Important]
|
> [!Important]
|
||||||
> We have a discord server, where you can report bugs or send feedback https://discord.gg/c58YesBxve
|
> We have a discord server, where you can report bugs or send feedback https://discord.gg/c58YesBxve
|
||||||
@@ -9,23 +9,20 @@ 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.
|
This project aims to preserve and improve this early version of Minecraft PE.
|
||||||
|
|
||||||
# TODO / Roadmap
|
# Features
|
||||||
- [x] Add platform GLFW
|
- Support for modern IOS and Android, Linux, Web
|
||||||
- [x] Compile for Linux
|
- Improved Dedicated Server (Windows build, anticheat, commands, etc)
|
||||||
- [x] Compile for android aarch64
|
- Features from Beta version of Minecraft (Grass tint, Beta sky, Smooth lighting, etc) and other tweaks
|
||||||
- [x] Touch control improvements
|
|
||||||
- [ ] Screen fixes
|
# Screenshots
|
||||||
- [ ] Rewrite platform logic
|
<p align="center">
|
||||||
- [x] Fix sound
|
|
||||||
- [x] Do a server connection GUI
|
<img width="49%" alt="menu" src="https://sffempire.ru/mcpe-screenshots/menu.png" />
|
||||||
- [ ] Controller support
|
<img width="49%" alt="settings" src="https://sffempire.ru/mcpe-screenshots/settings.png" />
|
||||||
- [x] Minecraft server hosting
|
<img width="49%" alt="worlds" src="https://sffempire.ru/mcpe-screenshots/worlds.png" />
|
||||||
- [x] Screen fixess
|
<img width="49%" alt="gameplay" src="https://sffempire.ru/mcpe-screenshots/gameplay.png" />
|
||||||
- [x] Fix fog
|
|
||||||
- [x] Add sprinting
|
</p>
|
||||||
- [x] Chat (semi working) and commands
|
|
||||||
- [x] Implementing options
|
|
||||||
- [x] Better F3
|
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
|
|
||||||
@@ -79,8 +76,14 @@ cmake --build .
|
|||||||
```
|
```
|
||||||
C:\android-ndk-r14b
|
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):
|
||||||
|
|
||||||
3. Run the build script:
|
```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:
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
# Full build (NDK + Java + APK + install)
|
# Full build (NDK + Java + APK + install)
|
||||||
@@ -154,7 +157,6 @@ cmake --build .
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
35.0.0
|
35.0.0
|
||||||
33.0.2
|
|
||||||
```
|
```
|
||||||
|
|
||||||
6. Download **Android NDK r14b**:
|
6. Download **Android NDK r14b**:
|
||||||
@@ -200,7 +202,7 @@ cmake --build .
|
|||||||
```
|
```
|
||||||
## iOS
|
## iOS
|
||||||
### Xcode
|
### 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.
|
> 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
|
### 1. Clone
|
||||||
|
|||||||
BIN
data/images/pe.ico
Normal file
BIN
data/images/pe.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 63 KiB |
1
data/images/pe.rc
Normal file
1
data/images/pe.rc
Normal file
@@ -0,0 +1 @@
|
|||||||
|
IDI_ICON1 ICON "pe.ico"
|
||||||
@@ -1020,5 +1020,5 @@ desc.netherbrickitem=Used to form blocks of Nether bricks.
|
|||||||
desc.netherquartz=Quartz from the Nether, used to create Blocks of Quartz.
|
desc.netherquartz=Quartz from the Nether, used to create Blocks of Quartz.
|
||||||
desc.quartzblock=Decorative block, used to create other kinds of Quartz blocks.
|
desc.quartzblock=Decorative block, used to create other kinds of Quartz blocks.
|
||||||
desc.stonecutter=For crafting stoneblocks.
|
desc.stonecutter=For crafting stoneblocks.
|
||||||
desc.seedsmelon=Allows for more melons.
|
desc.seeds_melon=Allows for more melons.
|
||||||
desc.tile.melon=Can be cut up and eaten.
|
desc.tile.melon=Can be cut up and eaten.
|
||||||
|
|||||||
@@ -965,5 +965,5 @@ desc.netherbrickitem=Used to form blocks of Nether bricks.
|
|||||||
desc.netherquartz=Quartz from the Nether, used to create Blocks of Quartz.
|
desc.netherquartz=Quartz from the Nether, used to create Blocks of Quartz.
|
||||||
desc.quartzblock=Decorative block, used to create other kinds of Quartz blocks.
|
desc.quartzblock=Decorative block, used to create other kinds of Quartz blocks.
|
||||||
desc.stonecutter=For crafting stoneblocks.
|
desc.stonecutter=For crafting stoneblocks.
|
||||||
desc.seedsmelon=Allows for more melons.
|
desc.seeds_melon=Allows for more melons.
|
||||||
desc.tile.melon=Can be cut up and eaten.
|
desc.tile.melon=Can be cut up and eaten.
|
||||||
|
|||||||
@@ -47,6 +47,8 @@
|
|||||||
9D293CE816071C08000305C8 /* CreateNewWorld_iphone.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9D293CE616071C08000305C8 /* CreateNewWorld_iphone.xib */; };
|
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 */; };
|
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 */; };
|
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 */; };
|
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 */; };
|
D51DC73614581D4E00E3D761 /* itemframe.png in Resources */ = {isa = PBXBuildFile; fileRef = D51DC73514581D4E00E3D761 /* itemframe.png */; };
|
||||||
D51DC74314592B8B00E3D761 /* PVRTexture.m in Sources */ = {isa = PBXBuildFile; fileRef = D51DC74214592B8A00E3D761 /* PVRTexture.m */; };
|
D51DC74314592B8B00E3D761 /* PVRTexture.m in Sources */ = {isa = PBXBuildFile; fileRef = D51DC74214592B8A00E3D761 /* PVRTexture.m */; };
|
||||||
@@ -1179,8 +1181,19 @@
|
|||||||
F99F0FAD2F8436CE00F2B29A /* FoliageColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99F0FAB2F8436CE00F2B29A /* FoliageColor.cpp */; };
|
F99F0FAD2F8436CE00F2B29A /* FoliageColor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99F0FAB2F8436CE00F2B29A /* FoliageColor.cpp */; };
|
||||||
F99F0FAF2F8436EB00F2B29A /* Color.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99F0FAE2F8436EB00F2B29A /* Color.cpp */; };
|
F99F0FAF2F8436EB00F2B29A /* Color.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99F0FAE2F8436EB00F2B29A /* Color.cpp */; };
|
||||||
F99F0FB02F8436EB00F2B29A /* Color.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99F0FAE2F8436EB00F2B29A /* Color.cpp */; };
|
F99F0FB02F8436EB00F2B29A /* Color.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F99F0FAE2F8436EB00F2B29A /* Color.cpp */; };
|
||||||
BEEF202614CFF670005F0002 /* Lighting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEEF202614CFF670005F0001 /* Lighting.cpp */; };
|
F9E5A772300E7A8700164066 /* LevelConstants.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F9E5A771300E7A8700164066 /* LevelConstants.cpp */; };
|
||||||
BEEF202614CFF670005F0003 /* Lighting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BEEF202614CFF670005F0001 /* Lighting.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 */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
@@ -1248,6 +1261,7 @@
|
|||||||
9D293CE616071C08000305C8 /* CreateNewWorld_iphone.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = CreateNewWorld_iphone.xib; path = minecraftpe/dialogs/CreateNewWorld_iphone.xib; 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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
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>"; };
|
D51DC74114592B8A00E3D761 /* PVRTexture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PVRTexture.h; sourceTree = "<group>"; };
|
||||||
@@ -2468,7 +2482,19 @@
|
|||||||
F99F0FA82F84369F00F2B29A /* GrassColor.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = GrassColor.cpp; sourceTree = "<group>"; };
|
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>"; };
|
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>"; };
|
F99F0FAE2F8436EB00F2B29A /* Color.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Color.cpp; sourceTree = "<group>"; };
|
||||||
BEEF202614CFF670005F0001 /* Lighting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Lighting.cpp; path = Lighting.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>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@@ -4319,6 +4345,19 @@
|
|||||||
D5CF9C37144C225000E4244F = {
|
D5CF9C37144C225000E4244F = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
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 */,
|
F99D344D2F7372A100DC153E /* Launch Screen.storyboard */,
|
||||||
D5E1BA9A1451C8A0007DCC4F /* Default@2x.png */,
|
D5E1BA9A1451C8A0007DCC4F /* Default@2x.png */,
|
||||||
9D959AFF16036BEE00E23A6F /* Default-568h@2x.png */,
|
9D959AFF16036BEE00E23A6F /* Default-568h@2x.png */,
|
||||||
@@ -5451,6 +5490,19 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
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 */,
|
F912B8CF2F6C3D5200BC60DF /* TextBox.h in Sources */,
|
||||||
D5CF9C57144C225000E4244F /* main.mm in Sources */,
|
D5CF9C57144C225000E4244F /* main.mm in Sources */,
|
||||||
D5CF9C5B144C225000E4244F /* minecraftpeAppDelegate.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.
|
// so-- that's why the only change I made is to restrict to odd seeds.
|
||||||
//
|
//
|
||||||
|
|
||||||
unsigned int x = ( seed | 1U ) & 0xFFFFFFFFU, *s = state;
|
register unsigned int x = ( seed | 1U ) & 0xFFFFFFFFU, *s = state;
|
||||||
int j;
|
register int j;
|
||||||
|
|
||||||
for ( left = 0, *s++ = x, j = N; --j;
|
for ( left = 0, *s++ = x, j = N; --j;
|
||||||
*s++ = ( x *= 69069U ) & 0xFFFFFFFFU )
|
*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 )
|
unsigned int reloadMT( unsigned int *state, unsigned int *&next, int &left )
|
||||||
{
|
{
|
||||||
unsigned int * p0 = state, *p2 = state + 2, *pM = state + M, s0, s1;
|
register unsigned int * p0 = state, *p2 = state + 2, *pM = state + M, s0, s1;
|
||||||
int j;
|
register int j;
|
||||||
|
|
||||||
if ( left < -1 )
|
if ( left < -1 )
|
||||||
seedMT( 4357U );
|
seedMT( 4357U );
|
||||||
|
|||||||
@@ -4,12 +4,11 @@ namespace Common {
|
|||||||
|
|
||||||
std::string getGameVersionString(const std::string& versionSuffix /* = "" */)
|
std::string getGameVersionString(const std::string& versionSuffix /* = "" */)
|
||||||
{
|
{
|
||||||
std::string result = std::string("v0.6.1") + versionSuffix;
|
std::string result = std::string("v0.1.0 (forked from v0.6.1 alpha)") + versionSuffix;
|
||||||
// append 64-bit port marker only on Android 64‑bit targets
|
// append 64-bit port marker only on Android 64‑bit targets
|
||||||
#if defined(ANDROID) && (defined(__aarch64__) || defined(__x86_64__))
|
#if defined(ANDROID) && (defined(__aarch64__) || defined(__x86_64__))
|
||||||
result += " (64-bit port)";
|
result += " (64-bit)";
|
||||||
#endif
|
#endif
|
||||||
result += " alpha";
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -287,9 +287,13 @@ void Minecraft::setLevel(Level* level, const std::string& message /* ="" */, Loc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this->level = level;
|
this->level = level;
|
||||||
|
// So uhhh
|
||||||
|
std::string op = options.getStringValue(OPTIONS_USERNAME);
|
||||||
|
std::transform(op.begin(), op.end(), op.begin(), ::tolower);
|
||||||
|
|
||||||
|
level->ops.emplace(op);
|
||||||
_hasSignaledGeneratingLevelFinished = false;
|
_hasSignaledGeneratingLevelFinished = false;
|
||||||
#ifdef STANDALONE_SERVER
|
#if defined(STANDALONE_SERVER) || defined(PLATFORM_WEB)
|
||||||
const bool threadedLevelCreation = false;
|
const bool threadedLevelCreation = false;
|
||||||
#else
|
#else
|
||||||
const bool threadedLevelCreation = true;
|
const bool threadedLevelCreation = true;
|
||||||
@@ -512,7 +516,7 @@ void Minecraft::tick(int nTick, int maxTick) {
|
|||||||
if (missTime > 0) missTime--;
|
if (missTime > 0) missTime--;
|
||||||
#ifndef STANDALONE_SERVER
|
#ifndef STANDALONE_SERVER
|
||||||
if (!screen && player) {
|
if (!screen && player) {
|
||||||
if (player->health <= 0) {
|
if (player->hasDied()) {
|
||||||
setScreen(new DeathScreen());
|
setScreen(new DeathScreen());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1210,8 +1214,6 @@ void Minecraft::init()
|
|||||||
checkGlError("Init complete");
|
checkGlError("Init complete");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PluginsManager::get().init(*this);
|
|
||||||
|
|
||||||
options.load();
|
options.load();
|
||||||
|
|
||||||
setIsCreativeMode(false); // false means it's Survival Mode
|
setIsCreativeMode(false); // false means it's Survival Mode
|
||||||
|
|||||||
@@ -3,8 +3,6 @@
|
|||||||
|
|
||||||
#include "Options.h"
|
#include "Options.h"
|
||||||
#include "commands/CommandManager.hpp"
|
#include "commands/CommandManager.hpp"
|
||||||
#include <plugins/PluginsManager.hpp>
|
|
||||||
|
|
||||||
#ifndef STANDALONE_SERVER
|
#ifndef STANDALONE_SERVER
|
||||||
#include "MouseHandler.h"
|
#include "MouseHandler.h"
|
||||||
#include "gui/Gui.h"
|
#include "gui/Gui.h"
|
||||||
|
|||||||
@@ -65,17 +65,13 @@ OptionBool useVignette("useVignette", true);
|
|||||||
OptionBool useTouchscreen("useTouchscreen", true);
|
OptionBool useTouchscreen("useTouchscreen", true);
|
||||||
|
|
||||||
OptionBool serverVisible("servervisible", true);
|
OptionBool serverVisible("servervisible", true);
|
||||||
|
OptionBool foliageTint("foliagetint", false);
|
||||||
OptionBool foliageTint("foliagetint", true);
|
|
||||||
|
|
||||||
OptionInt fogType("fogType", 0, 0, 2);
|
OptionInt fogType("fogType", 0, 0, 2);
|
||||||
|
|
||||||
OptionBool javaHud("javaHud", false);
|
OptionBool javaHud("javaHud", false);
|
||||||
|
|
||||||
OptionBool betaSky("betaSky", false);
|
OptionBool betaSky("betaSky", false);
|
||||||
|
|
||||||
OptionBool tintedSide("tintedSide", false);
|
OptionBool tintedSide("tintedSide", false);
|
||||||
|
|
||||||
OptionBool blockOutline("blockOutline", false);
|
OptionBool blockOutline("blockOutline", false);
|
||||||
|
|
||||||
OptionBool restoredAnims("restoredAnims", true);
|
OptionBool restoredAnims("restoredAnims", true);
|
||||||
@@ -200,16 +196,13 @@ void Options::initTable() {
|
|||||||
m_options[OPTIONS_ALLOW_SPRINT] = &allowSprint;
|
m_options[OPTIONS_ALLOW_SPRINT] = &allowSprint;
|
||||||
m_options[OPTIONS_RPI_CURSOR] = &rpiCursor;
|
m_options[OPTIONS_RPI_CURSOR] = &rpiCursor;
|
||||||
m_options[OPTIONS_FOLIAGE_TINT] = &foliageTint;
|
m_options[OPTIONS_FOLIAGE_TINT] = &foliageTint;
|
||||||
|
|
||||||
// more options yay
|
// more options yay
|
||||||
m_options[OPTIONS_FOG_TYPE] = &fogType;
|
m_options[OPTIONS_FOG_TYPE] = &fogType;
|
||||||
|
|
||||||
m_options[OPTIONS_DEBUG_STYLE] = &debugStyle;
|
m_options[OPTIONS_DEBUG_STYLE] = &debugStyle;
|
||||||
|
|
||||||
m_options[OPTIONS_BETA_SKY] = &betaSky;
|
m_options[OPTIONS_BETA_SKY] = &betaSky;
|
||||||
|
|
||||||
m_options[OPTIONS_TINTED_SIDE] = &tintedSide;
|
m_options[OPTIONS_TINTED_SIDE] = &tintedSide;
|
||||||
|
|
||||||
m_options[OPTIONS_JAVA_HUD] = &javaHud;
|
m_options[OPTIONS_JAVA_HUD] = &javaHud;
|
||||||
|
|
||||||
m_options[OPTIONS_AUTOJUMP] = &autoJump;
|
m_options[OPTIONS_AUTOJUMP] = &autoJump;
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ enum OptionId {
|
|||||||
|
|
||||||
OPTIONS_RPI_CURSOR,
|
OPTIONS_RPI_CURSOR,
|
||||||
OPTIONS_FOLIAGE_TINT,
|
OPTIONS_FOLIAGE_TINT,
|
||||||
OPTIONS_FOG_TYPE,
|
OPTIONS_FOG_TYPE,
|
||||||
OPTIONS_JAVA_HUD,
|
OPTIONS_JAVA_HUD,
|
||||||
OPTIONS_RESTORED_ANIMS,
|
OPTIONS_RESTORED_ANIMS,
|
||||||
OPTIONS_TINTED_SIDE,
|
OPTIONS_TINTED_SIDE,
|
||||||
|
|||||||
@@ -35,6 +35,17 @@ void GuiElementContainer::removeChild( GuiElement* element ) {
|
|||||||
children.erase(it);
|
children.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GuiElementContainer::containsPointInChildren(int x, int y) const {
|
||||||
|
for (auto it = children.begin(); it != children.end(); ++it) {
|
||||||
|
GuiElement* child = *it;
|
||||||
|
if (child == NULL || !child->visible) continue;
|
||||||
|
if (child->pointInside(x, y)) return true;
|
||||||
|
const GuiElementContainer* container = dynamic_cast<const GuiElementContainer*>(child);
|
||||||
|
if (container != NULL && container->containsPointInChildren(x, y)) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void GuiElementContainer::tick( Minecraft* minecraft ) {
|
void GuiElementContainer::tick( Minecraft* minecraft ) {
|
||||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
||||||
(*it)->tick(minecraft);
|
(*it)->tick(minecraft);
|
||||||
|
|||||||
@@ -5,16 +5,17 @@
|
|||||||
class Tesselator;
|
class Tesselator;
|
||||||
class Minecraft;
|
class Minecraft;
|
||||||
|
|
||||||
class GuiElementContainer : public GuiElement {
|
class GuiElementContainer : public GuiElement {
|
||||||
public:
|
public:
|
||||||
GuiElementContainer(bool active=false, bool visible=true, int x = 0, int y = 0, int width=24, int height=24);
|
GuiElementContainer(bool active=false, bool visible=true, int x = 0, int y = 0, int width=24, int height=24);
|
||||||
virtual ~GuiElementContainer();
|
virtual ~GuiElementContainer();
|
||||||
virtual void render(Minecraft* minecraft, int xm, int ym);
|
virtual void render(Minecraft* minecraft, int xm, int ym);
|
||||||
virtual void setupPositions();
|
virtual void setupPositions();
|
||||||
virtual void addChild(GuiElement* element);
|
virtual void addChild(GuiElement* element);
|
||||||
virtual void removeChild(GuiElement* element);
|
virtual void removeChild(GuiElement* element);
|
||||||
|
bool containsPointInChildren(int x, int y) const;
|
||||||
virtual void tick( Minecraft* minecraft );
|
|
||||||
|
virtual void tick( Minecraft* minecraft );
|
||||||
|
|
||||||
virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum );
|
virtual void mouseClicked( Minecraft* minecraft, int x, int y, int buttonNum );
|
||||||
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum );
|
virtual void mouseReleased( Minecraft* minecraft, int x, int y, int buttonNum );
|
||||||
|
|||||||
@@ -1,115 +1,219 @@
|
|||||||
#include "OptionsGroup.h"
|
#include "OptionsGroup.h"
|
||||||
#include "../../Minecraft.h"
|
#include "../../Minecraft.h"
|
||||||
#include "ImageButton.h"
|
#include "ImageButton.h"
|
||||||
#include "OptionsItem.h"
|
#include "OptionsItem.h"
|
||||||
#include "Slider.h"
|
#include "Slider.h"
|
||||||
#include "../../../locale/I18n.h"
|
#include "../../../locale/I18n.h"
|
||||||
#include "TextOption.h"
|
#include "TextOption.h"
|
||||||
#include "KeyOption.h"
|
#include "KeyOption.h"
|
||||||
|
#include <algorithm>
|
||||||
OptionsGroup::OptionsGroup( std::string labelID ) {
|
#include "../Gui.h"
|
||||||
label = I18n::get(labelID);
|
#include "../Screen.h"
|
||||||
}
|
#include "../../../platform/input/Mouse.h"
|
||||||
|
#include "../../../util/Mth.h"
|
||||||
void OptionsGroup::setupPositions() {
|
|
||||||
// First we write the header and then we add the items
|
OptionsGroup::OptionsGroup( std::string labelID ) {
|
||||||
int curY = y + 18;
|
label = I18n::get(labelID);
|
||||||
for(std::vector<GuiElement*>::iterator it = children.begin(); it != children.end(); ++it) {
|
}
|
||||||
(*it)->width = width - 5;
|
|
||||||
|
void OptionsGroup::setupPositions() {
|
||||||
(*it)->y = curY;
|
const int labelHeight = 18;
|
||||||
(*it)->x = x + 10;
|
const int bottomPadding = 36;
|
||||||
(*it)->setupPositions();
|
const float requestedScroll = scrollOffsetY;
|
||||||
curY += (*it)->height + 3;
|
const int scrollOffset = (int)requestedScroll;
|
||||||
}
|
int curY = y + labelHeight - scrollOffset;
|
||||||
height = curY;
|
const int contentStartY = y + labelHeight;
|
||||||
}
|
|
||||||
|
// First we write the header and then we add the items
|
||||||
void OptionsGroup::render( Minecraft* minecraft, int xm, int ym ) {
|
for(auto it = children.begin(); it != children.end(); ++it) {
|
||||||
float padX = 10.0f;
|
(*it)->width = width - 5;
|
||||||
float padY = 5.0f;
|
|
||||||
|
(*it)->y = curY;
|
||||||
minecraft->font->draw(label, (float)x + padX, (float)y + padY, 0xffffffff, false);
|
(*it)->x = x + 10;
|
||||||
|
(*it)->setupPositions();
|
||||||
super::render(minecraft, xm, ym);
|
curY += (*it)->height + 3;
|
||||||
}
|
}
|
||||||
|
curY += bottomPadding;
|
||||||
OptionsGroup& OptionsGroup::addOptionItem(OptionId optId, Minecraft* minecraft ) {
|
contentHeight = std::max(0, curY - contentStartY + scrollOffset);
|
||||||
auto option = minecraft->options.getOpt(optId);
|
maxScrollOffsetY = std::max(0, contentHeight - (height - labelHeight));
|
||||||
|
const float clampedScroll = Mth::clamp(requestedScroll, 0.0f, maxScrollOffsetY);
|
||||||
if (option == nullptr) return *this;
|
if (clampedScroll != requestedScroll) {
|
||||||
|
scrollOffsetY = clampedScroll;
|
||||||
// TODO: do a options key class to check it faster via dynamic_cast
|
setupPositions();
|
||||||
if (option->getStringId().find("options.key") != std::string::npos) createKey(optId, minecraft);
|
}
|
||||||
else if (dynamic_cast<OptionBool*>(option)) createToggle(optId, minecraft);
|
}
|
||||||
else if (dynamic_cast<OptionFloat*>(option)) createProgressSlider(optId, minecraft);
|
|
||||||
else if (dynamic_cast<OptionInt*>(option)) createStepSlider(optId, minecraft);
|
void OptionsGroup::render( Minecraft* minecraft, int xm, int ym ) {
|
||||||
else if (dynamic_cast<OptionString*>(option)) createTextbox(optId, minecraft);
|
float padX = 10.0f;
|
||||||
|
float padY = 5.0f;
|
||||||
return *this;
|
const int labelHeight = 18;
|
||||||
}
|
|
||||||
|
minecraft->font->draw(label, (float)x + padX, (float)y + padY, 0xffffffff, false);
|
||||||
// TODO: wrap this copypaste shit into templates
|
|
||||||
|
glEnable2(GL_SCISSOR_TEST);
|
||||||
void OptionsGroup::createToggle(OptionId optId, Minecraft* minecraft ) {
|
glScissor(
|
||||||
ImageDef def;
|
Gui::GuiScale * x,
|
||||||
|
minecraft->height - Gui::GuiScale * (y + height),
|
||||||
def.setSrc(IntRectangle(160, 206, 39, 20));
|
Gui::GuiScale * width,
|
||||||
def.name = "gui/touchgui.png";
|
Gui::GuiScale * (height - labelHeight)
|
||||||
def.width = 39 * 0.7f;
|
);
|
||||||
def.height = 20 * 0.7f;
|
|
||||||
|
super::render(minecraft, xm, ym);
|
||||||
OptionButton* element = new OptionButton(optId);
|
glDisable2(GL_SCISSOR_TEST);
|
||||||
element->setImageDef(def, true);
|
}
|
||||||
element->updateImage(&minecraft->options);
|
|
||||||
|
void OptionsGroup::tick(Minecraft* minecraft) {
|
||||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
int xm = Mouse::getX();
|
||||||
|
int ym = Mouse::getY();
|
||||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
if (minecraft->screen != NULL) {
|
||||||
|
minecraft->screen->toGUICoordinate(xm, ym);
|
||||||
addChild(item);
|
}
|
||||||
setupPositions();
|
|
||||||
}
|
bool leftDown = Mouse::isButtonDown(MouseAction::ACTION_LEFT);
|
||||||
|
|
||||||
void OptionsGroup::createProgressSlider(OptionId optId, Minecraft* minecraft ) {
|
if (trackingScrollGesture && leftDown) {
|
||||||
Slider* element = new SliderFloat(minecraft, optId);
|
int dy = ym - lastDragY;
|
||||||
element->width = 100;
|
int dx = xm - dragStartX;
|
||||||
element->height = 20;
|
if (!scrollingGesture) {
|
||||||
|
int totalDx = xm - dragStartX;
|
||||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
int totalDy = ym - dragStartY;
|
||||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
if (std::abs(totalDx) >= ScrollStartThreshold || std::abs(totalDy) >= ScrollStartThreshold) {
|
||||||
addChild(item);
|
if (std::abs(totalDy) >= std::abs(totalDx)) {
|
||||||
setupPositions();
|
scrollingGesture = true;
|
||||||
}
|
} else if (!touchDispatched) {
|
||||||
|
super::mouseClicked(minecraft, touchStartX, touchStartY, MouseAction::ACTION_LEFT);
|
||||||
void OptionsGroup::createStepSlider(OptionId optId, Minecraft* minecraft ) {
|
touchDispatched = true;
|
||||||
Slider* element = new SliderInt(minecraft, optId);
|
}
|
||||||
element->width = 100;
|
}
|
||||||
element->height = 20;
|
}
|
||||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
if (scrollingGesture && dy != 0) {
|
||||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
scrollByPixels((float)dy);
|
||||||
addChild(item);
|
}
|
||||||
setupPositions();
|
lastDragY = ym;
|
||||||
}
|
}
|
||||||
|
super::tick(minecraft);
|
||||||
void OptionsGroup::createTextbox(OptionId optId, Minecraft* minecraft) {
|
}
|
||||||
TextBox* element = new TextOption(minecraft, optId);
|
|
||||||
element->width = 100;
|
void OptionsGroup::mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum) {
|
||||||
element->height = 20;
|
trackingScrollGesture = false;
|
||||||
|
scrollingGesture = false;
|
||||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
touchDispatched = false;
|
||||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
|
||||||
addChild(item);
|
if (buttonNum == MouseAction::ACTION_LEFT && pointInside(x, y)) {
|
||||||
setupPositions();
|
trackingScrollGesture = true;
|
||||||
}
|
dragStartX = x;
|
||||||
|
dragStartY = y;
|
||||||
void OptionsGroup::createKey(OptionId optId, Minecraft* minecraft) {
|
lastDragY = y;
|
||||||
KeyOption* element = new KeyOption(minecraft, optId);
|
touchStartX = x;
|
||||||
element->width = 50;
|
touchStartY = y;
|
||||||
element->height = 20;
|
return;
|
||||||
|
}
|
||||||
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
|
||||||
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
super::mouseClicked(minecraft, x, y, buttonNum);
|
||||||
addChild(item);
|
}
|
||||||
setupPositions();
|
|
||||||
}
|
void OptionsGroup::mouseReleased(Minecraft* minecraft, int x, int y, int buttonNum) {
|
||||||
|
bool wasScrolling = scrollingGesture;
|
||||||
|
bool wasTracking = trackingScrollGesture;
|
||||||
|
trackingScrollGesture = false;
|
||||||
|
scrollingGesture = false;
|
||||||
|
if (buttonNum == MouseAction::ACTION_LEFT && wasTracking && !touchDispatched && pointInside(touchStartX, touchStartY)) {
|
||||||
|
super::mouseClicked(minecraft, touchStartX, touchStartY, buttonNum);
|
||||||
|
touchDispatched = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!wasScrolling) {
|
||||||
|
super::mouseReleased(minecraft, x, y, buttonNum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OptionsGroup::scrollByPixels(float deltaY) {
|
||||||
|
if (deltaY == 0.0f || maxScrollOffsetY <= 0.0f) return;
|
||||||
|
|
||||||
|
scrollOffsetY = Mth::clamp(scrollOffsetY - deltaY, 0.0f, maxScrollOffsetY);
|
||||||
|
setupPositions();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OptionsGroup::isScrollingGestureActive() const {
|
||||||
|
return trackingScrollGesture || scrollingGesture;
|
||||||
|
}
|
||||||
|
|
||||||
|
OptionsGroup& OptionsGroup::addOptionItem(OptionId optId, Minecraft* minecraft ) {
|
||||||
|
auto option = minecraft->options.getOpt(optId);
|
||||||
|
|
||||||
|
if (option == nullptr) return *this;
|
||||||
|
|
||||||
|
// TODO: do a options key class to check it faster via dynamic_cast
|
||||||
|
if (option->getStringId().find("options.key") != std::string::npos) createKey(optId, minecraft);
|
||||||
|
else if (dynamic_cast<OptionBool*>(option)) createToggle(optId, minecraft);
|
||||||
|
else if (dynamic_cast<OptionFloat*>(option)) createProgressSlider(optId, minecraft);
|
||||||
|
else if (dynamic_cast<OptionInt*>(option)) createStepSlider(optId, minecraft);
|
||||||
|
else if (dynamic_cast<OptionString*>(option)) createTextbox(optId, minecraft);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: wrap this copypaste shit into templates
|
||||||
|
|
||||||
|
void OptionsGroup::createToggle(OptionId optId, Minecraft* minecraft ) {
|
||||||
|
ImageDef def;
|
||||||
|
|
||||||
|
def.setSrc(IntRectangle(160, 206, 39, 20));
|
||||||
|
def.name = "gui/touchgui.png";
|
||||||
|
def.width = 39 * 0.7f;
|
||||||
|
def.height = 20 * 0.7f;
|
||||||
|
|
||||||
|
OptionButton* element = new OptionButton(optId);
|
||||||
|
element->setImageDef(def, true);
|
||||||
|
element->updateImage(&minecraft->options);
|
||||||
|
|
||||||
|
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||||
|
|
||||||
|
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||||
|
|
||||||
|
addChild(item);
|
||||||
|
setupPositions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OptionsGroup::createProgressSlider(OptionId optId, Minecraft* minecraft ) {
|
||||||
|
Slider* element = new SliderFloat(minecraft, optId);
|
||||||
|
element->width = 100;
|
||||||
|
element->height = 20;
|
||||||
|
|
||||||
|
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||||
|
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||||
|
addChild(item);
|
||||||
|
setupPositions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OptionsGroup::createStepSlider(OptionId optId, Minecraft* minecraft ) {
|
||||||
|
Slider* element = new SliderInt(minecraft, optId);
|
||||||
|
element->width = 100;
|
||||||
|
element->height = 20;
|
||||||
|
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||||
|
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||||
|
addChild(item);
|
||||||
|
setupPositions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OptionsGroup::createTextbox(OptionId optId, Minecraft* minecraft) {
|
||||||
|
TextBox* element = new TextOption(minecraft, optId);
|
||||||
|
element->width = 100;
|
||||||
|
element->height = 20;
|
||||||
|
|
||||||
|
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||||
|
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||||
|
addChild(item);
|
||||||
|
setupPositions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OptionsGroup::createKey(OptionId optId, Minecraft* minecraft) {
|
||||||
|
KeyOption* element = new KeyOption(minecraft, optId);
|
||||||
|
element->width = 50;
|
||||||
|
element->height = 20;
|
||||||
|
|
||||||
|
std::string itemLabel = I18n::get(minecraft->options.getOpt(optId)->getStringId());
|
||||||
|
OptionsItem* item = new OptionsItem(optId, itemLabel, element);
|
||||||
|
addChild(item);
|
||||||
|
setupPositions();
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,32 +1,49 @@
|
|||||||
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsGroup_H__
|
#ifndef NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsGroup_H__
|
||||||
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsGroup_H__
|
#define NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsGroup_H__
|
||||||
|
|
||||||
//package net.minecraft.client.gui;
|
//package net.minecraft.client.gui;
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "GuiElementContainer.h"
|
#include "GuiElementContainer.h"
|
||||||
#include "ScrollingPane.h"
|
#include "ScrollingPane.h"
|
||||||
#include "../../Options.h"
|
#include "../../Options.h"
|
||||||
|
|
||||||
class Font;
|
class Font;
|
||||||
class Minecraft;
|
class Minecraft;
|
||||||
|
|
||||||
class OptionsGroup: public GuiElementContainer {
|
class OptionsGroup: public GuiElementContainer {
|
||||||
typedef GuiElementContainer super;
|
typedef GuiElementContainer super;
|
||||||
public:
|
public:
|
||||||
OptionsGroup(std::string labelID);
|
OptionsGroup(std::string labelID);
|
||||||
virtual void setupPositions();
|
virtual void setupPositions();
|
||||||
virtual void render(Minecraft* minecraft, int xm, int ym);
|
virtual void render(Minecraft* minecraft, int xm, int ym);
|
||||||
OptionsGroup& addOptionItem(OptionId optId, Minecraft* minecraft);
|
virtual void tick(Minecraft* minecraft);
|
||||||
protected:
|
virtual void mouseClicked(Minecraft* minecraft, int x, int y, int buttonNum);
|
||||||
|
virtual void mouseReleased(Minecraft* minecraft, int x, int y, int buttonNum);
|
||||||
void createToggle(OptionId optId, Minecraft* minecraft);
|
OptionsGroup& addOptionItem(OptionId optId, Minecraft* minecraft);
|
||||||
void createProgressSlider(OptionId optId, Minecraft* minecraft);
|
void scrollByPixels(float deltaY);
|
||||||
void createStepSlider(OptionId optId, Minecraft* minecraft);
|
bool isScrollingGestureActive() const;
|
||||||
void createTextbox(OptionId optId, Minecraft* minecraft);
|
protected:
|
||||||
void createKey(OptionId optId, Minecraft* minecraft);
|
|
||||||
|
void createToggle(OptionId optId, Minecraft* minecraft);
|
||||||
std::string label;
|
void createProgressSlider(OptionId optId, Minecraft* minecraft);
|
||||||
};
|
void createStepSlider(OptionId optId, Minecraft* minecraft);
|
||||||
|
void createTextbox(OptionId optId, Minecraft* minecraft);
|
||||||
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsGroup_H__*/
|
void createKey(OptionId optId, Minecraft* minecraft);
|
||||||
|
|
||||||
|
std::string label;
|
||||||
|
int contentHeight = 0;
|
||||||
|
float scrollOffsetY = 0.f;
|
||||||
|
float maxScrollOffsetY = 0.f;
|
||||||
|
bool trackingScrollGesture = false;
|
||||||
|
bool scrollingGesture = false;
|
||||||
|
bool touchDispatched = false;
|
||||||
|
int dragStartX = 0;
|
||||||
|
int dragStartY = 0;
|
||||||
|
int lastDragY = 0;
|
||||||
|
int touchStartX = 0;
|
||||||
|
int touchStartY = 0;
|
||||||
|
static const int ScrollStartThreshold = 5;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /*NET_MINECRAFT_CLIENT_GUI_COMPONENTS__OptionsGroup_H__*/
|
||||||
|
|||||||
@@ -204,22 +204,23 @@ void ScrollingPane::render( int xm, int ym, float alpha ) {
|
|||||||
|
|
||||||
const float bxx = bbox.x - (fpx /*+ dx*alpha*/) + (nw.xf - nw.x);
|
const float bxx = bbox.x - (fpx /*+ dx*alpha*/) + (nw.xf - nw.x);
|
||||||
const float byy = bbox.y - (fpy /*+ dy*alpha*/) + (nw.yf - nw.y);
|
const float byy = bbox.y - (fpy /*+ dy*alpha*/) + (nw.yf - nw.y);
|
||||||
for (int y = nw.y; y <= se.y; ++y)
|
for (int y = nw.y; y <= se.y; ++y) {
|
||||||
for (int x = nw.x; x <= se.x; ++x) {
|
for (int x = nw.x; x <= se.x; ++x) {
|
||||||
int id = y * columns + x;
|
int id = y * columns + x;
|
||||||
if (y <0 || id < 0 || id >= numItems) continue; // @todo: break rather
|
if (y <0 || id < 0 || id >= numItems) continue; // @todo: break rather
|
||||||
if (isNotSet(SF_WrapX) && (x < 0 || x >= columns)) continue; // @todo: break rather
|
if (isNotSet(SF_WrapX) && (x < 0 || x >= columns)) continue; // @todo: break rather
|
||||||
GridItem item; //@todo: v- Does not support SF_Wrapping
|
GridItem item; //@todo: v- Does not support SF_Wrapping
|
||||||
item.id = id;
|
item.id = id;
|
||||||
item.xf = bxx + x * itemBbox.w;
|
item.xf = bxx + x * itemBbox.w;
|
||||||
item.yf = byy + y * itemBbox.h;
|
item.yf = byy + y * itemBbox.h;
|
||||||
item.x = (int)item.xf;
|
item.x = (int)item.xf;
|
||||||
item.y = (int)item.yf;
|
item.y = (int)item.yf;
|
||||||
//LOGI("i: %d (%.1f, %.1f)\t", id, item.xf, item.yf);
|
//LOGI("i: %d (%.1f, %.1f)\t", id, item.xf, item.yf);
|
||||||
if (isSet(SF_MultiSelect)) item.selected = selected[id];
|
if (isSet(SF_MultiSelect)) item.selected = selected[id];
|
||||||
else item.selected = (id == selectedId);
|
else item.selected = (id == selectedId);
|
||||||
|
|
||||||
itemsToRender.push_back(item);
|
itemsToRender.push_back(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
renderBatch(itemsToRender, alpha);
|
renderBatch(itemsToRender, alpha);
|
||||||
|
|
||||||
|
|||||||
@@ -329,7 +329,10 @@ bool ChestScreen::handleAddItem(FillingContainer* from, FillingContainer* to, in
|
|||||||
added = (takenItem.count != wantedCount);
|
added = (takenItem.count != wantedCount);
|
||||||
|
|
||||||
if (added) {
|
if (added) {
|
||||||
item->count -= (wantedCount - takenItem.count);
|
if (!minecraft->isCreativeMode()) {
|
||||||
|
item->count -= (wantedCount - takenItem.count);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<int> changed;
|
std::vector<int> changed;
|
||||||
std::vector<const ItemInstance*> items = getItems(toPane);
|
std::vector<const ItemInstance*> items = getItems(toPane);
|
||||||
differ.getDiff(items, changed);
|
differ.getDiff(items, changed);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include "../../../world/level/Level.h"
|
#include "../../../world/level/Level.h"
|
||||||
#include "../../../network/RakNetInstance.h"
|
#include "../../../network/RakNetInstance.h"
|
||||||
#include "../../../network/ServerSideNetworkHandler.h"
|
#include "../../../network/ServerSideNetworkHandler.h"
|
||||||
#include "../../../network/packet/ChatPacket.h"
|
#include "../../../network/packet/MessagePacket.h"
|
||||||
#include "../../../platform/log.h"
|
#include "../../../platform/log.h"
|
||||||
#include "util/StringUtils.h"
|
#include "util/StringUtils.h"
|
||||||
|
|
||||||
@@ -63,25 +63,28 @@ void ConsoleScreen::execute()
|
|||||||
return minecraft->setScreen(NULL);
|
return minecraft->setScreen(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (_input[0] == '/') {
|
if (minecraft->netCallback && !minecraft->raknetInstance->isServer()) {
|
||||||
// // Command
|
MessagePacket packet(_input.c_str());
|
||||||
// _input = Util::stringTrim(_input.substr(1));
|
minecraft->raknetInstance->send(packet);
|
||||||
|
} else if (_input[0] == '/') {
|
||||||
// std::istringstream iss(minecraft->commandManager().execute(*minecraft, *minecraft->player, _input));
|
_input = Util::stringTrim(_input.substr(1));
|
||||||
// for (std::string line; std::getline(iss, line); ) {
|
|
||||||
// minecraft->gui.addMessage(line);
|
std::istringstream iss(
|
||||||
// }
|
minecraft->commandManager().execute(*minecraft, *minecraft->player, _input)
|
||||||
// } else {
|
);
|
||||||
// @ai @rewrite
|
|
||||||
if (minecraft->netCallback && minecraft->raknetInstance->isServer()) {
|
for (std::string line; std::getline(iss, line);) {
|
||||||
static_cast<ServerSideNetworkHandler*>(minecraft->netCallback)->displayGameMessage(_input);
|
minecraft->gui.addMessage(line);
|
||||||
} else if (minecraft->netCallback) {
|
|
||||||
ChatPacket chatPkt(_input);
|
|
||||||
minecraft->raknetInstance->send(chatPkt);
|
|
||||||
} else {
|
|
||||||
minecraft->gui.addMessage("<" + minecraft->player->name + "> " + _input);
|
|
||||||
}
|
}
|
||||||
// }
|
}
|
||||||
|
else {
|
||||||
|
if (minecraft->raknetInstance->isServer()) {
|
||||||
|
MessagePacket packet(_input.c_str());
|
||||||
|
minecraft->raknetInstance->send(packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
minecraft->gui.addMessage("<" + minecraft->player->name + "> " + _input);
|
||||||
|
}
|
||||||
|
|
||||||
minecraft->setScreen(NULL);
|
minecraft->setScreen(NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ void DeathScreen::render( int xm, int ym, float a )
|
|||||||
if (minecraft->options.getIntValue(OPTIONS_MENU_STYLE) == 2){
|
if (minecraft->options.getIntValue(OPTIONS_MENU_STYLE) == 2){
|
||||||
glPushMatrix2();
|
glPushMatrix2();
|
||||||
glScalef2(2, 2, 2);
|
glScalef2(2, 2, 2);
|
||||||
drawCenteredString(font, "Game over!", width / 2 / 2, height / 8, 0xffffff);
|
drawCenteredString(font, I18n::get("deathScreen.title.hardcore"), width / 4, height / 8, 0xffffff);
|
||||||
glPopMatrix2();
|
glPopMatrix2();
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "Score: &e" << minecraft->player->getScore();
|
ss << "Score: &e" << minecraft->player->getScore();
|
||||||
@@ -80,7 +80,7 @@ if (minecraft->options.getIntValue(OPTIONS_MENU_STYLE) == 2){
|
|||||||
} else {
|
} else {
|
||||||
glPushMatrix2();
|
glPushMatrix2();
|
||||||
glScalef2(2, 2, 2);
|
glScalef2(2, 2, 2);
|
||||||
drawCenteredString(font, "You died!", width / 2 / 2, height / 8, 0xffffff);
|
drawCenteredString(font, I18n::get("deathScreen.title"), width / 4, height / 8, 0xffffff);
|
||||||
glPopMatrix2();
|
glPopMatrix2();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -500,6 +500,8 @@ ItemInstance FurnaceScreen::moveOver(const ItemInstance* item, int maxCount) {
|
|||||||
setIfNotSet(doRecreatePane, newSize != oldSize);
|
setIfNotSet(doRecreatePane, newSize != oldSize);
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return ItemInstance();
|
return ItemInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ void OptionsScreen::setupPositions() {
|
|||||||
(*it)->x = categoryButtons[0]->width;
|
(*it)->x = categoryButtons[0]->width;
|
||||||
(*it)->y = bHeader->height;
|
(*it)->y = bHeader->height;
|
||||||
(*it)->width = width - categoryButtons[0]->width;
|
(*it)->width = width - categoryButtons[0]->width;
|
||||||
|
(*it)->height = height - bHeader->height;
|
||||||
|
|
||||||
(*it)->setupPositions();
|
(*it)->setupPositions();
|
||||||
}
|
}
|
||||||
@@ -237,8 +238,10 @@ void OptionsScreen::generateOptionScreens() {
|
|||||||
.addOptionItem(OPTIONS_BAR_ON_TOP, minecraft)
|
.addOptionItem(OPTIONS_BAR_ON_TOP, minecraft)
|
||||||
.addOptionItem(OPTIONS_MENU_STYLE, minecraft)
|
.addOptionItem(OPTIONS_MENU_STYLE, minecraft)
|
||||||
.addOptionItem(OPTIONS_RPI_CURSOR, minecraft)
|
.addOptionItem(OPTIONS_RPI_CURSOR, minecraft)
|
||||||
|
#ifndef __APPLE__
|
||||||
.addOptionItem(OPTIONS_FOLIAGE_TINT, minecraft)
|
.addOptionItem(OPTIONS_FOLIAGE_TINT, minecraft)
|
||||||
.addOptionItem(OPTIONS_TINTED_SIDE, minecraft)
|
.addOptionItem(OPTIONS_TINTED_SIDE, minecraft)
|
||||||
|
#endif
|
||||||
.addOptionItem(OPTIONS_JAVA_HUD, minecraft)
|
.addOptionItem(OPTIONS_JAVA_HUD, minecraft)
|
||||||
.addOptionItem(OPTIONS_FOG_TYPE, minecraft)
|
.addOptionItem(OPTIONS_FOG_TYPE, minecraft)
|
||||||
.addOptionItem(OPTIONS_BETA_SKY, minecraft)
|
.addOptionItem(OPTIONS_BETA_SKY, minecraft)
|
||||||
@@ -261,6 +264,12 @@ void OptionsScreen::mouseReleased(int x, int y, int buttonNum) {
|
|||||||
super::mouseReleased(x, y, buttonNum);
|
super::mouseReleased(x, y, buttonNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OptionsScreen::mouseWheel(int dx, int dy, int xm, int ym) {
|
||||||
|
if (currentOptionsGroup != NULL && currentOptionsGroup->pointInside(xm, ym) && dy != 0) {
|
||||||
|
currentOptionsGroup->scrollByPixels((float)dy * 18.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OptionsScreen::keyPressed(int eventKey) {
|
void OptionsScreen::keyPressed(int eventKey) {
|
||||||
if (currentOptionsGroup != NULL)
|
if (currentOptionsGroup != NULL)
|
||||||
currentOptionsGroup->keyPressed(minecraft, eventKey);
|
currentOptionsGroup->keyPressed(minecraft, eventKey);
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ public:
|
|||||||
|
|
||||||
virtual void mouseClicked(int x, int y, int buttonNum);
|
virtual void mouseClicked(int x, int y, int buttonNum);
|
||||||
virtual void mouseReleased(int x, int y, int buttonNum);
|
virtual void mouseReleased(int x, int y, int buttonNum);
|
||||||
|
virtual void mouseWheel(int dx, int dy, int xm, int ym);
|
||||||
virtual void keyPressed(int eventKey);
|
virtual void keyPressed(int eventKey);
|
||||||
virtual void charPressed(char inputChar);
|
virtual void charPressed(char inputChar);
|
||||||
|
|
||||||
|
|||||||
@@ -8,13 +8,14 @@
|
|||||||
#include "../../../platform/time.h"
|
#include "../../../platform/time.h"
|
||||||
#include "../../../platform/input/Keyboard.h"
|
#include "../../../platform/input/Keyboard.h"
|
||||||
#include "../../../platform/log.h"
|
#include "../../../platform/log.h"
|
||||||
|
#include <locale/I18n.h>
|
||||||
|
|
||||||
SimpleChooseLevelScreen::SimpleChooseLevelScreen(const std::string& levelName)
|
SimpleChooseLevelScreen::SimpleChooseLevelScreen(const std::string& levelName)
|
||||||
: bHeader(0),
|
: bHeader(nullptr),
|
||||||
bGamemode(0),
|
bGamemode(nullptr),
|
||||||
bCheats(0),
|
bCheats(nullptr),
|
||||||
bBack(0),
|
bBack(nullptr),
|
||||||
bCreate(0),
|
bCreate(nullptr),
|
||||||
levelName(levelName),
|
levelName(levelName),
|
||||||
hasChosen(false),
|
hasChosen(false),
|
||||||
gamemode(GameType::Survival),
|
gamemode(GameType::Survival),
|
||||||
@@ -42,10 +43,10 @@ void SimpleChooseLevelScreen::init()
|
|||||||
// first") when the name already existed.
|
// first") when the name already existed.
|
||||||
ChooseLevelScreen::init();
|
ChooseLevelScreen::init();
|
||||||
|
|
||||||
tLevelName.text = "New world";
|
tLevelName.text = I18n::get("selectWorld.newWorld");
|
||||||
|
|
||||||
// header + close button
|
// header + close button
|
||||||
bHeader = new Touch::THeader(0, "Create World");
|
bHeader = new Touch::THeader(0, I18n::get("selectWorld.create"));
|
||||||
// create the back/X button as ImageButton like CreditsScreen
|
// create the back/X button as ImageButton like CreditsScreen
|
||||||
bBack = new ImageButton(2, "");
|
bBack = new ImageButton(2, "");
|
||||||
{
|
{
|
||||||
@@ -56,14 +57,14 @@ void SimpleChooseLevelScreen::init()
|
|||||||
def.setSrc(IntRectangle(150, 0, (int)def.width, (int)def.height));
|
def.setSrc(IntRectangle(150, 0, (int)def.width, (int)def.height));
|
||||||
bBack->setImageDef(def, true);
|
bBack->setImageDef(def, true);
|
||||||
}
|
}
|
||||||
if (/* minecraft->useTouchscreen() */ true) {
|
if (minecraft->options.getIntValue(OPTIONS_MENU_STYLE) != 2) {
|
||||||
bGamemode = new Touch::TButton(1, "Survival mode");
|
bGamemode = new Touch::TButton(1, I18n::get("selectWorld.gameMode.survival"));
|
||||||
bCheats = new Touch::TButton(4, "Cheats: Off");
|
bCheats = new Touch::TButton(4, "Cheats: Off");
|
||||||
bCreate = new Touch::TButton(3, "Create");
|
bCreate = new Touch::TButton(3, I18n::get("selectWorld.create"));
|
||||||
} else {
|
} else {
|
||||||
bGamemode = new Button(1, "Survival mode");
|
bGamemode = new Button(1, I18n::get("selectWorld.gameMode.survival"));
|
||||||
bCheats = new Button(4, "Cheats: Off");
|
bCheats = new Button(4, "Cheats: Off");
|
||||||
bCreate = new Button(3, "Create");
|
bCreate = new Button(3, I18n::get("Create"));
|
||||||
}
|
}
|
||||||
|
|
||||||
buttons.push_back(bHeader);
|
buttons.push_back(bHeader);
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ HumanoidModel::HumanoidModel( float g /*= 0*/, float yOffset /*= 0*/, int texW /
|
|||||||
texWidth = texW;
|
texWidth = texW;
|
||||||
texHeight = texH;
|
texHeight = texH;
|
||||||
|
|
||||||
|
// texWidth = 64;
|
||||||
|
// texHeight = 32;
|
||||||
|
|
||||||
head.setModel(this);
|
head.setModel(this);
|
||||||
hair.setModel(this);
|
hair.setModel(this);
|
||||||
body.setModel(this);
|
body.setModel(this);
|
||||||
|
|||||||
@@ -554,9 +554,9 @@ void LocalPlayer::aiStep() {
|
|||||||
|
|
||||||
//if (onGround && abilities.flying)
|
//if (onGround && abilities.flying)
|
||||||
// abilities.flying = false;
|
// abilities.flying = false;
|
||||||
yBobO = yBob;
|
yBobO = yBob;
|
||||||
xBobO = xBob;
|
xBobO = xBob;
|
||||||
xBob += (xRot - xBob) * 0.5;
|
xBob += (xRot - xBob) * 0.5;
|
||||||
yBob += (yRot - yBob) * 0.5;
|
yBob += (yRot - yBob) * 0.5;
|
||||||
|
|
||||||
if (interpolateOnly())
|
if (interpolateOnly())
|
||||||
@@ -774,22 +774,19 @@ void LocalPlayer::startCrafting(int x, int y, int z, int tableSize) {
|
|||||||
|
|
||||||
void LocalPlayer::startStonecutting(int x, int y, int z) {
|
void LocalPlayer::startStonecutting(int x, int y, int z) {
|
||||||
#ifndef STANDALONE_SERVER
|
#ifndef STANDALONE_SERVER
|
||||||
if (!minecraft->isCreativeMode())
|
minecraft->setScreen( new StonecutterScreen() );
|
||||||
minecraft->setScreen( new StonecutterScreen() );
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalPlayer::openFurnace( FurnaceTileEntity* e ) {
|
void LocalPlayer::openFurnace( FurnaceTileEntity* e ) {
|
||||||
#ifndef STANDALONE_SERVER
|
#ifndef STANDALONE_SERVER
|
||||||
if (!minecraft->isCreativeMode())
|
minecraft->setScreen( new FurnaceScreen(this, e) );
|
||||||
minecraft->setScreen( new FurnaceScreen(this, e) );
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalPlayer::openContainer( ChestTileEntity* container ) {
|
void LocalPlayer::openContainer( ChestTileEntity* container ) {
|
||||||
#ifndef STANDALONE_SERVER
|
#ifndef STANDALONE_SERVER
|
||||||
if (!minecraft->isCreativeMode())
|
minecraft->setScreen( new ChestScreen(this, container) );
|
||||||
minecraft->setScreen( new ChestScreen(this, container) );
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public:
|
|||||||
|
|
||||||
void tick();
|
void tick();
|
||||||
|
|
||||||
float yBob, xBob; // shredder added from b1.8/4j for the hand swaying animation
|
float yBob, xBob; // shredder added from b1.8/4j for the hand swaying animation
|
||||||
float yBobO, xBobO; // shredder added from b1.8/4j for the hand swaying animation
|
float yBobO, xBobO; // shredder added from b1.8/4j for the hand swaying animation
|
||||||
|
|
||||||
void move(float xa, float ya, float za);
|
void move(float xa, float ya, float za);
|
||||||
|
|||||||
@@ -440,7 +440,7 @@ float GameRenderer::getFov(float a, bool applyEffects) {
|
|||||||
fov *= this->oFov + (this->fov - this->oFov) * a;
|
fov *= this->oFov + (this->fov - this->oFov) * a;
|
||||||
|
|
||||||
if (player->isUnderLiquid(Material::water)) fov = 60;
|
if (player->isUnderLiquid(Material::water)) fov = 60;
|
||||||
if (player->health <= 0) {
|
if (player->hasDied()) {
|
||||||
float duration = player->deathTime + a;
|
float duration = player->deathTime + a;
|
||||||
|
|
||||||
fov /= ((1 - 500 / (duration + 500)) * 2.0f + 1);
|
fov /= ((1 - 500 / (duration + 500)) * 2.0f + 1);
|
||||||
@@ -537,7 +537,7 @@ void GameRenderer::bobHurt(float a) {
|
|||||||
|
|
||||||
float hurt = player->hurtTime - a;
|
float hurt = player->hurtTime - a;
|
||||||
|
|
||||||
if (player->health <= 0) {
|
if (player->hasDied()) {
|
||||||
float duration = player->deathTime + a;
|
float duration = player->deathTime + a;
|
||||||
glRotatef2(40 - (40 * 200) / (duration + 200), 0, 0, 1);
|
glRotatef2(40 - (40 * 200) / (duration + 200), 0, 0, 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,14 +291,13 @@ void ItemInHandRenderer::render( float a )
|
|||||||
Lighting::turnOn(mc);
|
Lighting::turnOn(mc);
|
||||||
glPopMatrix2();
|
glPopMatrix2();
|
||||||
|
|
||||||
if (localPlayer) // shredder added, basically does the hand swaying animation from b1.8
|
if (localPlayer) { // shredder added, basically does the hand swaying animation from b1.8
|
||||||
{
|
float xrr = localPlayer->xBobO + (localPlayer->xBob - localPlayer->xBobO) * a;
|
||||||
float xrr = localPlayer->xBobO + (localPlayer->xBob - localPlayer->xBobO) * a;
|
float yrr = localPlayer->yBobO + (localPlayer->yBob - localPlayer->yBobO) * a;
|
||||||
float yrr = localPlayer->yBobO + (localPlayer->yBob - localPlayer->yBobO) * a;
|
// 4J - was using player->xRot and yRot directly here rather than interpolating between old & current with a
|
||||||
// 4J - was using player->xRot and yRot directly here rather than interpolating between old & current with a
|
float yr = player->yRotO + (player->yRot - player->yRotO) * a;
|
||||||
float yr = player->yRotO + (player->yRot - player->yRotO) * a;
|
glRotatef((xr - xrr) * 0.1f, 1, 0, 0);
|
||||||
glRotatef((xr - xrr) * 0.1f, 1, 0, 0);
|
glRotatef((yr - yrr) * 0.1f, 0, 1, 0);
|
||||||
glRotatef((yr - yrr) * 0.1f, 0, 1, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float br = mc->level->getBrightness(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
|
float br = mc->level->getBrightness(Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
|
||||||
@@ -425,6 +424,8 @@ void ItemInHandRenderer::render( float a )
|
|||||||
|
|
||||||
EntityRenderer* er = EntityRenderDispatcher::getInstance()->getRenderer(mc->player);
|
EntityRenderer* er = EntityRenderDispatcher::getInstance()->getRenderer(mc->player);
|
||||||
HumanoidMobRenderer* playerRenderer = (HumanoidMobRenderer*) er;
|
HumanoidMobRenderer* playerRenderer = (HumanoidMobRenderer*) er;
|
||||||
|
EntityRenderDispatcher::getInstance()->setModernSkin((Entity*)(player));
|
||||||
|
|
||||||
float ss = 1;
|
float ss = 1;
|
||||||
glScalef2(ss, ss, ss);
|
glScalef2(ss, ss, ss);
|
||||||
playerRenderer->renderHand();
|
playerRenderer->renderHand();
|
||||||
|
|||||||
@@ -185,11 +185,14 @@ void LevelRenderer::allChanged()
|
|||||||
|
|
||||||
lastFogType = mc->options.getIntValue(OPTIONS_FOG_TYPE);
|
lastFogType = mc->options.getIntValue(OPTIONS_FOG_TYPE);
|
||||||
|
|
||||||
|
#ifndef __APPLE__
|
||||||
bool tint = mc->options.getBooleanValue(OPTIONS_FOLIAGE_TINT);
|
bool tint = mc->options.getBooleanValue(OPTIONS_FOLIAGE_TINT);
|
||||||
|
bool sideTint = mc->options.getBooleanValue(OPTIONS_TINTED_SIDE);
|
||||||
|
#else
|
||||||
|
bool tint = false, sideTint = false;
|
||||||
|
#endif
|
||||||
FoliageColor::setUseTint(tint);
|
FoliageColor::setUseTint(tint);
|
||||||
GrassColor::setUseTint(tint);
|
GrassColor::setUseTint(tint);
|
||||||
|
|
||||||
bool sideTint = mc->options.getBooleanValue(OPTIONS_TINTED_SIDE);
|
|
||||||
TileRenderer::setUseTint(sideTint);
|
TileRenderer::setUseTint(sideTint);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -137,6 +137,11 @@ void EntityRenderDispatcher::render( Entity* entity, float x, float y, float z,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityRenderDispatcher::setModernSkin(Entity* player) {
|
||||||
|
PlayerRenderer* rend = (PlayerRenderer*)(getRenderer(player));
|
||||||
|
rend->setModernSkin((Mob*)player);
|
||||||
|
}
|
||||||
|
|
||||||
EntityRenderer* EntityRenderDispatcher::getRenderer( Entity* entity )
|
EntityRenderer* EntityRenderDispatcher::getRenderer( Entity* entity )
|
||||||
{
|
{
|
||||||
EntityRendererId rendererId = entity->entityRendererId;
|
EntityRendererId rendererId = entity->entityRendererId;
|
||||||
|
|||||||
@@ -45,6 +45,8 @@ public:
|
|||||||
Font* getFont();
|
Font* getFont();
|
||||||
|
|
||||||
void onGraphicsReset();
|
void onGraphicsReset();
|
||||||
|
|
||||||
|
void setModernSkin(Entity* player);
|
||||||
private:
|
private:
|
||||||
void assign(EntityRendererId id, EntityRenderer* renderer);
|
void assign(EntityRendererId id, EntityRenderer* renderer);
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -257,7 +257,7 @@ void EntityRenderer::renderShadow(Entity* e, float x, float y, float z, float po
|
|||||||
//Textures* textures = entityRenderDispatcher->textures;
|
//Textures* textures = entityRenderDispatcher->textures;
|
||||||
//textures->bind(textures->loadTexture("%clamp%/environment/shadow.png"));
|
//textures->bind(textures->loadTexture("%clamp%/environment/shadow.png"));
|
||||||
Textures* textures = entityRenderDispatcher->textures;
|
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);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
@@ -298,6 +298,7 @@ void EntityRenderer::renderShadow(Entity* e, float x, float y, float z, float po
|
|||||||
tt.draw();
|
tt.draw();
|
||||||
|
|
||||||
glColor4f2(1, 1, 1, 1);
|
glColor4f2(1, 1, 1, 1);
|
||||||
|
// tt.color(1.f, 1.f, 1.f, 1.f);
|
||||||
glDisable2(GL_BLEND);
|
glDisable2(GL_BLEND);
|
||||||
glDepthMask(true);
|
glDepthMask(true);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||||
@@ -315,7 +316,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);
|
float a = ((pow - (y - (yt + yo)) / 2) * 0.5f) * getLevel()->getBrightness(xt, yt, zt);
|
||||||
if (a < 0) return;
|
if (a < 0) return;
|
||||||
if (a > 1) a = 1;
|
if (a > 1) a = 1;
|
||||||
// t.color(1, 1, 1, (float) a);
|
// t.color(1.f, 1.f, 1.f, (float) a);
|
||||||
glColor4f2(1, 1, 1, (float) a);
|
glColor4f2(1, 1, 1, (float) a);
|
||||||
|
|
||||||
float x0 = xt + tt->xx0 + xo;
|
float x0 = xt + tt->xx0 + xo;
|
||||||
|
|||||||
@@ -189,9 +189,9 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures, const ItemInsta
|
|||||||
// it we're batching for saving the
|
// it we're batching for saving the
|
||||||
// buffer, this will fail miserably
|
// buffer, this will fail miserably
|
||||||
t.endOverrideAndDraw();
|
t.endOverrideAndDraw();
|
||||||
glDisable2(GL_TEXTURE_2D);
|
// glDisable2(GL_TEXTURE_2D);
|
||||||
fillRect(t, x, y, w, h, 0xff0000);
|
// fillRect(t, x, y, w, h, 0xff0000);
|
||||||
glEnable2(GL_TEXTURE_2D);
|
// glEnable2(GL_TEXTURE_2D);
|
||||||
renderGuiItemCorrect(font, textures, item, int(x), int(y));
|
renderGuiItemCorrect(font, textures, item, int(x), int(y));
|
||||||
t.beginOverride();
|
t.beginOverride();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,13 +70,18 @@ void PlayerRenderer::renderName( Mob* mob, float x, float y, float z ){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerRenderer::render(Entity* mob_, float x, float y, float z, float rot, float a) {
|
// @note fix player skin system
|
||||||
Mob* mob = (Mob*) mob_;
|
void PlayerRenderer::setModernSkin(Mob* mob) {
|
||||||
HumanoidModel* desired = isModernPlayerSkin(mob) ? playerModel64 : playerModel32;
|
HumanoidModel* desired = isModernPlayerSkin(mob) ? playerModel64 : playerModel32;
|
||||||
if (model != desired || humanoidModel != desired) {
|
if (model != desired || humanoidModel != desired) {
|
||||||
model = desired;
|
model = desired;
|
||||||
humanoidModel = desired;
|
humanoidModel = desired;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlayerRenderer::render(Entity* mob_, float x, float y, float z, float rot, float a) {
|
||||||
|
Mob* mob = (Mob*) mob_;
|
||||||
|
setModernSkin(mob);
|
||||||
/* LOGI("[PlayerRenderer] %s: skin=%s, modelTex=%dx%d, desired=%s\n",
|
/* LOGI("[PlayerRenderer] %s: skin=%s, modelTex=%dx%d, desired=%s\n",
|
||||||
((Player*)mob)->name.c_str(), mob->getTexture().c_str(),
|
((Player*)mob)->name.c_str(), mob->getTexture().c_str(),
|
||||||
humanoidModel->texWidth, humanoidModel->texHeight,
|
humanoidModel->texWidth, humanoidModel->texHeight,
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ public:
|
|||||||
|
|
||||||
virtual void renderName(Mob* mob, float x, float y, float z);
|
virtual void renderName(Mob* mob, float x, float y, float z);
|
||||||
virtual void onGraphicsReset();
|
virtual void onGraphicsReset();
|
||||||
|
|
||||||
|
void setModernSkin(Mob* mob);
|
||||||
private:
|
private:
|
||||||
HumanoidModel* playerModel32;
|
HumanoidModel* playerModel32;
|
||||||
HumanoidModel* playerModel64;
|
HumanoidModel* playerModel64;
|
||||||
|
|||||||
@@ -2,18 +2,12 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
enum CommandFlags {
|
|
||||||
COMMAND_FLAG_SINGLEPLAYER_ONLY = (1 << 1),
|
|
||||||
COMMAND_FLAG_NO_ARGS = (1 << 2),
|
|
||||||
};
|
|
||||||
|
|
||||||
class Minecraft;
|
class Minecraft;
|
||||||
class Player;
|
class Player;
|
||||||
|
|
||||||
class Command {
|
class Command {
|
||||||
public:
|
public:
|
||||||
const std::string& getName() { return m_name; }
|
const std::string& getName() { return m_name; }
|
||||||
const CommandFlags getFlags() { return m_flags; }
|
|
||||||
|
|
||||||
bool isPlayerOp(Minecraft& mc, Player& player);
|
bool isPlayerOp(Minecraft& mc, Player& player);
|
||||||
|
|
||||||
@@ -21,8 +15,7 @@ public:
|
|||||||
virtual std::string help(Minecraft& mc) = 0;
|
virtual std::string help(Minecraft& mc) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Command(const std::string& name, CommandFlags flags = (CommandFlags)0) : m_name(name), m_flags(flags) {}
|
Command(const std::string& name) : m_name(name) {}
|
||||||
|
|
||||||
const std::string m_name;
|
const std::string m_name;
|
||||||
const CommandFlags m_flags;
|
|
||||||
};
|
};
|
||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "world/level/Level.h"
|
#include "world/level/Level.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <client/Minecraft.h>
|
#include <client/Minecraft.h>
|
||||||
#include <network/packet/LoginStatusPacket.h>
|
|
||||||
|
|
||||||
CommandBan::CommandBan() : Command("ban") {}
|
CommandBan::CommandBan() : Command("ban") {}
|
||||||
|
|
||||||
@@ -21,26 +20,30 @@ std::string CommandBan::execute(Minecraft& mc, Player& player, const std::vector
|
|||||||
std::string nicknameLower = args[0];
|
std::string nicknameLower = args[0];
|
||||||
std::transform(nicknameLower.begin(), nicknameLower.end(), nicknameLower.begin(), ::tolower);
|
std::transform(nicknameLower.begin(), nicknameLower.end(), nicknameLower.begin(), ::tolower);
|
||||||
|
|
||||||
auto it = std::find_if(mc.level->players.begin(), mc.level->players.end(), [nicknameLower] (auto& it) -> bool {
|
auto it = std::find_if(mc.level->players.begin(), mc.level->players.end(), [args, nicknameLower] (auto& it) -> bool {
|
||||||
std::string lower = it->name;
|
std::string lower = it->name;
|
||||||
std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
|
std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
|
||||||
|
|
||||||
return lower == nicknameLower;
|
return lower == nicknameLower;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (*it == (Player*)mc.player) {
|
||||||
|
return "ban: you can't ban urself lol";
|
||||||
|
}
|
||||||
|
|
||||||
if (it != mc.level->players.end()) {
|
if (it != mc.level->players.end()) {
|
||||||
if (*it == (Player*)mc.player) {
|
mc.level->removePlayer(*it);
|
||||||
return "banip: you can't ban urself lol";
|
(*it)->remove();
|
||||||
}
|
mc.raknetInstance->getPeer()->CloseConnection((*it)->owner, true);
|
||||||
} else {
|
} else {
|
||||||
for (auto& banned : mc.level->bannedPpl) {
|
for (auto& banned : mc.level->bannedPlayers) {
|
||||||
if (nicknameLower == banned) {
|
if (nicknameLower == banned) {
|
||||||
return args[0] + " already banned!";
|
return args[0] + "already banned!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mc.level->bannedPpl.insert(nicknameLower);
|
mc.level->bannedPlayers.insert(nicknameLower);
|
||||||
return "ban: successfully banned player " + args[0];
|
return "ban: successfully banned player " + args[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
#include "CommandBanIp.hpp"
|
|
||||||
#include "commands/Command.hpp"
|
|
||||||
#include "network/RakNetInstance.h"
|
|
||||||
#include "raknet/RakPeerInterface.h"
|
|
||||||
#include "world/level/Level.h"
|
|
||||||
#include <algorithm>
|
|
||||||
#include <client/Minecraft.h>
|
|
||||||
|
|
||||||
CommandBanIp::CommandBanIp() : Command("banip") {}
|
|
||||||
|
|
||||||
std::string CommandBanIp::execute(Minecraft& mc, Player& player, const std::vector<std::string>& args) {
|
|
||||||
if (!isPlayerOp(mc, player)) {
|
|
||||||
return "You aren't enough priveleged to run this command";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.empty()) {
|
|
||||||
return help(mc);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string nicknameLower = args[0];
|
|
||||||
std::transform(nicknameLower.begin(), nicknameLower.end(), nicknameLower.begin(), ::tolower);
|
|
||||||
|
|
||||||
auto it = std::find_if(mc.level->players.begin(), mc.level->players.end(), [nicknameLower] (auto& it) -> bool {
|
|
||||||
std::string lower = it->name;
|
|
||||||
std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
|
|
||||||
|
|
||||||
return lower == nicknameLower;
|
|
||||||
});
|
|
||||||
|
|
||||||
std::string clientIp;
|
|
||||||
|
|
||||||
if (it != mc.level->players.end()) {
|
|
||||||
if (*it == (Player*)mc.player) {
|
|
||||||
return "banip: you can't ban urself lol";
|
|
||||||
}
|
|
||||||
|
|
||||||
RakNet::SystemAddress sysAddress = mc.raknetInstance->getPeer()->GetSystemAddressFromGuid((*it)->owner);
|
|
||||||
|
|
||||||
char ip[32];
|
|
||||||
sysAddress.ToString(false, ip);
|
|
||||||
|
|
||||||
clientIp = ip;
|
|
||||||
|
|
||||||
auto sourceId = (*it)->owner;
|
|
||||||
|
|
||||||
(*it)->reallyRemoveIfPlayer = true;
|
|
||||||
mc.level->removeEntity((*it));
|
|
||||||
mc.raknetInstance->getPeer()->CloseConnection(sourceId, true);
|
|
||||||
} else {
|
|
||||||
for (auto& banned : mc.level->bannedIps) {
|
|
||||||
if (clientIp == banned) {
|
|
||||||
return args[0] + " already banned!";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
clientIp = args[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
mc.level->bannedIps.insert(clientIp);
|
|
||||||
return "banip: successfully banned player by ip " + args[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string CommandBanIp::help(Minecraft& mc) {
|
|
||||||
return "Usage: /banip <player>";
|
|
||||||
}
|
|
||||||
33
src/commands/CommandGimmieItems.cpp
Normal file
33
src/commands/CommandGimmieItems.cpp
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#include "CommandGimmieItems.hpp"
|
||||||
|
#include <client/Minecraft.h>
|
||||||
|
#include <world/level/Level.h>
|
||||||
|
#include <world/item/DyePowderItem.h>
|
||||||
|
|
||||||
|
CommandGimmieItems::CommandGimmieItems() : Command("gimmieitems") {}
|
||||||
|
|
||||||
|
std::string CommandGimmieItems::execute(Minecraft& mc, Player& player, const std::vector<std::string>& args) {
|
||||||
|
if (mc.level != nullptr) {
|
||||||
|
if (mc.level->getLevelData()->getAllowCheats()) {
|
||||||
|
player.inventory->add(new ItemInstance(Item::ironIngot, 64));
|
||||||
|
player.inventory->add(new ItemInstance(Item::ironIngot, 34));
|
||||||
|
player.inventory->add(new ItemInstance(Tile::stonecutterBench));
|
||||||
|
player.inventory->add(new ItemInstance(Tile::workBench));
|
||||||
|
player.inventory->add(new ItemInstance(Tile::furnace));
|
||||||
|
player.inventory->add(new ItemInstance(Tile::wood, 54));
|
||||||
|
player.inventory->add(new ItemInstance(Item::stick, 14));
|
||||||
|
player.inventory->add(new ItemInstance(Item::coal, 31));
|
||||||
|
player.inventory->add(new ItemInstance(Tile::sand, 6));
|
||||||
|
player.inventory->add(new ItemInstance(Item::dye_powder, 23, DyePowderItem::PURPLE));
|
||||||
|
|
||||||
|
return "Grant debug items. Have fun!";
|
||||||
|
} else {
|
||||||
|
return "Cheats are not allowed!";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "World not loaded";
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string CommandGimmieItems::help(Minecraft& mc) {
|
||||||
|
return "Usage: /gimmieitems";
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
#include "Command.hpp"
|
#include "Command.hpp"
|
||||||
|
|
||||||
class CommandBanIp : public Command {
|
class CommandGimmieItems : public Command {
|
||||||
public:
|
public:
|
||||||
CommandBanIp();
|
CommandGimmieItems();
|
||||||
|
|
||||||
std::string execute(Minecraft& mc, Player& player, const std::vector<std::string>& args);
|
std::string execute(Minecraft& mc, Player& player, const std::vector<std::string>& args);
|
||||||
std::string help(Minecraft& mc);
|
std::string help(Minecraft& mc);
|
||||||
@@ -35,11 +35,9 @@ std::string CommandKick::execute(Minecraft& mc, Player& player, const std::vecto
|
|||||||
return "kick: you can't kick urself lol";
|
return "kick: you can't kick urself lol";
|
||||||
}
|
}
|
||||||
|
|
||||||
auto sourceId = (*it)->owner;
|
mc.level->removePlayer(*it);
|
||||||
|
(*it)->remove();
|
||||||
(*it)->reallyRemoveIfPlayer = true;
|
mc.raknetInstance->getPeer()->CloseConnection((*it)->owner, true);
|
||||||
mc.level->removeEntity((*it));
|
|
||||||
mc.raknetInstance->getPeer()->CloseConnection(sourceId, true);
|
|
||||||
return "kick: successfully kicked player " + args[0];
|
return "kick: successfully kicked player " + args[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,7 @@
|
|||||||
#include "commands/CommandKick.hpp"
|
#include "commands/CommandKick.hpp"
|
||||||
#include "commands/CommandOp.hpp"
|
#include "commands/CommandOp.hpp"
|
||||||
#include "commands/CommandBan.hpp"
|
#include "commands/CommandBan.hpp"
|
||||||
#include "commands/CommandBanIp.hpp"
|
#include "commands/CommandGimmieItems.hpp"
|
||||||
#include "commands/CommandPardon.hpp"
|
|
||||||
#include "network/packet/ChatPacket.h"
|
#include "network/packet/ChatPacket.h"
|
||||||
#include "network/RakNetInstance.h"
|
#include "network/RakNetInstance.h"
|
||||||
#include "world/level/Level.h"
|
#include "world/level/Level.h"
|
||||||
@@ -23,8 +22,7 @@ void CommandManager::registerAllCommands() {
|
|||||||
m_commands.push_back(new CommandKick());
|
m_commands.push_back(new CommandKick());
|
||||||
m_commands.push_back(new CommandOp());
|
m_commands.push_back(new CommandOp());
|
||||||
m_commands.push_back(new CommandBan());
|
m_commands.push_back(new CommandBan());
|
||||||
m_commands.push_back(new CommandBanIp());
|
// m_commands.push_back(new CommandGimmieItems());
|
||||||
m_commands.push_back(new CommandPardon());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> CommandManager::getListAllCommands() {
|
std::vector<std::string> CommandManager::getListAllCommands() {
|
||||||
@@ -55,15 +53,8 @@ std::string CommandManager::execute(Minecraft& mc, Player& player, const std::st
|
|||||||
|
|
||||||
std::string tok;
|
std::string tok;
|
||||||
while (ss >> tok) args.push_back(tok);
|
while (ss >> tok) args.push_back(tok);
|
||||||
|
|
||||||
if (!mc.level->isClientSide || (*it)->getFlags() & CommandFlags::COMMAND_FLAG_SINGLEPLAYER_ONLY) {
|
|
||||||
return (*it)->execute(mc, player, args);
|
|
||||||
} else {
|
|
||||||
ChatPacket packet("/" + input);
|
|
||||||
mc.raknetInstance->send(packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
return (*it)->execute(mc, player, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command* CommandManager::getCommand(const std::string& name) {
|
Command* CommandManager::getCommand(const std::string& name) {
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
#include "CommandPardon.hpp"
|
|
||||||
#include "commands/Command.hpp"
|
|
||||||
#include "network/RakNetInstance.h"
|
|
||||||
#include "raknet/RakPeerInterface.h"
|
|
||||||
#include "world/level/Level.h"
|
|
||||||
#include <algorithm>
|
|
||||||
#include <client/Minecraft.h>
|
|
||||||
|
|
||||||
CommandPardon::CommandPardon() : Command("pardon") {}
|
|
||||||
|
|
||||||
std::string CommandPardon::execute(Minecraft& mc, Player& player, const std::vector<std::string>& args) {
|
|
||||||
if (!isPlayerOp(mc, player)) {
|
|
||||||
return "You aren't enough priveleged to run this command";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.empty()) {
|
|
||||||
return help(mc);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string nicknameLower = args[0];
|
|
||||||
std::transform(nicknameLower.begin(), nicknameLower.end(), nicknameLower.begin(), ::tolower);
|
|
||||||
|
|
||||||
if (mc.level->bannedPpl.find(nicknameLower) != mc.level->bannedPpl.end()) {
|
|
||||||
mc.level->bannedPpl.erase(nicknameLower);
|
|
||||||
|
|
||||||
return "pardon: successfully unbanned player " + args[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mc.level->bannedIps.find(nicknameLower) != mc.level->bannedIps.end()) {
|
|
||||||
mc.level->bannedIps.erase(nicknameLower);
|
|
||||||
|
|
||||||
return "pardon: successfully unbanned ip " + args[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
return "Player/Ip doesnt banned";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string CommandPardon::help(Minecraft& mc) {
|
|
||||||
return "Usage: /pardon <player>";
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#include "Command.hpp"
|
|
||||||
|
|
||||||
class CommandPardon : public Command {
|
|
||||||
public:
|
|
||||||
CommandPardon();
|
|
||||||
|
|
||||||
std::string execute(Minecraft& mc, Player& player, const std::vector<std::string>& args);
|
|
||||||
std::string help(Minecraft& mc);
|
|
||||||
};
|
|
||||||
@@ -15,16 +15,15 @@
|
|||||||
#include "platform/time.h"
|
#include "platform/time.h"
|
||||||
#include "SharedConstants.h"
|
#include "SharedConstants.h"
|
||||||
#include "world/level/LevelConstants.h"
|
#include "world/level/LevelConstants.h"
|
||||||
#include <plugins/PluginsManager.hpp>
|
|
||||||
|
|
||||||
#define MAIN_CLASS NinecraftApp
|
#define MAIN_CLASS NinecraftApp
|
||||||
static App* g_app = 0;
|
static App* g_app = 0;
|
||||||
static int g_exitCode = 0;
|
static int g_exitCode = 0;
|
||||||
void signal_callback_handler(int signum) {
|
void signal_callback_handler(int signum) {
|
||||||
std::cout << "Signum caught: " << signum << std::endl;
|
std::cout << "Signum caught: " << signum << std::endl;
|
||||||
|
if(signum == 2 || signum == 3){ // SIGINT || SIGQUIT
|
||||||
|
|
||||||
if (signum == 2 || signum == 3) { // SIGINT || SIGQUIT
|
if(g_app != 0) {
|
||||||
if (g_app != 0) {
|
|
||||||
g_app->quit();
|
g_app->quit();
|
||||||
} else {
|
} else {
|
||||||
exit(g_exitCode);
|
exit(g_exitCode);
|
||||||
@@ -65,6 +64,7 @@ std::string findStringInConfig(std::string line, std::string config) {
|
|||||||
return valueStr;
|
return valueStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int numArguments, char* pszArgs[]) {
|
int main(int numArguments, char* pszArgs[]) {
|
||||||
std::ifstream serverProperties("server.properties");
|
std::ifstream serverProperties("server.properties");
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ int main(int numArguments, char* pszArgs[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("Level Name: %s\n", levelName.c_str());
|
printf("Level Name: %s\n", levelName.c_str());
|
||||||
|
|
||||||
AppContext appContext;
|
AppContext appContext;
|
||||||
appContext.platform = new AppPlatform();
|
appContext.platform = new AppPlatform();
|
||||||
App* app = new MAIN_CLASS();
|
App* app = new MAIN_CLASS();
|
||||||
@@ -162,7 +162,6 @@ int main(int numArguments, char* pszArgs[]) {
|
|||||||
float startTime = getTimeS();
|
float startTime = getTimeS();
|
||||||
((MAIN_CLASS*)g_app)->selectLevel(levelDir, levelName, settings);
|
((MAIN_CLASS*)g_app)->selectLevel(levelDir, levelName, settings);
|
||||||
((MAIN_CLASS*)g_app)->hostMultiplayer(port);
|
((MAIN_CLASS*)g_app)->hostMultiplayer(port);
|
||||||
PluginsManager::get().loadPlugins();
|
|
||||||
|
|
||||||
// Reading ops
|
// Reading ops
|
||||||
std::ifstream ops("ops.txt");
|
std::ifstream ops("ops.txt");
|
||||||
@@ -191,31 +190,13 @@ int main(int numArguments, char* pszArgs[]) {
|
|||||||
|
|
||||||
while (std::getline(banned, line)) {
|
while (std::getline(banned, line)) {
|
||||||
if (!line.empty()) {
|
if (!line.empty()) {
|
||||||
((MAIN_CLASS*)g_app)->level->bannedPpl.insert(line);
|
((MAIN_CLASS*)g_app)->level->bannedPlayers.insert(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::ofstream bannedPpl("banned-players.txt");
|
std::ofstream bannedPlayers("banned-players.txt");
|
||||||
|
|
||||||
if (!bannedPpl.is_open()) {
|
if (!bannedPlayers.is_open()) {
|
||||||
throw std::runtime_error("Cannot create banned players list.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ifstream bannedIps("banned-ips.txt");
|
|
||||||
|
|
||||||
if (bannedIps.is_open()) {
|
|
||||||
std::string line;
|
|
||||||
|
|
||||||
while (std::getline(bannedIps, line)) {
|
|
||||||
if (!line.empty()) {
|
|
||||||
((MAIN_CLASS*)g_app)->level->bannedIps.insert(line);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
std::ofstream bannedIp("banned-ips.txt");
|
|
||||||
|
|
||||||
if (!bannedIp.is_open()) {
|
|
||||||
throw std::runtime_error("Cannot create banned players list.");
|
throw std::runtime_error("Cannot create banned players list.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,7 +204,6 @@ int main(int numArguments, char* pszArgs[]) {
|
|||||||
std::cout << "Level has been generated in " << getTimeS() - startTime << std::endl;
|
std::cout << "Level has been generated in " << getTimeS() - startTime << std::endl;
|
||||||
((MAIN_CLASS*)g_app)->level->saveLevelData();
|
((MAIN_CLASS*)g_app)->level->saveLevelData();
|
||||||
std::cout << "Level has been saved!" << std::endl;
|
std::cout << "Level has been saved!" << std::endl;
|
||||||
PluginsManager::get().emit("ServerLoaded");
|
|
||||||
|
|
||||||
while(!app->wantToQuit()) {
|
while(!app->wantToQuit()) {
|
||||||
app->update();
|
app->update();
|
||||||
@@ -245,27 +225,14 @@ int main(int numArguments, char* pszArgs[]) {
|
|||||||
std::ofstream bannedWrite("banned-players.txt");
|
std::ofstream bannedWrite("banned-players.txt");
|
||||||
|
|
||||||
if (bannedWrite.is_open()) {
|
if (bannedWrite.is_open()) {
|
||||||
for (auto& banned : ((MAIN_CLASS*)g_app)->level->bannedPpl) {
|
for (auto& banned : ((MAIN_CLASS*)g_app)->level->bannedPlayers) {
|
||||||
bannedWrite << banned << std::endl;
|
bannedWrite << banned << std::endl;
|
||||||
}
|
}
|
||||||
bannedWrite.close();
|
bannedWrite.close();
|
||||||
} else {
|
} else {
|
||||||
throw std::runtime_error("Cannot open banned players list.");
|
throw std::runtime_error("Cannot open banned players list.");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ofstream bannedIpsWrite("banned-ips.txt");
|
|
||||||
|
|
||||||
if (bannedIpsWrite.is_open()) {
|
|
||||||
for (auto& banned : ((MAIN_CLASS*)g_app)->level->bannedIps) {
|
|
||||||
bannedIpsWrite << banned << std::endl;
|
|
||||||
}
|
|
||||||
bannedIpsWrite.close();
|
|
||||||
} else {
|
|
||||||
throw std::runtime_error("Cannot open banned players list.");
|
|
||||||
}
|
|
||||||
|
|
||||||
PluginsManager::get().emit("ServerShutdown");
|
|
||||||
|
|
||||||
((MAIN_CLASS*)g_app)->level->saveLevelData();
|
((MAIN_CLASS*)g_app)->level->saveLevelData();
|
||||||
|
|
||||||
delete app;
|
delete app;
|
||||||
|
|||||||
@@ -173,7 +173,6 @@ bool RakNetInstance::isMyLocalGuid(const RakNet::RakNetGUID& guid)
|
|||||||
void RakNetInstance::runEvents(NetEventCallback* callback)
|
void RakNetInstance::runEvents(NetEventCallback* callback)
|
||||||
{
|
{
|
||||||
RakNet::Packet* currentEvent;
|
RakNet::Packet* currentEvent;
|
||||||
bool disconnect = false;
|
|
||||||
|
|
||||||
while ((currentEvent = rakPeer->Receive()) != NULL)
|
while ((currentEvent = rakPeer->Receive()) != NULL)
|
||||||
{
|
{
|
||||||
@@ -201,8 +200,7 @@ void RakNetInstance::runEvents(NetEventCallback* callback)
|
|||||||
case ID_DISCONNECTION_NOTIFICATION:
|
case ID_DISCONNECTION_NOTIFICATION:
|
||||||
case ID_CONNECTION_LOST:
|
case ID_CONNECTION_LOST:
|
||||||
callback->onDisconnect(currentEvent->guid);
|
callback->onDisconnect(currentEvent->guid);
|
||||||
disconnect = true;
|
return;
|
||||||
break;
|
|
||||||
case ID_UNCONNECTED_PONG:
|
case ID_UNCONNECTED_PONG:
|
||||||
{
|
{
|
||||||
RakNet::TimeMS time;
|
RakNet::TimeMS time;
|
||||||
@@ -235,9 +233,8 @@ void RakNetInstance::runEvents(NetEventCallback* callback)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!disconnect) {
|
|
||||||
rakPeer->DeallocatePacket(currentEvent);
|
rakPeer->DeallocatePacket(currentEvent);
|
||||||
}
|
|
||||||
//delete activeBitStream;
|
//delete activeBitStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "../server/ServerPlayer.h"
|
#include "../server/ServerPlayer.h"
|
||||||
#include "../world/entity/item/FallingTile.h"
|
#include "../world/entity/item/FallingTile.h"
|
||||||
#include <plugins/LuaPlayer.hpp>
|
|
||||||
#include <plugins/MessageEvent.hpp>
|
|
||||||
|
|
||||||
#define TIMES(x) for(int itc ## __LINE__ = 0; itc ## __LINE__ < x; ++ itc ## __LINE__)
|
#define TIMES(x) for(int itc ## __LINE__ = 0; itc ## __LINE__ < x; ++ itc ## __LINE__)
|
||||||
|
|
||||||
@@ -162,29 +160,16 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, MessageP
|
|||||||
auto player = getPlayer(source);
|
auto player = getPlayer(source);
|
||||||
|
|
||||||
if (player == nullptr) return; // @todo maybe kick?
|
if (player == nullptr) return; // @todo maybe kick?
|
||||||
|
std::string msg = packet->message.C_String();
|
||||||
auto msg = std::string(packet->message.C_String());
|
|
||||||
|
|
||||||
MessageEvent event;
|
if (msg[0] == '/') {
|
||||||
event.m_decline = false;
|
// This is a command
|
||||||
|
|
||||||
PluginsManager::get().emit("Message", LuaPlayer(source), msg, event);
|
|
||||||
|
|
||||||
if (!event.m_decline) {
|
|
||||||
if (packet->message[0] == '/') {
|
|
||||||
// This is a command
|
|
||||||
auto cmd = Util::stringTrim(msg.substr(1));
|
|
||||||
|
|
||||||
if (PluginsManager::get().emitCommands(cmd, source)) {
|
ChatPacket resp(minecraft->commandManager().execute(*minecraft, *player, Util::stringTrim(msg.substr(1))));
|
||||||
ChatPacket resp(minecraft->commandManager().execute(*minecraft, *player, cmd));
|
return sendPrivate(resp, source);
|
||||||
return sendPrivate(resp, source);
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
displayGameMessage("<" + player->name + "> " + msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
displayGameMessage("<" + player->name + "> " + msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, ChatPacket* packet)
|
void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, ChatPacket* packet)
|
||||||
@@ -193,26 +178,14 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, ChatPack
|
|||||||
|
|
||||||
if (player == nullptr) return; // @todo maybe kick?
|
if (player == nullptr) return; // @todo maybe kick?
|
||||||
|
|
||||||
MessageEvent event;
|
if (packet->message[0] == '/') {
|
||||||
event.m_decline = false;
|
// This is a command
|
||||||
|
|
||||||
PluginsManager::get().emit("Message", LuaPlayer(source), packet->message, event);
|
|
||||||
|
|
||||||
if (!event.m_decline) {
|
|
||||||
if (packet->message[0] == '/') {
|
|
||||||
// This is a command
|
|
||||||
auto cmd = Util::stringTrim(packet->message.substr(1));
|
|
||||||
|
|
||||||
if (PluginsManager::get().emitCommands(cmd, source)) {
|
ChatPacket resp(minecraft->commandManager().execute(*minecraft, *player, Util::stringTrim(packet->message.substr(1))));
|
||||||
ChatPacket resp(minecraft->commandManager().execute(*minecraft, *player, cmd));
|
return sendPrivate(resp, source);
|
||||||
return sendPrivate(resp, source);
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
displayGameMessage("<" + player->name + "> " + packet->message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
displayGameMessage("<" + player->name + "> " + packet->message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerSideNetworkHandler::onNewClient(const RakNet::RakNetGUID& clientGuid)
|
void ServerSideNetworkHandler::onNewClient(const RakNet::RakNetGUID& clientGuid)
|
||||||
@@ -232,7 +205,6 @@ void ServerSideNetworkHandler::onDisconnect(const RakNet::RakNetGUID& guid)
|
|||||||
|
|
||||||
if (player->owner == guid)
|
if (player->owner == guid)
|
||||||
{
|
{
|
||||||
PluginsManager::get().emit("PlayerDisconnect", LuaPlayer(guid));
|
|
||||||
minecraft->level->getLevelStorage()->savePlayer(*player);
|
minecraft->level->getLevelStorage()->savePlayer(*player);
|
||||||
|
|
||||||
std::string message = player->name;
|
std::string message = player->name;
|
||||||
@@ -271,10 +243,7 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, LoginPac
|
|||||||
std::string nicknameLower = packet->clientName.C_String();
|
std::string nicknameLower = packet->clientName.C_String();
|
||||||
std::transform(nicknameLower.begin(), nicknameLower.end(), nicknameLower.begin(), ::tolower);
|
std::transform(nicknameLower.begin(), nicknameLower.end(), nicknameLower.begin(), ::tolower);
|
||||||
|
|
||||||
RakNet::SystemAddress sysAddress = rakPeer->GetSystemAddressFromGuid(source);
|
printf("%s lower \n", nicknameLower.c_str());
|
||||||
char clientIp[32];
|
|
||||||
sysAddress.ToString(false, clientIp);
|
|
||||||
|
|
||||||
for (int i = 0; i < level->players.size(); i++) {
|
for (int i = 0; i < level->players.size(); i++) {
|
||||||
ServerPlayer* player = (ServerPlayer*) level->players.at(i);
|
ServerPlayer* player = (ServerPlayer*) level->players.at(i);
|
||||||
|
|
||||||
@@ -288,20 +257,13 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, LoginPac
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& banned : level->bannedPpl) {
|
for (auto& banned : level->bannedPlayers) {
|
||||||
if (nicknameLower == banned) {
|
if (nicknameLower == banned) {
|
||||||
loginStatus = packet->newProto ? LoginStatus::Failed_Banned : LoginStatus::Failed_ClientOld;
|
loginStatus = packet->newProto ? LoginStatus::Failed_Banned : LoginStatus::Failed_ClientOld;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& banned : level->bannedIps) {
|
|
||||||
if (clientIp == banned) {
|
|
||||||
loginStatus = packet->newProto ? LoginStatus::Failed_Banned : LoginStatus::Failed_ClientOld;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RakNet::BitStream bitStream;
|
RakNet::BitStream bitStream;
|
||||||
LoginStatusPacket(loginStatus).write(&bitStream);
|
LoginStatusPacket(loginStatus).write(&bitStream);
|
||||||
rakPeer->Send(&bitStream, HIGH_PRIORITY, RELIABLE_ORDERED, 0, source, false);
|
rakPeer->Send(&bitStream, HIGH_PRIORITY, RELIABLE_ORDERED, 0, source, false);
|
||||||
@@ -361,6 +323,8 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, ReadyPac
|
|||||||
|
|
||||||
if (packet->type == ReadyPacket::READY_REQUESTEDCHUNKS)
|
if (packet->type == ReadyPacket::READY_REQUESTEDCHUNKS)
|
||||||
onReady_RequestedChunks(source);
|
onReady_RequestedChunks(source);
|
||||||
|
|
||||||
|
LOGI("Ready player two ready ready player two!!\n ");
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerSideNetworkHandler::onReady_ClientGeneration(const RakNet::RakNetGUID& source)
|
void ServerSideNetworkHandler::onReady_ClientGeneration(const RakNet::RakNetGUID& source)
|
||||||
@@ -405,6 +369,7 @@ void ServerSideNetworkHandler::onReady_ClientGeneration(const RakNet::RakNetGUID
|
|||||||
#else
|
#else
|
||||||
LOGW("%s joined the game\n", newPlayer->name.c_str());
|
LOGW("%s joined the game\n", newPlayer->name.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Send all Entities to the new player
|
// Send all Entities to the new player
|
||||||
for (unsigned int i = 0; i < level->entities.size(); ++i) {
|
for (unsigned int i = 0; i < level->entities.size(); ++i) {
|
||||||
Entity* e = level->entities[i];
|
Entity* e = level->entities[i];
|
||||||
@@ -460,8 +425,6 @@ void ServerSideNetworkHandler::onReady_ClientGeneration(const RakNet::RakNetGUID
|
|||||||
bitStream.Reset();
|
bitStream.Reset();
|
||||||
AddPlayerPacket(newPlayer).write(&bitStream);
|
AddPlayerPacket(newPlayer).write(&bitStream);
|
||||||
rakPeer->Send(&bitStream, HIGH_PRIORITY, RELIABLE_ORDERED, 0, source, true);
|
rakPeer->Send(&bitStream, HIGH_PRIORITY, RELIABLE_ORDERED, 0, source, true);
|
||||||
|
|
||||||
PluginsManager::get().emit("PlayerJoin", LuaPlayer(source));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -505,23 +468,17 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, MovePlay
|
|||||||
// return raknetInstance->send(refuse);
|
// return raknetInstance->send(refuse);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
PluginsManager::get().emit(
|
|
||||||
"PlayerMovement",
|
|
||||||
LuaPlayer(source),
|
|
||||||
packet->x, packet->y, packet->z, packet->yRot, packet->xRot, // newPos
|
|
||||||
player->x, player->y, player->z, player->yRot, player->xRot // oldPos
|
|
||||||
);
|
|
||||||
|
|
||||||
entity->xd = entity->yd = entity->zd = 0;
|
entity->xd = entity->yd = entity->zd = 0;
|
||||||
entity->lerpTo(packet->x, packet->y, packet->z, packet->yRot, packet->xRot, 3);
|
entity->lerpTo(packet->x, packet->y, packet->z, packet->yRot, packet->xRot, 3);
|
||||||
|
|
||||||
// broadcast this packet to other clients
|
// broadcast this packet to other clients
|
||||||
redistributePacket(packet, source);
|
redistributePacket(packet, source);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, RemoveBlockPacket* packet) {
|
void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, RemoveBlockPacket* packet){
|
||||||
if (!level) return;
|
if (!level) return;
|
||||||
|
|
||||||
Player* player = getPlayer(source);
|
Player* player = getPlayer(source);
|
||||||
@@ -559,8 +516,6 @@ void ServerSideNetworkHandler::handle(const RakNet::RakNetGUID& source, RemoveBl
|
|||||||
|
|
||||||
|
|
||||||
oldTile->destroy(level, x, y, z, data);
|
oldTile->destroy(level, x, y, z, data);
|
||||||
// RemoveEntityPacket packet(e->entityId);
|
|
||||||
// redistributePacket(&packet, rakPeer->GetMyGUID());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGI("Remove block [%i, %i, %i]\n", packet->x, packet->y, packet->z);
|
LOGI("Remove block [%i, %i, %i]\n", packet->x, packet->y, packet->z);
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ public:
|
|||||||
virtual void handle(const RakNet::RakNetGUID& source, SignUpdatePacket* packet);
|
virtual void handle(const RakNet::RakNetGUID& source, SignUpdatePacket* packet);
|
||||||
virtual void handle(const RakNet::RakNetGUID& source, ChatPacket* packet);
|
virtual void handle(const RakNet::RakNetGUID& source, ChatPacket* packet);
|
||||||
virtual void handle(const RakNet::RakNetGUID& source, MessagePacket* packet);
|
virtual void handle(const RakNet::RakNetGUID& source, MessagePacket* packet);
|
||||||
|
|
||||||
virtual void handle(const RakNet::RakNetGUID& source, WantCreatePacket* packet);
|
virtual void handle(const RakNet::RakNetGUID& source, WantCreatePacket* packet);
|
||||||
|
|
||||||
bool allowsIncomingConnections() { return _allowIncoming; }
|
bool allowsIncomingConnections() { return _allowIncoming; }
|
||||||
@@ -67,7 +68,7 @@ public:
|
|||||||
Player* popPendingPlayer(const RakNet::RakNetGUID& source);
|
Player* popPendingPlayer(const RakNet::RakNetGUID& source);
|
||||||
|
|
||||||
void displayGameMessage(const std::string& message);
|
void displayGameMessage(const std::string& message);
|
||||||
|
private:
|
||||||
/**
|
/**
|
||||||
* @brief Send packet to all players
|
* @brief Send packet to all players
|
||||||
*/
|
*/
|
||||||
@@ -79,8 +80,6 @@ public:
|
|||||||
void sendPrivate(Packet& packet, const RakNet::RakNetGUID& source);
|
void sendPrivate(Packet& packet, const RakNet::RakNetGUID& source);
|
||||||
|
|
||||||
Player* getPlayer(const RakNet::RakNetGUID& source);
|
Player* getPlayer(const RakNet::RakNetGUID& source);
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
Minecraft* minecraft;
|
Minecraft* minecraft;
|
||||||
Level* level;
|
Level* level;
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ static std::string ToStringOk(const T& a, const T& b, const T& c) {
|
|||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << a << "," << b << "," << c << "\n";
|
ss << a << "," << b << "," << c << "\n";
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool inRange(int c, int lowInclusive, int highInclusive) {
|
static bool inRange(int c, int lowInclusive, int highInclusive) {
|
||||||
return c >= lowInclusive && c <= highInclusive;
|
return c >= lowInclusive && c <= highInclusive;
|
||||||
|
|||||||
@@ -10,13 +10,10 @@
|
|||||||
static const char* errIdString = 0;
|
static const char* errIdString = 0;
|
||||||
|
|
||||||
void checkError() {
|
void checkError() {
|
||||||
|
ALenum err = alGetError();
|
||||||
|
if(err == AL_NO_ERROR) return;
|
||||||
|
|
||||||
while (1) {
|
LOGI("### SoundSystemAL error: %d ####: %s\n", err, errIdString==0?"(none)":errIdString);
|
||||||
ALenum err = alGetError();
|
|
||||||
if(err == AL_NO_ERROR) return;
|
|
||||||
|
|
||||||
LOGI("### SoundSystemAL error: %d ####: %s\n", err, errIdString==0?"(none)":errIdString);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//typedef ALvoid AL_APIENTRY (*alBufferDataStaticProcPtr) (const ALint bid, ALenum format, ALvoid *data, ALsizei size, ALsizei freq);
|
//typedef ALvoid AL_APIENTRY (*alBufferDataStaticProcPtr) (const ALint bid, ALenum format, ALvoid *data, ALsizei size, ALsizei freq);
|
||||||
|
|||||||
@@ -1,160 +0,0 @@
|
|||||||
#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>
|
|
||||||
#include <network/packet/ChatPacket.h>
|
|
||||||
#include <network/packet/MovePlayerPacket.h>
|
|
||||||
#include <network/packet/RemoveItemPacket.h>
|
|
||||||
#include <network/packet/SetHealthPacket.h>
|
|
||||||
#include <network/packet/TakeItemPacket.h>
|
|
||||||
#include <world/entity/player/Inventory.h>
|
|
||||||
|
|
||||||
// TODO: Optimize includes
|
|
||||||
class LuaPlayer {
|
|
||||||
public:
|
|
||||||
LuaPlayer(const RakNet::RakNetGUID source) : m_source(source) {}
|
|
||||||
|
|
||||||
Player* getPlayer() {
|
|
||||||
auto mc = PluginsManager::get().getMinecraft();
|
|
||||||
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) mc->netCallback;
|
|
||||||
auto plr = ss->getPlayer(m_source);
|
|
||||||
|
|
||||||
return plr;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getNickname() {
|
|
||||||
auto plr = getPlayer();
|
|
||||||
if (plr != nullptr) return plr->name;
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::tuple<float, float, float, float, float> getPos() {
|
|
||||||
auto plr = getPlayer();
|
|
||||||
if (plr != nullptr) return {plr->x, plr->y, plr->z, plr->yRot, plr->xRot};
|
|
||||||
|
|
||||||
return {0, 0, 0, 0, 0};
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPos(float x, float y, float z, float yRot, float xRot) {
|
|
||||||
auto plr = getPlayer();
|
|
||||||
if (plr == nullptr) return;
|
|
||||||
|
|
||||||
auto mc = PluginsManager::get().getMinecraft();
|
|
||||||
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) mc->netCallback;
|
|
||||||
|
|
||||||
|
|
||||||
// plr->x = x;
|
|
||||||
// plr->y = y;
|
|
||||||
// plr->z = z;
|
|
||||||
// plr->yRot = yRot;
|
|
||||||
// plr->xRot = xRot;
|
|
||||||
plr->xd = plr->yd = plr->zd = 0;
|
|
||||||
plr->lerpTo(x, y, z, yRot, xRot, 3);
|
|
||||||
|
|
||||||
MovePlayerPacket move(plr->entityId, x, y, z, yRot, xRot);
|
|
||||||
|
|
||||||
ss->sendPrivate(move, m_source);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sendMessage(std::string msg) {
|
|
||||||
auto mc = PluginsManager::get().getMinecraft();
|
|
||||||
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) mc->netCallback;
|
|
||||||
ChatPacket packet(msg);
|
|
||||||
|
|
||||||
ss->sendPrivate(packet, m_source);
|
|
||||||
}
|
|
||||||
|
|
||||||
void addItem(int id, int count, int auxValue) {
|
|
||||||
auto plr = getPlayer();
|
|
||||||
if (plr == nullptr) return;
|
|
||||||
|
|
||||||
auto mc = PluginsManager::get().getMinecraft();
|
|
||||||
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) mc->netCallback;
|
|
||||||
auto item = new ItemInstance(id, count, auxValue);
|
|
||||||
|
|
||||||
if (!plr->inventory->add(item)) {
|
|
||||||
plr->inventory->add(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
TakeItemPacket itemAdd(plr->entityId, count, auxValue, id);
|
|
||||||
ss->sendPrivate(itemAdd, m_source);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::tuple<int, int, int> getItem(int index) {
|
|
||||||
auto plr = getPlayer();
|
|
||||||
if (plr == nullptr) return {0, 0, 0};
|
|
||||||
|
|
||||||
auto item = plr->inventory->getItem(index);
|
|
||||||
|
|
||||||
if (item != nullptr) {
|
|
||||||
return {item->id, item->count, item->getAuxValue()};
|
|
||||||
} else {
|
|
||||||
return {0, 0, 0};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void clearInventory() {
|
|
||||||
auto plr = getPlayer();
|
|
||||||
if (plr == nullptr) return;
|
|
||||||
|
|
||||||
auto mc = PluginsManager::get().getMinecraft();
|
|
||||||
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) mc->netCallback;
|
|
||||||
|
|
||||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < plr->inventory->getContainerSize(); i++) {
|
|
||||||
auto itm = plr->inventory->getItem(i);
|
|
||||||
|
|
||||||
if (itm != NULL) {
|
|
||||||
printf("remove %d \n", plr->inventory->removeResource(ItemInstance(itm->id, itm->count, itm->getAuxValue())));
|
|
||||||
RemoveItemPacket itemAdd(plr->entityId, itm->count, itm->getAuxValue(), itm->id);
|
|
||||||
ss->sendPrivate(itemAdd, m_source);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
sol::table getInventory() {
|
|
||||||
auto plr = getPlayer();
|
|
||||||
if (plr == nullptr) return {};
|
|
||||||
|
|
||||||
sol::table inv = PluginsManager::get().getLua().create_table();
|
|
||||||
|
|
||||||
for (int i = Inventory::MAX_SELECTION_SIZE; i < plr->inventory->getContainerSize(); i++) {
|
|
||||||
auto itm = plr->inventory->getItem(i);
|
|
||||||
|
|
||||||
if (itm != NULL) {
|
|
||||||
inv[i - 8] = {itm->id, itm->count, itm->getAuxValue()};
|
|
||||||
} else {
|
|
||||||
inv[i - 8] = sol::lua_nil;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return inv;
|
|
||||||
}
|
|
||||||
|
|
||||||
int getHp() {
|
|
||||||
auto plr = getPlayer();
|
|
||||||
if (plr == nullptr) return -1;
|
|
||||||
|
|
||||||
return plr->health;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setHp(int hp) {
|
|
||||||
auto plr = getPlayer();
|
|
||||||
if (plr == nullptr) return;
|
|
||||||
|
|
||||||
plr->health = hp;
|
|
||||||
|
|
||||||
auto mc = PluginsManager::get().getMinecraft();
|
|
||||||
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) mc->netCallback;
|
|
||||||
|
|
||||||
SetHealthPacket hpPacket(plr->health);
|
|
||||||
ss->sendPrivate(hpPacket, m_source);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
const RakNet::RakNetGUID m_source;
|
|
||||||
};
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
#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);
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
class LuaServer {
|
|
||||||
public:
|
|
||||||
void sendServerMessage(std::string msg);
|
|
||||||
};
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
class MessageEvent {
|
|
||||||
public:
|
|
||||||
bool m_decline;
|
|
||||||
|
|
||||||
void setDecline(bool decline) { m_decline = decline; }
|
|
||||||
private:
|
|
||||||
};
|
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
#include <plugins/PluginsManager.hpp>
|
|
||||||
#include <plugins/LuaPlayer.hpp>
|
|
||||||
#include <plugins/LuaServer.hpp>
|
|
||||||
|
|
||||||
#include <client/Minecraft.h>
|
|
||||||
#include <filesystem>
|
|
||||||
#include "MessageEvent.hpp"
|
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
|
||||||
|
|
||||||
int PluginsManager::emitCommands(std::string command, const RakNet::RakNetGUID& source) {
|
|
||||||
std::vector<std::string> args;
|
|
||||||
std::string cmd;
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
std::string word;
|
|
||||||
std::stringstream ss(command);
|
|
||||||
|
|
||||||
while (ss >> word) {
|
|
||||||
if (i == 0) {
|
|
||||||
cmd = word;
|
|
||||||
} else {
|
|
||||||
args.push_back(word);
|
|
||||||
}
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto it = m_luaCommands.find(cmd);
|
|
||||||
|
|
||||||
if (it == m_luaCommands.end()) return 1;
|
|
||||||
|
|
||||||
for (auto& callback : it->second) {
|
|
||||||
sol::protected_function_result result = callback(LuaPlayer(source), sol::as_table(args));
|
|
||||||
|
|
||||||
if (!result.valid()) {
|
|
||||||
sol::error err = result;
|
|
||||||
std::cout << err.what() << std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PluginsManager::init(Minecraft& minecraft) {
|
|
||||||
m_lua.open_libraries(sol::lib::base, sol::lib::package, sol::lib::string, sol::lib::math, sol::lib::table, sol::lib::io);
|
|
||||||
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) {
|
|
||||||
m_callbacks[event].push_back(func);
|
|
||||||
});
|
|
||||||
|
|
||||||
m_lua.set_function("addCommand", [this](std::string commandName, sol::function func) {
|
|
||||||
m_luaCommands[commandName].push_back(func);
|
|
||||||
});
|
|
||||||
|
|
||||||
m_lua.new_usertype<LuaServer>(
|
|
||||||
"Server",
|
|
||||||
"sendMessage", &LuaServer::sendServerMessage
|
|
||||||
);
|
|
||||||
|
|
||||||
m_lua.new_usertype<LuaPlayer>(
|
|
||||||
"Player",
|
|
||||||
"getNickname", &LuaPlayer::getNickname,
|
|
||||||
"getPos", &LuaPlayer::getPos,
|
|
||||||
"setPos", &LuaPlayer::setPos,
|
|
||||||
"sendMessage", &LuaPlayer::sendMessage,
|
|
||||||
"getInventory", &LuaPlayer::getInventory,
|
|
||||||
"addItem", &LuaPlayer::addItem,
|
|
||||||
"getItem", &LuaPlayer::getItem,
|
|
||||||
"clearInventory", &LuaPlayer::clearInventory,
|
|
||||||
"getHp", &LuaPlayer::getHp,
|
|
||||||
"setHp", &LuaPlayer::setHp
|
|
||||||
);
|
|
||||||
|
|
||||||
m_lua.new_usertype<MessageEvent>(
|
|
||||||
"MessageEvent",
|
|
||||||
"setDecline", &MessageEvent::setDecline
|
|
||||||
);
|
|
||||||
|
|
||||||
m_lua["Server"] = &m_srv;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PluginsManager::loadPlugins() {
|
|
||||||
std::string path = "plugins/";
|
|
||||||
|
|
||||||
if (fs::exists(path)) {
|
|
||||||
for (const auto& entry : fs::directory_iterator(path)) {
|
|
||||||
if (!fs::is_directory(entry.path().string())) {
|
|
||||||
m_lua.script_file(entry.path().string());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
std::filesystem::create_directory(path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <sol/sol.hpp>
|
|
||||||
#include <vector>
|
|
||||||
#include <iostream>
|
|
||||||
#include <plugins/LuaServer.hpp>
|
|
||||||
#include <raknet/RakNetTypes.h>
|
|
||||||
|
|
||||||
class Minecraft;
|
|
||||||
|
|
||||||
class PluginsManager {
|
|
||||||
public:
|
|
||||||
static inline PluginsManager& get() {
|
|
||||||
static PluginsManager inst;
|
|
||||||
return inst;
|
|
||||||
}
|
|
||||||
|
|
||||||
void init(Minecraft& minecraft);
|
|
||||||
|
|
||||||
void registerTypes();
|
|
||||||
|
|
||||||
void loadPlugins();
|
|
||||||
|
|
||||||
sol::state& getLua() { return m_lua; }
|
|
||||||
|
|
||||||
// @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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int emitCommands(std::string command, const RakNet::RakNetGUID& source);
|
|
||||||
|
|
||||||
Minecraft* getMinecraft() { return m_minecraft; }
|
|
||||||
private:
|
|
||||||
std::unordered_map<std::string, std::vector<sol::function>> m_callbacks;
|
|
||||||
std::unordered_map<std::string, std::vector<sol::function>> m_luaCommands;
|
|
||||||
|
|
||||||
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.
|
// so-- that's why the only change I made is to restrict to odd seeds.
|
||||||
//
|
//
|
||||||
|
|
||||||
unsigned int x = ( seed | 1U ) & 0xFFFFFFFFU, *s = state;
|
register unsigned int x = ( seed | 1U ) & 0xFFFFFFFFU, *s = state;
|
||||||
int j;
|
register int j;
|
||||||
|
|
||||||
for ( left = 0, *s++ = x, j = N; --j;
|
for ( left = 0, *s++ = x, j = N; --j;
|
||||||
*s++ = ( x *= 69069U ) & 0xFFFFFFFFU )
|
*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 )
|
unsigned int reloadMT( unsigned int *state, unsigned int *&next, int &left )
|
||||||
{
|
{
|
||||||
unsigned int * p0 = state, *p2 = state + 2, *pM = state + M, s0, s1;
|
register unsigned int * p0 = state, *p2 = state + 2, *pM = state + M, s0, s1;
|
||||||
int j;
|
register int j;
|
||||||
|
|
||||||
if ( left < -1 )
|
if ( left < -1 )
|
||||||
seedMT( 4357U );
|
seedMT( 4357U );
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ void Mob::baseTick()
|
|||||||
if (hurtTime > 0) hurtTime--;
|
if (hurtTime > 0) hurtTime--;
|
||||||
if (invulnerableTime > 0) invulnerableTime--;
|
if (invulnerableTime > 0) invulnerableTime--;
|
||||||
|
|
||||||
if (health <= 0) {
|
if (this->hasDied()) {
|
||||||
deathTime++;
|
deathTime++;
|
||||||
if (deathTime > SharedConstants::TicksPerSecond) {
|
if (deathTime > SharedConstants::TicksPerSecond) {
|
||||||
beforeRemove();
|
beforeRemove();
|
||||||
@@ -437,7 +437,8 @@ void Mob::setSize( float w, float h )
|
|||||||
|
|
||||||
void Mob::heal( int heal )
|
void Mob::heal( int heal )
|
||||||
{
|
{
|
||||||
if (health <= 0) return;
|
if (this->hasDied()) return;
|
||||||
|
|
||||||
health += heal;
|
health += heal;
|
||||||
if (health > 20) health = 20;
|
if (health > 20) health = 20;
|
||||||
invulnerableTime = invulnerableDuration / 2;
|
invulnerableTime = invulnerableDuration / 2;
|
||||||
@@ -447,7 +448,8 @@ bool Mob::hurt( Entity* source, int dmg )
|
|||||||
{
|
{
|
||||||
if (level->isClientSide) return false;
|
if (level->isClientSide) return false;
|
||||||
noActionTime = 0;
|
noActionTime = 0;
|
||||||
if (health <= 0) return false;
|
|
||||||
|
if (this->hasDied()) return false;
|
||||||
|
|
||||||
this->walkAnimSpeed = 1.5f;
|
this->walkAnimSpeed = 1.5f;
|
||||||
|
|
||||||
@@ -485,7 +487,7 @@ bool Mob::hurt( Entity* source, int dmg )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (health <= 0) {
|
if (this->hasDied()) {
|
||||||
if (sound) level->playSound(this, getDeathSound(), getSoundVolume(), getVoicePitch());
|
if (sound) level->playSound(this, getDeathSound(), getSoundVolume(), getVoicePitch());
|
||||||
die(source);
|
die(source);
|
||||||
} else {
|
} else {
|
||||||
@@ -892,7 +894,7 @@ void Mob::newServerAiStep() {
|
|||||||
|
|
||||||
bool Mob::isImmobile()
|
bool Mob::isImmobile()
|
||||||
{
|
{
|
||||||
return health <= 0;
|
return this->hasDied();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mob::jumpFromGround()
|
void Mob::jumpFromGround()
|
||||||
|
|||||||
@@ -127,6 +127,8 @@ public:
|
|||||||
virtual ItemInstance* getCarriedItem() {return NULL;}
|
virtual ItemInstance* getCarriedItem() {return NULL;}
|
||||||
virtual int getUseItemDuration() {return 0;}
|
virtual int getUseItemDuration() {return 0;}
|
||||||
virtual void swing();
|
virtual void swing();
|
||||||
|
|
||||||
|
inline bool hasDied() { return health <= 0; }
|
||||||
protected:
|
protected:
|
||||||
virtual void causeFallDamage(float distance);
|
virtual void causeFallDamage(float distance);
|
||||||
|
|
||||||
|
|||||||
@@ -390,7 +390,7 @@ void Player::travel(float xa, float ya) {
|
|||||||
|
|
||||||
/*protected*/
|
/*protected*/
|
||||||
bool Player::isImmobile() {
|
bool Player::isImmobile() {
|
||||||
return health <= 0 || isSleeping();
|
return hasDied() || isSleeping();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*protected*/
|
/*protected*/
|
||||||
@@ -447,8 +447,8 @@ void Player::aiStep() {
|
|||||||
float tBob = (float) Mth::sqrt(xd * xd + zd * zd);
|
float tBob = (float) Mth::sqrt(xd * xd + zd * zd);
|
||||||
float tTilt = (float) Mth::atan(-yd * 0.2f) * 15.f;
|
float tTilt = (float) Mth::atan(-yd * 0.2f) * 15.f;
|
||||||
if (tBob > 0.1f) tBob = 0.1f;
|
if (tBob > 0.1f) tBob = 0.1f;
|
||||||
if (!onGround || health <= 0) tBob = 0;
|
if (!onGround || hasDied()) tBob = 0;
|
||||||
if (onGround || health <= 0) tTilt = 0;
|
if (onGround || hasDied()) tTilt = 0;
|
||||||
bob += (tBob - bob) * 0.4f;
|
bob += (tBob - bob) * 0.4f;
|
||||||
tilt += (tTilt - tilt) * 0.8f;
|
tilt += (tTilt - tilt) * 0.8f;
|
||||||
|
|
||||||
@@ -518,14 +518,6 @@ bool Player::isCreativeModeAllowed() {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void Player::drop() {
|
|
||||||
// //drop(inventory.removeItem(inventory.selected, 1), false);
|
|
||||||
//}
|
|
||||||
|
|
||||||
void Player::drop(ItemInstance* item) {
|
|
||||||
drop(item, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::drop(ItemInstance* item, bool randomly) {
|
void Player::drop(ItemInstance* item, bool randomly) {
|
||||||
if (item == NULL || item->isNull())
|
if (item == NULL || item->isNull())
|
||||||
return;
|
return;
|
||||||
@@ -559,11 +551,6 @@ void Player::drop(ItemInstance* item, bool randomly) {
|
|||||||
thrownItem->zd += Mth::sin(dir) * pow;
|
thrownItem->zd += Mth::sin(dir) * pow;
|
||||||
}
|
}
|
||||||
|
|
||||||
reallyDrop(thrownItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*protected*/
|
|
||||||
void Player::reallyDrop(ItemEntity* thrownItem) {
|
|
||||||
level->addEntity(thrownItem);
|
level->addEntity(thrownItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -680,7 +667,7 @@ bool Player::hurt(Entity* source, int dmg) {
|
|||||||
if (abilities.invulnerable) return false;
|
if (abilities.invulnerable) return false;
|
||||||
|
|
||||||
noActionTime = 0;
|
noActionTime = 0;
|
||||||
if (health <= 0) return false;
|
if (hasDied()) return false;
|
||||||
if(isSleeping() && !level->isClientSide) {
|
if(isSleeping() && !level->isClientSide) {
|
||||||
stopSleepInBed(true, true, false);
|
stopSleepInBed(true, true, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,10 +91,7 @@ public:
|
|||||||
void handleEntityEvent(char id);
|
void handleEntityEvent(char id);
|
||||||
|
|
||||||
virtual void take(Entity* e, int orgCount);
|
virtual void take(Entity* e, int orgCount);
|
||||||
//void drop();
|
virtual void drop(ItemInstance* item, bool randomly = false);
|
||||||
virtual void drop(ItemInstance* item);
|
|
||||||
virtual void drop(ItemInstance* item, bool randomly);
|
|
||||||
void reallyDrop(ItemEntity* thrownItem);
|
|
||||||
|
|
||||||
bool canDestroy(Tile* tile);
|
bool canDestroy(Tile* tile);
|
||||||
float getDestroySpeed(Tile* tile);
|
float getDestroySpeed(Tile* tile);
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ void Item::initItems() {
|
|||||||
//Item::diode = (new TilePlanterItem(100, Tile::diode_off))->setIcon(6, 5)->setCategory(ItemCategory::Mechanisms)->setDescriptionId("diode");
|
//Item::diode = (new TilePlanterItem(100, Tile::diode_off))->setIcon(6, 5)->setCategory(ItemCategory::Mechanisms)->setDescriptionId("diode");
|
||||||
Item::shears = (ShearsItem*)(new ShearsItem(103))->setIcon(13, 5)->setCategory(ItemCategory::Tools)->setDescriptionId("shears");
|
Item::shears = (ShearsItem*)(new ShearsItem(103))->setIcon(13, 5)->setCategory(ItemCategory::Tools)->setDescriptionId("shears");
|
||||||
Item::melon = (new FoodItem(104, 2, false))->setIcon(13, 6)->setCategory(ItemCategory::FoodArmor)->setDescriptionId("melon");
|
Item::melon = (new FoodItem(104, 2, false))->setIcon(13, 6)->setCategory(ItemCategory::FoodArmor)->setDescriptionId("melon");
|
||||||
Item::seeds_melon = (new SeedItem(106, Tile::melonStem->id, Tile::farmland->id))->setIcon(14, 3)->setCategory(ItemCategory::FoodArmor)->setDescriptionId("seedsMelon");
|
Item::seeds_melon = (new SeedItem(106, Tile::melonStem->id, Tile::farmland->id))->setIcon(14, 3)->setCategory(ItemCategory::FoodArmor)->setDescriptionId("seeds_melon");
|
||||||
Item::beef_raw = (new FoodItem(107, 3, /*FoodConstants.FOOD_SATURATION_LOW,*/ true))->setIcon(9, 6)->setCategory(ItemCategory::FoodArmor)->setDescriptionId("beefRaw");
|
Item::beef_raw = (new FoodItem(107, 3, /*FoodConstants.FOOD_SATURATION_LOW,*/ true))->setIcon(9, 6)->setCategory(ItemCategory::FoodArmor)->setDescriptionId("beefRaw");
|
||||||
Item::beef_cooked = (new FoodItem(108, 8, /*FoodConstants.FOOD_SATURATION_GOOD,*/ true))->setIcon(10, 6)->setCategory(ItemCategory::FoodArmor)->setDescriptionId("beefCooked");
|
Item::beef_cooked = (new FoodItem(108, 8, /*FoodConstants.FOOD_SATURATION_GOOD,*/ true))->setIcon(10, 6)->setCategory(ItemCategory::FoodArmor)->setDescriptionId("beefCooked");
|
||||||
Item::chicken_raw = (new FoodItem(109, 2, /*FoodConstants.FOOD_SATURATION_LOW,*/ true))->setIcon(9, 7)->setCategory(ItemCategory::FoodArmor)->setDescriptionId("chickenRaw");
|
Item::chicken_raw = (new FoodItem(109, 2, /*FoodConstants.FOOD_SATURATION_LOW,*/ true))->setIcon(9, 7)->setCategory(ItemCategory::FoodArmor)->setDescriptionId("chickenRaw");
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
//package net.minecraft.world.item;
|
//package net.minecraft.world.item;
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <plugins/PluginsManager.hpp>
|
|
||||||
#include <plugins/LuaPlayer.hpp>
|
|
||||||
|
|
||||||
#include "Item.h"
|
#include "Item.h"
|
||||||
#include "ItemInstance.h"
|
#include "ItemInstance.h"
|
||||||
@@ -63,7 +61,7 @@ public:
|
|||||||
if (level->setTileAndData(x, y, z, tileId, data)) {
|
if (level->setTileAndData(x, y, z, tileId, data)) {
|
||||||
Tile::tiles[tileId]->setPlacedBy(level, x, y, z, player);
|
Tile::tiles[tileId]->setPlacedBy(level, x, y, z, player);
|
||||||
level->playSound(x + 0.5f, y + 0.5f, z + 0.5f, tile->soundType->getStepSound(), (tile->soundType->getVolume() + 1) / 2, tile->soundType->getPitch() * 0.8f);
|
level->playSound(x + 0.5f, y + 0.5f, z + 0.5f, tile->soundType->getStepSound(), (tile->soundType->getVolume() + 1) / 2, tile->soundType->getPitch() * 0.8f);
|
||||||
PluginsManager::get().emit("PlayerPlaceBlock", LuaPlayer(player->owner), x, y, z, face, tileId, instance->getAuxValue());
|
printf("%f %f %f \n", player->x, player->y, player->z);
|
||||||
/*
|
/*
|
||||||
PlaceBlockPacket packet(player->entityId, x, y, z, face, tileId, instance->getAuxValue());
|
PlaceBlockPacket packet(player->entityId, x, y, z, face, tileId, instance->getAuxValue());
|
||||||
//LOGI("Place block at @ %d, %d, %d\n", x, y, z);
|
//LOGI("Place block at @ %d, %d, %d\n", x, y, z);
|
||||||
|
|||||||
@@ -312,8 +312,7 @@ public:
|
|||||||
Random random;
|
Random random;
|
||||||
|
|
||||||
std::set<std::string> ops;
|
std::set<std::string> ops;
|
||||||
std::set<std::string> bannedPpl;
|
std::set<std::string> bannedPlayers;
|
||||||
std::set<std::string> bannedIps;
|
|
||||||
protected:
|
protected:
|
||||||
bool isFindingSpawn;
|
bool isFindingSpawn;
|
||||||
|
|
||||||
|
|||||||
@@ -43,8 +43,10 @@ int TallGrass::getColor( int auxData ) {
|
|||||||
int TallGrass::getColor( LevelSource* level, int x, int y, int z ) {
|
int TallGrass::getColor( LevelSource* level, int x, int y, int z ) {
|
||||||
int d = level->getData(x, y, z);
|
int d = level->getData(x, y, z);
|
||||||
if (d == DEAD_SHRUB); //return 0xffffff; // i removed this to make it accurate to beta 1.6.6 instead of early java release versions
|
if (d == DEAD_SHRUB); //return 0xffffff; // i removed this to make it accurate to beta 1.6.6 instead of early java release versions
|
||||||
|
|
||||||
|
level->getBiomeSource()->getBiomeBlock(x, z, 1, 1);
|
||||||
float temp = level->getBiomeSource()->temperatures[0]; // shredder added
|
float temp = level->getBiomeSource()->temperatures[0]; // shredder added
|
||||||
float rain = level->getBiomeSource()->downfalls[0]; // shredder added
|
float rain = level->getBiomeSource()->downfalls != nullptr ? level->getBiomeSource()->downfalls[0] : 0; // shredder added
|
||||||
if (!GrassColor::useTint && d == DEAD_SHRUB){
|
if (!GrassColor::useTint && d == DEAD_SHRUB){
|
||||||
return 0xffffff;
|
return 0xffffff;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user