The bug
Due to player data and region files not written to disk simultaneously, items can be duplicated quite easy under certain conditions. As of 1.16, Minecraft can be configured to run in synchronous disk i/o mode, making this issue more obvious and easier to reproduce.
How to reproduce
Make sure
syncChunkWrites
inoptions.txt
is set totrue
Create a world and fill your inventory with things
Leave the world to make sure player data gets written to disk
Rejoin the world
Die
Forcefully terminate minecraft's java process (Taskmanager,
/taskkill
, ...)Rejoin the world
→ ❌ Notice things you've collected now appear on the ground and in your inventory
Video demonstrating the issue (potentially outdated regarding reproduction): https://youtu.be/0RYRj5XN8vk?t=25s
Related issues
is duplicated by
relates to
Comments
I just tried it:
Threw a dozen diamond blocks on the ground, pressed esc then again, then force-closed the game.
When i reopened minecraft the items on the ground were invisible, but i was still able to pick them up. Interesting :/
(Running Mas OS X Mountain Lion btw)
As this has been in the game for a while I do not believe that this should not be considered a 1.4.1Pre bug. It is more a long standing bug than a bug which was a result of switching to 1.4.1Pre.
This glitch only works in 1.2.5 release, it was fixed
I tested it in 1.4.1Pre, and it worked there. As for what Nathan W. said, It's a bug that is still there, so it should be considered an ongoing bug in this version.
is true, I'm in 1.4.2 and it worked
While this is a bug, it's not important, because it doesn't affect gameplay, as you could just as easily put yourself in creative mode and give yourself the blocks.
@Zachary Connor
Unless, of course cheats are off.
Is this still a concern on Minecraft 1.4.4 Pre-Release? If so, please update the version affected.
Can't reproduce 1.4.5pre
@Isaak Rogers No, you can open to LAN then enable cheats within that menu.
Unable to reproduce. Instead of appearing on the ground and in my inventory, items disappear from both instances, which indicates this is somewhat fixed, though atleast one instance should remain after reloading the world, but I assume this is related to MC-409. Resolving for now.

I cannot reproduce this bug in 1.6.2.
This bug is still in the game in a similar form. Now you cannot dupe the item by alt f4, instead you must save and quit to menu but the timing is more precise.
Cannot reproduce on 15w51b.

Is this still an issue in the current Minecraft Snapshot 15w51b or later? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.
Reopened from MC-95793
Unable to reproduce in 1.9.0

Confirmed in 1.9.1-pre1.
I can't seem to reproduce this in 16w20a. I'm on OS X, and I used Cmd-Q to close the game (instead of Alt-F4). In the log it says that it saved the worlds as well as the players when I quit the game, and the item was not on the ground when I reopened the game.
Is this a Windows-only issue?

Alt+f4 and command+q are very different commands.

Has anyone tips to reproduce this? Do I have to press Alt+F4 right when the item appears first in the hotbar, while the little animation still runs? And at what point of the animation is the probability the highest?

The following is based on a decompiled version of Minecraft 1.10 using MCP 9.30.
It looks like the player data is only saved when either all chunks are saved or when the player logged out. To create this bug in singleplayer the client needs to crash and before the server can shut down because the owner left the server needs to crash as well. This is very likely impossible because shutting down the server happens directly after the player data was saved.
In multiplayer this can happen more likely, if the player leaves the server and the server crashes at some point after that before the chunks are saved, but this is the intended behaviour.
But please recheck.

That wasn't really a code analysis but rather an explanation why it should not happen anymore

Seems like a reasonable explanation to me. If anyone still has this issue, please leave a comment, if there is none within a reasonable time frame, this will be marked as "Fixed".

