Changing minecraft playerdata when transferring a saved game (open to LAN)?

Player A created a Single Player game in Minecraft, hosted on his laptop, and opened to LAN at my house with about 4 people in total, including myself, Player B. Player A's laptop was soon struggling with the hosting responsibilities, and we wanted to transfer the saved game to Player B's desktop.

We transferred the file onto my computer, and loaded it. The world seemed to be the same, but when I logged in as Player B, it loaded the player data for Player A; I was in his spot, with his items, and had his experience.

Upon digging, I believe that the reason for this is because the way that the game's playerdata saved his player had something to do with him being the host. Now, since I'm the host, it must be assigning me the player with the previous host attributes.

I have not yet logged him (Player A) in while I (Player B) am hosting on the desktop, but I assume he would have my credentials?

Also, another player, who was on the server last night while Player A was hosting, logged in while I started hosting, and her character was the same; she had the same items, was in the same location as last night, etc.

Why am I logged in as the previous host, Player A, but it seems everyone else has their correct credentials? Is there a way I can change this so that I'm logged in as Player B while hosting?


Each player has their own file in a world's playerdata folder, named by their UUIDs:

enter image description here

These files contain their inventory, location, health, etc.

Note: If it's an older world there may also be a players folder with similar files. Ignore this, it is obsolete and does nothing.

In addition to this storage location, on singleplayer, the player's data is stored in level.dat, always under the name "Player". This file contains other data, and you need to use the editor NBTExplorer in order to view contents and manage the data:

enter image description here

On singleplayer this default "Player" version takes precedence. If it exists, it will always be used first, and it doesn't care who the user is, so long as it's singleplayer. Both of these locations are saved to with your current in-game data.

This means that you can play a world on singleplayer with one account, then give it to a friend (or upload it to a site) for other people to continue where you left off (still on singleplayer), it will use the Player file rather than the one specific to your UUID.

As LAN worlds are created by first launching singleplayer then opening the world to LAN, this Player data in level.dat will be the data of the host, Player A. As you are now opening the world on singleplayer (before opening it to LAN), it is using the data of the Player file, or Player A's data, rather than your own UUID file.

This also means that the data for your character stored in the UUID file has probably been overwritten with Player A's data. Everyone else still has their own UUID file intact, as they've only logged into the world while it is on multiplayer.

To fix this, you'd first need a backup from before the transfer. In level.dat, delete the "Player" section and then log into the world on singleplayer. This should force it to load your UUID file and then re-create the Player section in level.dat based on that, rather than the other way around. Everything should work fine from there.