Skip to content

Always pass event block to damage source#12158

Merged
lynxplay merged 1 commit into
PaperMC:mainfrom
lynxplay:bugfix/always-pass-event-block
Feb 20, 2025
Merged

Always pass event block to damage source#12158
lynxplay merged 1 commit into
PaperMC:mainfrom
lynxplay:bugfix/always-pass-event-block

Conversation

@lynxplay
Copy link
Copy Markdown
Contributor

@lynxplay lynxplay commented Feb 20, 2025

Always passes the respective block to a damage source when passing a
block state. While we could technically use the damageSourcePosition
here by, we'd have to translate it back to a block position by
subtracting .5 from all its components.
Such behaviour however relies on the caller logic's mutation of the
damageSourcePosition and will break once this position is not the centre
of the block.

Passing in the block at the specific callsite is a lot more future
proof.

Resolves: #12157


Download the paperclip jar for this pull request: paper-12158.zip

Always passes the respective block to a damage source when passing a
block state. While we could technically use the damageSourcePosition
here by, we'd have to translate it back to a block position by
subtracting .5 from all its components.
Such behaviour however relies on the caller logic's mutation of the
damageSourcePosition and will break once this position is not the centre
of the block.

Passing in the block at the specific callsite is a lot more future
proof.
@lynxplay lynxplay requested a review from a team as a code owner February 20, 2025 18:53
@lynxplay lynxplay added the publish-pr Enables a workflow to build Paperclip jars on the pull request. label Feb 20, 2025
@lynxplay lynxplay merged commit ab984a0 into PaperMC:main Feb 20, 2025
@lynxplay lynxplay deleted the bugfix/always-pass-event-block branch February 20, 2025 19:22
lynxplay added a commit that referenced this pull request Feb 21, 2025
This reverts commit ab984a0.

The block damage is null *and has been* null in cases where the block
has already been cleared. Consumers are supposed to use the
getDamagerBlockState instead.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

publish-pr Enables a workflow to build Paperclip jars on the pull request.

Projects

Status: Merged

Development

Successfully merging this pull request may close these issues.

Returned Block in the EntityDamageByBlockEvent Event is null when expecting a Respawn Anchor (Issue 9370)

2 participants