From a04d6679257bd89c0f6fa0ddd6399eba09485171 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 4 Jul 2021 19:35:34 +0500 Subject: Changed dynamic libs to static --- CMakeLists.txt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12ae824..7d703cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,8 +48,8 @@ CPMAddPackage( VERSION 2.0.14 GIT_TAG release-2.0.14 OPTIONS - "SDL_SHARED ON" - "SDL_STATIC OFF" + "SDL_SHARED OFF" + "SDL_STATIC ON" ) @@ -89,7 +89,7 @@ if(SDL2_net_ADDED) file(GLOB SDL2_net_sources ${SDL2_net_SOURCE_DIR}/*.c) list(REMOVE_ITEM SDL2_net_sources "${SDL2_net_SOURCE_DIR}/chatd.c") add_library(SDL2_net STATIC ${SDL2_net_sources}) - target_link_libraries(SDL2_net SDL2) + target_link_libraries(SDL2_net SDL2-static) IF (WIN32) target_link_libraries(SDL2_net ws2_32 iphlpapi) ENDIF() @@ -102,8 +102,8 @@ CPMAddPackage( GITHUB_REPOSITORY madler/zlib VERSION 1.2.11 ) -target_include_directories(zlib PUBLIC ${zlib_SOURCE_DIR}) -target_include_directories(zlib PUBLIC ${zlib_BINARY_DIR}) +target_include_directories(zlibstatic PUBLIC ${zlib_SOURCE_DIR}) +target_include_directories(zlibstatic PUBLIC ${zlib_BINARY_DIR}) CPMAddPackage( @@ -181,17 +181,17 @@ target_link_libraries(AltCraft easyloggingpp libglew_static nlohmann_json::nlohmann_json - SDL2 + SDL2-static SDL2main SDL2_net OptickCore - zlib + zlibstatic sol2 RmlLua RmlDebugger ) -set_target_properties(AltCraft SDL2 OptickCore zlib PROPERTIES +set_target_properties(AltCraft OptickCore PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} ) -- cgit v1.2.3 From ab23b1b10a0beabfef6d33e804de47f11f762c42 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Mon, 5 Jul 2021 12:50:32 +0500 Subject: Added 'Demonstration' section to README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 0f11119..09756f8 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,14 @@ AltCraft is implementation of [Minecraft: Java Edition (1.12.2)](https://minecra This is aimed at being fast, being free and being easy expandable. +# Demonstration ([more](https://github.com/LaG1924/AltCraft/discussions/69)) + +![screenshot_1](https://user-images.githubusercontent.com/12997935/124433999-cbd7a780-dd8c-11eb-812d-e89c65ffabc6.png) +![screenshot_2](https://user-images.githubusercontent.com/12997935/124433848-9fbc2680-dd8c-11eb-9c68-a0a9a3dcaecb.png) + +Clickable video: +[![video_1_yt](https://img.youtube.com/vi/LvvsEjPvCmY/0.jpg)](https://www.youtube.com/watch?v=LvvsEjPvCmY) + # Build 1. Install CMake 3.14, C++ compiler, OpenGL. -- cgit v1.2.3 From 0834b187890c0ef7b4ba8f4df6a248415ec103c8 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Mon, 5 Jul 2021 13:07:34 +0500 Subject: Fixed build for Windows-x86 --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d703cd..f7663bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,7 @@ CPMAddPackage( OPTIONS "SDL_SHARED OFF" "SDL_STATIC ON" + "LIBC ON" ) -- cgit v1.2.3 From 48b543f81d8cb9b8cf43dcce90312637176cc5fd Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Mon, 5 Jul 2021 14:59:17 +0500 Subject: Removed MacOS unnecessary dependencies --- CMakeLists.txt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f7663bc..7a2ee79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -143,10 +143,16 @@ endif() CPMAddPackage( - NAME Freetype - GITHUB_REPOSITORY freetype/freetype - VERSION 2.10.4 - GIT_TAG VER-2-10-4 + NAME Freetype + GITHUB_REPOSITORY freetype/freetype + VERSION 2.10.4 + GIT_TAG VER-2-10-4 + OPTIONS + "CMAKE_DISABLE_FIND_PACKAGE_ZLIB TRUE" + "CMAKE_DISABLE_FIND_PACKAGE_BZip2 TRUE" + "CMAKE_DISABLE_FIND_PACKAGE_PNG TRUE" + "CMAKE_DISABLE_FIND_PACKAGE_HarfBuzz TRUE" + "CMAKE_DISABLE_FIND_PACKAGE_BrotliDec TRUE" ) export(EXPORT freetype-targets) -- cgit v1.2.3 From 40aa26e59d5c806a84eeb3a0ded398393c8ae989 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Mon, 5 Jul 2021 17:10:59 +0500 Subject: Fixed shader error on MacOS --- cwd/assets/altcraft/shaders/vert/face.vs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cwd/assets/altcraft/shaders/vert/face.vs b/cwd/assets/altcraft/shaders/vert/face.vs index 469ea94..93e623d 100644 --- a/cwd/assets/altcraft/shaders/vert/face.vs +++ b/cwd/assets/altcraft/shaders/vert/face.vs @@ -23,5 +23,5 @@ void main() { vs_out.Texture.y -= (uv[2].y - uv[0].y) * trunc(mod(GlobalTime * 4.0f, animation)); float faceLight = clamp(light.x / 15.0 + (light.y / 15.0) * DayTime, MinLightLevel, 1.0); - vs_out.Color = mix(color.rgb * faceLight, vec3(1,1,1) * faceLight, (color == vec3(0,0,0))); + vs_out.Color = mix(color.rgb * faceLight, vec3(1,1,1) * faceLight, float(color == vec3(0,0,0))); } -- cgit v1.2.3 From 28cda3a34c85a35be2e1e4fa35b10fae5d0956d7 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Mon, 5 Jul 2021 18:36:28 +0500 Subject: Added disconnect messages --- cwd/assets/altcraft/scripts/init.lua | 11 +++++++++++ src/Plugin.cpp | 18 +++++++++++++++++- src/Plugin.hpp | 2 ++ src/Render.cpp | 2 ++ 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/cwd/assets/altcraft/scripts/init.lua b/cwd/assets/altcraft/scripts/init.lua index b60a988..c938e94 100644 --- a/cwd/assets/altcraft/scripts/init.lua +++ b/cwd/assets/altcraft/scripts/init.lua @@ -7,6 +7,7 @@ local plugin = { onTick = nil, onRequestBlockInfo = nil, onChatMessage = nil, + onDisconnected = nil, } function plugin.onLoad () @@ -104,6 +105,16 @@ function plugin.onChatMessage(chat, pos) MoveChatToBottom = true end +function plugin.onDisconnected(reason) + local mmDoc = {} + for i,d in ipairs(rmlui.contexts["default"].documents) do + if d.title == "MainMenu" then + mmDoc = d + end + end + mmDoc:GetElementById('disclaimer').inner_rml = reason +end + AC.RegisterDimension(0, Dimension.new("overworld", true)) AC.RegisterDimension(-1, Dimension.new("the_nether", false)) AC.RegisterDimension(1, Dimension.new("the_end", false)) diff --git a/src/Plugin.cpp b/src/Plugin.cpp index 98df8c3..3e06b0c 100644 --- a/src/Plugin.cpp +++ b/src/Plugin.cpp @@ -25,6 +25,7 @@ struct Plugin { const std::function onTick; const std::function onRequestBlockInfo; const std::function onChatMessage; + const std::function onDisconnected; }; @@ -45,6 +46,7 @@ namespace PluginApi { plugin["onTick"].get_or(std::function()), plugin["onRequestBlockInfo"].get_or(std::function()), plugin["onChatMessage"].get_or(std::function()), + plugin["onDisconnected"].get_or(std::function()), }; plugins.push_back(nativePlugin); LOG(INFO)<<"Loading plugin " << (!nativePlugin.displayName.empty() ? nativePlugin.displayName : nativePlugin.name); @@ -371,7 +373,7 @@ BlockInfo PluginSystem::RequestBlockInfo(Vector blockPos) { void PluginSystem::CallOnChatMessage(const Chat& chat, int position) { OPTICK_EVENT(); for (Plugin& plugin : plugins) { - if (plugin.onRequestBlockInfo && plugin.errors < 10) + if (plugin.errors < 10) try { plugin.onChatMessage(chat, position); } @@ -381,3 +383,17 @@ void PluginSystem::CallOnChatMessage(const Chat& chat, int position) { } } } + +void PluginSystem::CallOnDisconnected(const std::string &reason) { + OPTICK_EVENT(); + for (Plugin& plugin : plugins) { + if (plugin.errors < 10) + try { + plugin.onDisconnected(reason); + } + catch (sol::error& e) { + LOG(ERROR) << e.what(); + plugin.errors++; + } + } +} diff --git a/src/Plugin.hpp b/src/Plugin.hpp index 13b126e..e108c4f 100644 --- a/src/Plugin.hpp +++ b/src/Plugin.hpp @@ -22,4 +22,6 @@ namespace PluginSystem { BlockInfo RequestBlockInfo(Vector blockPos); void CallOnChatMessage(const Chat& chat, int position); + + void CallOnDisconnected(const std::string &reason); } \ No newline at end of file diff --git a/src/Render.cpp b/src/Render.cpp index 896a05f..b9b7ab0 100644 --- a/src/Render.cpp +++ b/src/Render.cpp @@ -465,6 +465,7 @@ void Render::InitEvents() { world.reset(); SetState(State::MainMenu); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + PluginSystem::CallOnDisconnected("Connection failed: " + eventData.get ()); }); listener.RegisterHandler("Disconnected", [this](const Event& eventData) { @@ -473,6 +474,7 @@ void Render::InitEvents() { world.reset(); SetState(State::MainMenu); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + PluginSystem::CallOnDisconnected("Disconnected: " + eventData.get()); }); listener.RegisterHandler("Connecting", [this](const Event&) { -- cgit v1.2.3