Anyone seeing similar stuff in 1.11?
This is reproduceable on Minecraft 1.11, tested with the vanilla server jar.
https://youtu.be/RvsiKgHG1rE?t=13s
Players are able to dupe items or stacks of items by sending a disconnect packet from their client and dropping an item at the same moment. The player drops the item in their hand, and closing the connection with their client upon dropping an item. When they re-connect in, the item is in their hand and on the ground.
[03:55:09] [Server thread/INFO]: pudens29 lost connection: TranslatableComponent{key='disconnect.genericReason', args=[Internal Exception: io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: readerIndex(1) + length(1) exceeds writerIndex(1): UnpooledHeapByteBuf(ridx: 1, widx: 1, cap: 1)], siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null,insertion=null}}

Please use the preview function (the blue symbol out the bottom left). You just sent 130 mails through JIRA.
Apologies for the multitude of emails, wasn't considering how editing affects the email servers.
As far as this bug goes, is there any chance of getting the status changed to reopened?
In addition to simply dropping items on the ground, players are also able to drop the item into a hopper and disconnect. The hopper updates and pulls in the item, but the player's inventory is not updated and still has the item in it, duplicating the item. This works with any item, but is especially game-breaking with shulker boxes filled with items.

can confirm in 1.11.2
Confirmed for latest snapshots 17w17a and 17w17b.
Confirmed for latest snapshot (18w15a)...
This glitch/bug is confirmed for Minecraft 1.13-pre1.
Confirmed for Minecraft 1.13-pre2.

I am unable to reproduce with the steps given in 1.14-pre5. Can someone else?
If not, I will close this ticket after seven days.

Is this still an issue in 1.14.4 or later?
I'm unable to reproduce in 1.14.4. The game now seems to save the current state of the world when Alt+F4 is used. This bug might still exist if there is a way to close the game without saving.

Of course there is. Killing the process. Either using the task manager or by holding F3+C.
Yes, killing the process closes the game without saving, but the inventory isn't saved either, meaning only the items laying on the ground remain. Seems like this might have been fixed indeed.
F3+C saves the game completely before causing a crash.

You can initiate a save by pressing Alt+F4 and then stop the process with the right timing.
Then please provide some consistent reproduction steps for that that don't cause the world file to be corrupted.

New repro steps provided in MC-161408.
Cannot reproduce in 1.15.2 (this)
Could anyone who has been able to reproduce this issue in 1.15+ provide detailed repro steps, please? None of the mentioned above work in 1.16-pre2.

I just tried to replicate this in 1.16.1 using the new instructions in the bug report. Could not get it to work. I used ALT+F4 and kill process in task manager. Maybe it needs just the right timing.

Use the task manager to forcefully kill the java thread. I've just noticed that ALT
+F4
places a WM_CLOSE
causing Minecraft to quit gracefully.
Also do it right after you have died to reduce the chance that player data gets written to disk in the meantime.

Modified title of report to be found more easily.
Can raproduce in 1.12.2, 1.13.1, and 1.14.4 with different method. But still cant reproduce on 1.15.2 and 1.16.1

This happened to me by accident
Basically I died on my friends server and a few minutes later the server crashed.
When the server restarted my items were still on the ground and in my inventory

Now that chunks save whenever in 1.18, its going to be harder to see this effect without a lower render distance. Just giving a heads up

In 22w03a.

Can anyone reproduce in 1.19.2?
Cannot reproduce this in vanilla 1.19.2

Can anyone reproduce in 1.19.3?
This happened to me in 1.19.3 when my computer froze. I got 32 free chests!

Can confirm in 23w03a

Can confirm in 23w04a

Can confirm in 23w06a

This not only can duplicate items but can also destroy items. I lost a chest full of stuff because of this bug because my computer crashed

Can confirm in 23w18a
Can confirm in 1.20

Can confirm in 23w32a
Can confirm in 1.20.5

Couldn't manage to confirm 24w37a

Can confirm in 1.21.4

Affects 25w03a

Affects 25w20a
Just tried this, and managed to dupe a stack of diamonds and a stack of melons.