server/world: Add a cancellable neighbour update event#1287
Open
root-nat wants to merge 1 commit into
Open
Conversation
Blocks react to a neighbouring block changing through NeighbourUpdateTick, but a Handler had no way to observe or veto this, unlike the redstone update event. Add HandleNeighbourUpdate, fired before a queued neighbour update is dispatched to the block (and any liquid) at the position; cancelling it skips the update, mirroring HandleRedstoneUpdate. The event is only fired for positions whose block or liquid actually handles neighbour updates, so inert blocks add no overhead. Closes df-mc#1002. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a cancellable event for neighbour-triggered block updates — the equivalent of PocketMine's
BlockUpdateEvent(#1002) — mirroring the existingHandleRedstoneUpdate.What
world.Handler.HandleNeighbourUpdate(ctx *Context, pos, changedNeighbour cube.Pos)(plus theNopHandlerstub) is fired fromperformNeighbourUpdatesbefore a queued neighbour update is dispatched.ctx.Cancel()skips the update for both the block and any liquid at the position.Design note
The event is fired only for positions whose block or liquid implements
NeighbourUpdateTicker— it gates updates that would actually run, rather than firing for every queued position. This keeps the veto use case precise and avoids an allocation per inert neighbour (a block change queues the position plus its six neighbours, most of which do not react).This differs from PocketMine's
BlockUpdateEvent, which fires regardless. If you would prefer observe-everything semantics, the event call can be hoisted above the ticker-existence check with only the dispatch gated on cancellation — happy to change it.Closes #1002.
🤖 Generated with Claude Code