summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2021-07-06 15:00:50 +0200
committerGitHub <noreply@github.com>2021-07-06 15:00:50 +0200
commit4354b1b85b92e378ac0ea7c542edc033c6abdaff (patch)
tree4e2fa2a75f76778b1982a84c5a17d8d8744dd078
parentMerge pull request #66 from LaG1924/ftr/more-rmlui (diff)
parentAdded disconnect messages (diff)
downloadAltCraft-4354b1b85b92e378ac0ea7c542edc033c6abdaff.tar
AltCraft-4354b1b85b92e378ac0ea7c542edc033c6abdaff.tar.gz
AltCraft-4354b1b85b92e378ac0ea7c542edc033c6abdaff.tar.bz2
AltCraft-4354b1b85b92e378ac0ea7c542edc033c6abdaff.tar.lz
AltCraft-4354b1b85b92e378ac0ea7c542edc033c6abdaff.tar.xz
AltCraft-4354b1b85b92e378ac0ea7c542edc033c6abdaff.tar.zst
AltCraft-4354b1b85b92e378ac0ea7c542edc033c6abdaff.zip
Diffstat (limited to '')
-rw-r--r--CMakeLists.txt31
-rw-r--r--README.md8
-rw-r--r--cwd/assets/altcraft/scripts/init.lua11
-rw-r--r--cwd/assets/altcraft/shaders/vert/face.vs2
-rw-r--r--src/Plugin.cpp18
-rw-r--r--src/Plugin.hpp2
-rw-r--r--src/Render.cpp2
7 files changed, 60 insertions, 14 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 12ae824..7a2ee79 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,8 +48,9 @@ CPMAddPackage(
VERSION 2.0.14
GIT_TAG release-2.0.14
OPTIONS
- "SDL_SHARED ON"
- "SDL_STATIC OFF"
+ "SDL_SHARED OFF"
+ "SDL_STATIC ON"
+ "LIBC ON"
)
@@ -89,7 +90,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 +103,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(
@@ -142,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)
@@ -181,17 +188,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}
)
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.
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/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)));
}
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<void(double)> onTick;
const std::function<BlockInfo(Vector)> onRequestBlockInfo;
const std::function<void(Chat, int)> onChatMessage;
+ const std::function<void(std::string)> onDisconnected;
};
@@ -45,6 +46,7 @@ namespace PluginApi {
plugin["onTick"].get_or(std::function<void(double)>()),
plugin["onRequestBlockInfo"].get_or(std::function<BlockInfo(Vector)>()),
plugin["onChatMessage"].get_or(std::function<void(Chat, int)>()),
+ plugin["onDisconnected"].get_or(std::function<void(std::string)>()),
};
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 <std::string>());
});
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<std::string>());
});
listener.RegisterHandler("Connecting", [this](const Event&) {