Paper icon indicating copy to clipboard operation
Paper copied to clipboard

BlockDropItemEvent does not execute for indirectly broken blocks

Open KillerCreeper112 opened this issue 10 months ago • 5 comments

Expected behavior

BlockDropItemEvent should execute for indirectly broken blocks (like if a torch was on top of a stone block and the stone was broken- the torch also gets indirectly broken). Because BlockDropItemEvent has a Player attached to it, it should only occur if the block was broken by a player.

Observed/Actual behavior

When a block is broken indirectly by a player (like if a torch was on top of a stone block and the stone was broken- the torch also gets indirectly broken), BlockDropItemEvent does not execute like the documentation says it does:

This event will also be called if the player breaks a multi block structure, for example a torch on top of a stone.

Steps/models to reproduce

@EventHandler
    public void onBlockDropItem(BlockDropItemEvent event) {
        Bukkit.broadcast(Component.text(event.getBlockState().getType() + ""));
    }

Place blocks that get indirectly broken on top of your "main" block. Then break the main block and observe the chat.

Plugin and Datapack List

Custom plugin

Paper version

This server is running Paper version git-Paper-484 (MC: 1.20.4) (Implementing API version 1.20.4-R0.1-SNAPSHOT) (Git: 4445d23) You are running the latest version Previous version: git-Paper-478 (MC: 1.20.4)

Other

I have tried multiple variations of blocks that get indirectly broken (vines, scaffolding, flowers, signs, etc). This is not just an issue for only torches. image image1

KillerCreeper112 avatar Apr 16 '24 00:04 KillerCreeper112

BlockDropItemEvent does not execute like the documentation says it does:

This event will also be called if the player breaks a multi block structure, for example a torch on top of a stone.

The documentation only mentions that items dropped by indirectly broken blocks will be included in the list from getItems, not that another event will be called for the other blocks, so the current behaviour could seem WAI to me.

Warriorrrr avatar Apr 18 '24 18:04 Warriorrrr

BlockDropItemEvent does not execute like the documentation says it does:

This event will also be called if the player breaks a multi block structure, for example a torch on top of a stone.

The documentation only mentions that items dropped by indirectly broken blocks will be included in the list from getItems, not that another event will be called for the other blocks, so the current behaviour could seem WAI to me.

That seems extremely strange to me. Especially because it limits the information that you're getting from the event. Like, why have all the items from all indirectly broken blocks but not have all of the indirectly broken block states themselves?

KillerCreeper112 avatar Apr 18 '24 19:04 KillerCreeper112

i think your idea of just adding a getBlockStates method is pretty good (if that is possible). that way we don't break how the event functions and still provide the extra data

notTamion avatar Apr 20 '24 16:04 notTamion

image

What's weird is the API in 1.19 did say it would call the event multiple times unless I'm misunderstanding it. It says "Both items will have an event call" when describing a torch on top of a stone block. So I guess somewhere down the line the "fix" someone made for it was merging the dropped items in the #getItems() list. (Because yes, I did test it in 1.19 and it does in fact, not execute multiple times per indirect block drop).

KillerCreeper112 avatar Apr 20 '24 20:04 KillerCreeper112

Yeah, afaik, those docs haven't been correct for a while (hence the change to the javadocs in the latest version). Keeping track of blocks broken indirectly is not simple. Right now, the way the items work, is any ItemEntity that is added to the world in the "block breaking" logic is then included in the BlockDropItemEvent items list. So that's why it captures drops from indirect block breaks.

Machine-Maker avatar Apr 20 '24 21:04 Machine-Maker