BlockDestroyEvent always firing for same part of two-block structure when breaking
Expected behavior
When I break a bed or a door, I expect to receive a BlockBreakEvent for the half of the bed/door that I actually broke through interaction, and then a BlockDestroyEvent for the other half that gets broken automatically through game logic.
Observed/Actual behavior
For beds, the BlockDestroyEvent is always called for the bottom half, no matter which half of the bed the player actually broke. For doors it's always the upper half. Might affect other blocks as well, only tested those two, couldn't think of anything else that's made up of two (or more) blocks off the top of my head.
Steps/models to reproduce
Add two EventHandlers for the events, log the coordinates whenever they're called for a Bed or Door. When breaking the bottom half of a bed or the top half of a door, both events should log the same coordinates.
Plugin and Datapack List
> plugins
[23:00:03 INFO]: Plugins (1): SpigotTestBox
> datapack list
[23:00:07 INFO]: There are 2 data packs enabled: [vanilla (built-in)], [file/bukkit (world)]
[23:00:07 INFO]: There are no more data packs available
Paper version
> version
[22:57:21 INFO]: Checking version, please wait...
[22:57:22 INFO]: This server is running Paper version git-Paper-136 (MC: 1.19.2) (Implementing API version 1.19.2-R0.1-SNAPSHOT) (Git: 046466f)
You are running the latest version
Previous version: git-Paper-134 (MC: 1.19.2)
Other
Could be related to #8191
I can replicate this. Mostly related to the fun way beds delete themselves.
// net.minecraft.world.level.block.BedBlock line 211
if (blockpropertybedpart == BedPart.FOOT) {
BlockPos blockposition1 = pos.relative(BedBlock.getNeighbourDirection(blockpropertybedpart, (Direction) state.getValue(BedBlock.FACING)));
BlockState iblockdata1 = world.getBlockState(blockposition1);
if (iblockdata1.is((Block) this) && iblockdata1.getValue(BedBlock.PART) == BedPart.HEAD) {
world.setBlock(blockposition1, Blocks.AIR.defaultBlockState(), 35);
world.levelEvent(player, 2001, blockposition1, Block.getId(iblockdata1));
}
}
They simply set the other part to air, skipping the event. This change on the other side of the bed then however triggers an update neighbour change, which then triggers a destroy event for the still remaining foot block of the bed.
Would need a rather fun change to untangle that mess :+1:
I cannot replicate this anymore. I registered two listeners, one for break, one for destroy. Then I broke beds and doors in survival mode and different coords were logged. Am closing, if someone can reproduce it still, this can be re-opened or a new issue created.
EDIT: actually, I can reproduce this, but only in creative mode oddly enough. In survival, the coords are different. But if that is an issue for someone, re-open a new issue specifying creative mode as the issue.