diff --git a/src/assets/AssetsLoader.cpp b/src/assets/AssetsLoader.cpp index 9fecf7da..ce2d1c30 100644 --- a/src/assets/AssetsLoader.cpp +++ b/src/assets/AssetsLoader.cpp @@ -213,12 +213,6 @@ void AssetsLoader::addDefaults(AssetsLoader& loader, const Content* content) { loader.tryAddSound(material.breakSound); } - addLayouts( - 0, - "core", - loader.getPaths()->getMainRoot() / fs::path("layouts"), - loader - ); for (auto& entry : content->getPacks()) { auto pack = entry.second.get(); auto& info = pack->getInfo(); diff --git a/src/engine.cpp b/src/engine.cpp index 7cc35b32..177d327a 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -305,6 +305,8 @@ static void load_configs(const fs::path& root) { } void Engine::loadContent() { + scripting::cleanup(); + auto resdir = paths->getResourcesFolder(); std::vector names; @@ -350,6 +352,7 @@ void Engine::loadContent() { } void Engine::resetContent() { + scripting::cleanup(); auto resdir = paths->getResourcesFolder(); std::vector resRoots; { diff --git a/src/frontend/hud.cpp b/src/frontend/hud.cpp index 2ff4d53c..c58f31ac 100644 --- a/src/frontend/hud.cpp +++ b/src/frontend/hud.cpp @@ -224,7 +224,7 @@ void Hud::processInput(bool visible) { setPause(true); } } - if (!pause && Events::active(BIND_DEVTOOLS_CONSOLE)) { + if (!pause && Events::jactive(BIND_DEVTOOLS_CONSOLE)) { showOverlay(assets->get("core:console"), false); } if (!Window::isFocused() && !pause && !isInventoryOpen()) { diff --git a/src/logic/scripting/scripting.cpp b/src/logic/scripting/scripting.cpp index 67d20a5b..c437a6ae 100644 --- a/src/logic/scripting/scripting.cpp +++ b/src/logic/scripting/scripting.cpp @@ -187,7 +187,15 @@ void scripting::on_world_quit() { for (auto& pack : scripting::engine->getContentPacks()) { lua::emit_event(L, pack.id + ":.worldquit"); } + scripting::level = nullptr; + scripting::content = nullptr; + scripting::indices = nullptr; + scripting::blocks = nullptr; + scripting::controller = nullptr; +} +void scripting::cleanup() { + auto L = lua::get_main_state(); lua::getglobal(L, "pack"); for (auto& pack : scripting::engine->getAllContentPacks()) { lua::getfield(L, "unload"); @@ -199,11 +207,6 @@ void scripting::on_world_quit() { if (lua::getglobal(L, "__scripts_cleanup")) { lua::call_nothrow(L, 0); } - scripting::level = nullptr; - scripting::content = nullptr; - scripting::indices = nullptr; - scripting::blocks = nullptr; - scripting::controller = nullptr; } void scripting::on_blocks_tick(const Block& block, int tps) { diff --git a/src/logic/scripting/scripting.hpp b/src/logic/scripting/scripting.hpp index a34c21cf..af9bb4c2 100644 --- a/src/logic/scripting/scripting.hpp +++ b/src/logic/scripting/scripting.hpp @@ -62,6 +62,7 @@ namespace scripting { void on_world_tick(); void on_world_save(); void on_world_quit(); + void cleanup(); void on_blocks_tick(const Block& block, int tps); void update_block(const Block& block, int x, int y, int z); void random_update_block(const Block& block, int x, int y, int z);