Skip to content

fix: pass placed block to afterPlaceBlock - #403

Open
killcerr wants to merge 3 commits into
LiteLDev:developfrom
killcerr:fix/after-place-block
Open

killcerr wants to merge 3 commits into
LiteLDev:developfrom
killcerr:fix/after-place-block

Conversation

@killcerr

Copy link
Copy Markdown
Contributor

What

afterPlaceBlock now builds the script block from PlayerPlacedBlockEvent::placedBlock() instead of re-reading the block at pos(), which could resolve to air.

Why

Closes #402. Listeners were always seeing minecraft:air.

Verification

Real client on BDS 1.26.51 / LeviLamina 26.51.7, flat world, placed grass blocks and jungle planks:

[LSE402] player=killcerr type=minecraft:grass_block ... waterBlocking=true heavy=false
[LSE402] player=killcerr type=minecraft:jungle_planks ... waterBlocking=true heavy=false

Before the change the same listener logged minecraft:air.

Additional build fixes

  • Define _HAS_CXX23 for the C++20 build: LeviLamina 26.51.7 reflection headers use std::to_underlying.
  • Include ScriptBlockBreakingEventListener.h where ScriptBlockGlobalEventListener destroys a unique_ptr to it, to provide the complete type.

Re-reading the block at the event position could return air. Use the block carried by PlayerPlacedBlockEvent instead. Fixes LiteLDev#402.
LeviLamina reflection headers now use std::to_underlying, so define _HAS_CXX23 for the C++20 build. ScriptBlockGlobalEventListener also needs the complete ScriptBlockBreakingEventListener type.
_AMC64_ was not referenced anywhere; _AMD64_ is the predefined MSVC/clang-cl macro.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 方块放置事件失效afterPlaceBlock

1 participant