mojira.dev
MC-697

Default singleplayer player data is always used for players opening world

The bug

For singleplayer worlds the player data is written to the level.dat file as well (called "default player data" in the following) and always used when someone opens the world. This creates the following two unwanted situations.

Cannot start with empty inventory in a world of someone else

Because the default player data is always used you cannot play in the world of someone else with new player data but instead start where the player who last played left and have the same items.

Default player data is used even if player data exists after playing in LAN

When you played in LAN before and an entry in the playerdata folder exists for a player the default player data is used anyways.
Imagine the following: Player 1 hosted the world and player 2 joined. After that player 2 opens the world, even though a player data entry exists he gets player 1's player data (=default player data) which even overwrites player 2's player data entry when he leaves the world.

Outdated default player data is used after loading world on a dedicated server

When a singleplayer world is loaded by a dedicated server and the default player data player joins, their playerdata entry is updated, but their default player data is not. Therefore when they load the world in singleplayer again, they have the old outdated player data.

Possible solution

See this reddit post for a discussion.

Have the game perform these steps when loading a world:

  1. If the default player data exists and for the same UUID a playerdata entry exists, overwrite the default player data with that. This is needed for the case where a singleplayer world was loaded by a dedicated server and therefore the default player data became outdated.
    Then continue with the following steps:

  2. If the default player data exists, but the UUID does not match the UUID of the current player:
    Possibly offer a checkbox to determine whether the default player data should be overwritten by the current player.
    Provide these options:

    • Offer to continue where that player last left

    • Offer to use own player data (in case playerdata entry exists) or otherwise with empty inventory at world spawn

  3. Otherwise: If the default player data exists and the UUID matches the UUID of the current player, use that data

  4. Otherwise: If no default player data exists use the matching playerdata entry or, in case that does not exist, start with an empty inventory at world spawn

Workaround

Keep in mind that this is a bug tracker and not a discussion forum or a help desk. For questions, ask for example on reddit, the Minecraft Forum, or on other platforms.

⚠️ Create a backup of your world before trying the following workaround. Otherwise you might loose data or your world can become corrupted.

The following steps require an NBT editor. Make sure it is up to date and supports changes to NBT structure introduced in the latest versions. You can use for example NBTExplorer version 2.8.0(+).

  1. Open the level.dat file of the world with an NBT editor

  2. Delete the Data > Player entry

  3. Save the file

Linked issues

MC-4600 Lan world progress save failure Resolved MC-13576 Different accounts accessed via the same PC share inventories Resolved MC-17785 Server login inventory copy Resolved MC-44064 "Open To Lan" game will overwrite player data Resolved MC-52929 Player 2 given Player 1's inventory, location, XP Resolved

Comments 44

This is somewhat serious, however I can not confirm because I don't have access to a copy of Minecraft at the moment. It makes sense, however.

Confirmed,only in LAN not multiplayer, they should make separate inventories for lan worlds and separate EnderChests.

Jesper the End

I've seen this once, but that was because the minecraft servers were down and player two was called 'player' that's why he will get the same NBT data from the level.dat instead of it's own player.dat

Is this still a concern in the current Minecraft version? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.

Yes, this is still a concern with LAN play.

(edit: And it concerns all facets of a character to include inventory and enderchests, despite the title)

When a player with a different username logs into Minecraft from my computer and pulls up the world we play together: her inventory, location, enderchest, etc. are all replaced with the original 'main character' values, which then overwrite her .dat file.

I thought that was strange, because she already had a .dat file, but the game rewrote her to be me.

(We lost a ton of enchanted armor she had just made, and duped several silk touch items I had this way. To top it all off, because I was mapping, she ended up displaced about 5km.)

edit: This was around 13w25a (Sorry to not have exact; it was after zombie AI changes and before 1.6 pre-release, but I haven't seen anything regarding SSP/LAN save structure in patch notes, so I bet it's still in live).

34 more comments

Can confirm in 1.19.3

Can confirm in 23w03a

Can confirm in 23w04a

Can confirm in 23w05a

Can confirm in 23w06a

Nathan Fielder

Mask3D_WOLF

(Unassigned)

Confirmed

Platform

Normal

Player

duplication, playerdata

Minecraft 1.4.2, Minecraft 1.4.6, Minecraft 1.7.4, Minecraft 14w05b, Minecraft 14w06b, ..., 23w03a, 23w04a, 23w05a, 23w06a, 1.20.4

Retrieved