Skip to content

Fix bottle drops after fatal potion consumption - #14343

Open
flennium wants to merge 1 commit into
PaperMC:mainfrom
flennium:bug/fix-potion-bottle-death
Open

flennium wants to merge 1 commit into
PaperMC:mainfrom
flennium:bug/fix-potion-bottle-death

Conversation

@flennium

@flennium flennium commented Oct 3, 2026 •

Copy link
Copy Markdown
MedalTVMinecraft20261003204553603-trim-1791056852011.mp4

Fixes #14338.

What was happening

When a player drank a fatal harming potion, finishUsingItem() applied the potion effects before replacing the potion with a glass bottle. The fatal effect called die() immediately, so Paper processed the death while the potion was still in the player's hand. The potion could enter the death drops, then item completion could put the bottle into the inventory after death processing, leaving the wrong item state after respawn.

The fix

During player item completion, die() now saves the first damage source instead of processing death immediately. The potion's result is installed and item use is stopped before the saved death is processed. A finally block also drains the saved source if completion exits exceptionally, so a lethal source is not left pending. Deaths outside this completion path are unchanged.

Testing

I reproduced the issue with the original build and confirmed the fix with the new Paperclip build. I tested fatal main-hand potion use with both keepInventory settings, fatal offhand use, and normal nonfatal potion use. The tested inventory outcomes had no extra potion or bottle.

I also ran patch application and rebuilding, the full Gradle build and check lifecycle, and built and launched the Paperclip jar. The final Gradle test report shows 10,066 tests, 0 failures, and 86 skipped.

Notes

Other consumables that cause death during completion use the same ordering. Damage caused by a plugin in the earlier PlayerItemConsumeEvent is outside the deferral. If item completion throws before it produces a replacement, death is still processed in finally using the inventory state at that point; the item's partial changes are not rolled back.

AI-assisted tooling helped trace the lifecycle, refine the implementation, and run the build checks. I reviewed the final diff and performed the in-game tests listed above.

@flennium
flennium requested a review from a team as a code owner October 3, 2026 20:40
@Doc94

Doc94 commented Oct 4, 2026

Copy link
Copy Markdown
Member

not totally sure about the fix... this mess with the death event and the use of item....

Currently exists two issues.

  • The item dropped its before of the change of the use_remainder component (paper issue)
  • The item converted using use_remainder its added when player die and keep in inventory when respawn (that part its paper and vanilla bug, vanilla add the item but remove when respawn because its added to late, paper keep the item because the changes of respawn for the player instance)

@flennium

flennium commented Oct 5, 2026 •

Copy link
Copy Markdown
Author

Ok, so I think I get it now.Two separate things: the drops get collected before use_remainder turns the potion into a bottle, and then the bottle gets added after death processing has already finished. Vanilla loses it on respawn since it makes a new player, but Paper reuses the same one so it just stays.

  • I delayed death on purpose so the whole drink finishes first and the PlayerDeathEvent sees the bottle. But yeah, I know that moves PlayerDeathEvent and plugins might notice, can't promise they won't.

So should I keep it like this (death waits till the item is done), or use a narrower fix, and leave the death event where it is? With a narrower fix, I'd still need to sort out the potion showing up in the drops, and whether the late bottle should just vanish like Vanilla or get fixed too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Awaiting review

Development

Successfully merging this pull request may close these issues.

Glass bottle persists on death

2 participants