LiteLDev / LeviLamina

A lightweight, modular and versatile mod loader for Minecraft Bedrock Edition, formerly known as LiteLoaderBDS
https://levimc.org/software/levilamina
GNU Lesser General Public License v3.0
1.14k stars 117 forks source link

[Bug]: Canceling an event #1536

Closed LordBombardir closed 6 months ago

LordBombardir commented 6 months ago

Describe the bug

Canceling the PlayerInteractBlockEvent event does not work.

To Reproduce

Create a listener for the PlayerInteractBlockEvent and cancel it.

Expected behavior

Preventing chest opening/lever switching

Screenshots

I'm sending a video instead of screenshots: https://youtu.be/KjJDRPgbhmY

Platform

Windows 11

Version

0.12.3

Additional context

My code

// here is the logic of event handling
void EventListener::onPlayerInteractBlock(ll::event::PlayerInteractBlockEvent& event) {
    ServerPlayer& player = event.self();

    if (manager::Manager::isPlayerUnauthorized(player.getRealName())) {
        player.sendMessage(
            "§f(§bАвторизация§f) Для того, чтобы взаимодействовать с блоками, Вам §bнеобходимо авторизоваться§f!"
        );

        event.cancel();
        return;
    }
}