Skip to content

fix(anvil): finish click results on the next tick - #107

Merged
CyR1en merged 2 commits into
CyR1en:developmentfrom
bobhenl:fix/anvil-click-next-tick
Nov 9, 2026
Merged

CyR1en merged 2 commits into
CyR1en:developmentfrom
bobhenl:fix/anvil-click-next-tick

Conversation

@bobhenl

@bobhenl bobhenl commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

Clicking the result (or cancel) slot of the anvil prompt closed the inventory inside the click event. The client kept its predicted cursor item, a copy of the input item, and in creative mode that item became real. Players got name tags (or the configured input item) in their inventory after answering a prompt.

  • Cancel the click and complete the screen on the player's next tick (falls back to completing right away when the scheduler is unavailable).
  • Call updateInventory() after closing, so the client drops any stale cursor/slot state.
  • Same change in prompt-ui-26.1, 26.2 and 26.3.

Tested on a live Paper server: answering an anvil prompt in creative no longer leaves items behind.

Closing the anvil inside the click left the client a predicted cursor item that creative players could keep.
@CyR1en
CyR1en requested review from CyR1en and removed request for CyR1en November 8, 2026 22:46
@CyR1en

CyR1en commented Nov 9, 2026

Copy link
Copy Markdown
Owner

The next-tick change looks right. Paper skips its normal sync when the menu changes during the click event, so deferring the close addresses the cause.

One small request: player.updateInventory() looks unreachable. cleanupScreen calls impl.close() first, so the player is back on their own inventory menu and the getTopInventory().equals(gui.getInventory()) check is false by then. That means the live test passed on the deferral alone. Could you remove the line from all three versions and drop that bullet from the description?

The screen has already switched back to the player's inventory menu by
the time this guard runs, so the call never executes.
@CyR1en

CyR1en commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Went ahead and pushed the small cleanup myself so this does not have to sit around. I just removed the updateInventory() line in all three versions, the rest is your fix as-is. Thanks for tracking this one down!

@CyR1en
CyR1en merged commit f5d7cfc into CyR1en:development Nov 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants