From c070b75e208d174f49cd84daffb79a11d83a3269 Mon Sep 17 00:00:00 2001 From: killcerr Date: Sat, 24 Oct 2026 16:07:27 +0800 Subject: [PATCH 1/3] fix: pass placed block to afterPlaceBlock Re-reading the block at the event position could return air. Use the block carried by PlayerPlacedBlockEvent instead. Fixes #402. --- CHANGELOG.md | 5 +++++ src/lse/events/PlayerEvents.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b9e5716..3ec44e1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- `afterPlaceBlock` now passes the placed block instead of re-reading the position, which could report air [#402] + ## [0.22.3] - 2026-10-11 ### Fixed @@ -1466,6 +1470,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#393]: https://github.com/LiteLDev/LegacyScriptEngine/issues/393 [#394]: https://github.com/LiteLDev/LegacyScriptEngine/issues/394 [#396]: https://github.com/LiteLDev/LegacyScriptEngine/issues/396 +[#402]: https://github.com/LiteLDev/LegacyScriptEngine/issues/402 [Unreleased]: https://github.com/LiteLDev/LegacyScriptEngine/compare/v0.22.3...HEAD [0.22.3]: https://github.com/LiteLDev/LegacyScriptEngine/compare/v0.22.2...v0.22.3 diff --git a/src/lse/events/PlayerEvents.cpp b/src/lse/events/PlayerEvents.cpp index 312a1102..def60bde 100644 --- a/src/lse/events/PlayerEvents.cpp +++ b/src/lse/events/PlayerEvents.cpp @@ -281,7 +281,7 @@ void afterPlaceBlock() { CallEvent( EVENT_TYPES::afterPlaceBlock, PlayerClass::newPlayer(&ev.self()), - BlockClass::newBlock(ev.pos(), ev.self().getDimensionId()) + BlockClass::newBlock(ev.placedBlock(), ev.pos(), ev.self().getDimensionId()) ); // Not cancellable } } From d8e2b3d15c6c5fe689aa4ca1609e3d2f75a8b8f7 Mon Sep 17 00:00:00 2001 From: killcerr Date: Sat, 24 Oct 2026 16:07:27 +0800 Subject: [PATCH 2/3] build: adapt to LeviLamina 26.51.7 headers LeviLamina reflection headers now use std::to_underlying, so define _HAS_CXX23 for the C++20 build. ScriptBlockGlobalEventListener also needs the complete ScriptBlockBreakingEventListener type. --- src/lse/events/BlockEventsHooks.cpp | 1 + xmake.lua | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lse/events/BlockEventsHooks.cpp b/src/lse/events/BlockEventsHooks.cpp index 69f1e05f..f7053bed 100644 --- a/src/lse/events/BlockEventsHooks.cpp +++ b/src/lse/events/BlockEventsHooks.cpp @@ -7,6 +7,7 @@ #include "legacy/api/PlayerAPI.h" #include "ll/api/memory/Hook.h" #include "lse/api/Thread.h" +#include "mc/scripting/modules/minecraft/events/ScriptBlockBreakingEventListener.h" #include "mc/scripting/modules/minecraft/events/ScriptBlockGlobalEventListener.h" #include "mc/server/commands/CommandOrigin.h" #include "mc/server/commands/CommandOriginType.h" diff --git a/xmake.lua b/xmake.lua index 819d9fd6..25c7ab92 100644 --- a/xmake.lua +++ b/xmake.lua @@ -65,7 +65,7 @@ option("backend") target("LegacyScriptEngine") add_rules("@levibuildscript/linkrule") if is_plat("windows") then - add_defines("NOMINMAX", "UNICODE", "_AMC64_") + add_defines("NOMINMAX", "UNICODE", "_AMC64_", "_HAS_CXX23=1") set_exceptions("none") -- To avoid conflicts with /EHa. add_cxflags( "/EHa", "/utf-8", "/W4", "/w44265", "/w44289", "/w44296", "/w45263", "/w44738", "/w45204") add_cxflags( From 2f48754a794da1d9d49fcf1a125ef47c8b1c0a1d Mon Sep 17 00:00:00 2001 From: killcerr Date: Sat, 24 Oct 2026 16:08:43 +0800 Subject: [PATCH 3/3] build: fix typo in _AMD64_ define _AMC64_ was not referenced anywhere; _AMD64_ is the predefined MSVC/clang-cl macro. --- xmake.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xmake.lua b/xmake.lua index 25c7ab92..5a7ca28a 100644 --- a/xmake.lua +++ b/xmake.lua @@ -65,7 +65,7 @@ option("backend") target("LegacyScriptEngine") add_rules("@levibuildscript/linkrule") if is_plat("windows") then - add_defines("NOMINMAX", "UNICODE", "_AMC64_", "_HAS_CXX23=1") + add_defines("NOMINMAX", "UNICODE", "_AMD64_", "_HAS_CXX23=1") set_exceptions("none") -- To avoid conflicts with /EHa. add_cxflags( "/EHa", "/utf-8", "/W4", "/w44265", "/w44289", "/w44296", "/w45263", "/w44738", "/w45204") add_cxflags(