Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlockDropItemEvent does not execute for indirectly broken blocks #10422

Open
KillerCreeper112 opened this issue Apr 16, 2024 · 5 comments
Open
Labels
status: input wanted Looking for community feedback on this issue. type: bug Something doesn't work as it was intended to. version: 1.20.4 Game version 1.20.4

Comments

@KillerCreeper112
Copy link

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 KillerCreeper112 added status: needs triage type: bug Something doesn't work as it was intended to. labels Apr 16, 2024
@Warriorrrr Warriorrrr added status: input wanted Looking for community feedback on this issue. and removed status: needs triage labels Apr 18, 2024
@Warriorrrr
Copy link
Member

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.

@KillerCreeper112
Copy link
Author

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?

@notTamion
Copy link
Contributor

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

@KillerCreeper112
Copy link
Author

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).

@Machine-Maker
Copy link
Member

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.

@kashike kashike added the version: 1.20.4 Game version 1.20.4 label Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: input wanted Looking for community feedback on this issue. type: bug Something doesn't work as it was intended to. version: 1.20.4 Game version 1.20.4
Projects
Status: Needs Work
Development

No branches or pull requests

5 participants