Take the 2-minute tour ×
Arqade is a question and answer site for passionate videogamers on all platforms. It's 100% free, no registration required.

With all of the recent biome generation changes, I've found myself generating a lot of new worlds lately, and once 1.9 hits I'll do it again.

When I restart the world on my server I would the inventories of all my players to be migrated over to the new world. This way people who have already been playing for quite some time on my server won't lose everything, and can bring their gold, diamonds, cookies, etc. to ease the transition. I'm wary of simply copying player data over because if it includes player position there's a high chance of players appearing in places they shouldn't. (Like in solid ground.)

So I'm looking for an automated tool that I can run once before the players sign in to the new world that copies over all player inventory and nothing else. Note that I'm just running a vanilla server, and would like to continue doing so. If this tool doesn't exist, is there a manual way to do so?

Edit: If I get a good enough response and someone knows how to migrate inventory manually, I just might code the tool myself and put it somewhere for everyone.

share|improve this question
    
IIRC, There's a failsafe now to stop people from spawning in walls so it should be safe to copy over all player data. I don't think it is possible to separate inventory from the rest of a players data, but you could just TP everyone to a bot that joins fresh at the spawn point. –  John the Green Sep 21 '11 at 19:06
    
@John - Not spawning in a wall is good, but if your giant underground base turned into a massive, unlit cave system—or the middle of a ravine—overnight, you wouldn't be very happy. –  dlras2 Sep 21 '11 at 19:09
    
You're starting over so the base would be gone anyway, right? That's why I suggest TP-ing. Don't copy one person's data - TP everyone to this person - copy this person's data - TP him to someone who just TP-ed to him (and therefore spawn). –  John the Green Sep 21 '11 at 19:13
    
@John - Yes the base would be gone, but I don't want players appearing, dying, and losing all their inventory. I want them to spawn like normal for a new world, but with their items from their past life. The TP method you're suggesting might work, but is infeasible for more than a few players. –  dlras2 Sep 21 '11 at 19:16
1  
@John - Peaceful wouldn't solve the problem of spawning a hundred meters above the bottom of a ravine... –  dlras2 Sep 21 '11 at 19:27
show 1 more comment

5 Answers

up vote 12 down vote accepted

player.dat is a gzipped file. If you unzip it, you can find the Pos field (string "Pos" and then 32 bytes of coordinates). So, you need to change those bytes.

I used Perl for this purpose:

process_file.sh

#!/bin/bash 
FILE_NAME_BASE="${1%.dat}"  
echo "Processing ${FILE_NAME_BASE}..."  
mv "${FILE_NAME_BASE}.dat" "${FILE_NAME_BASE}.gz"  
gunzip "${FILE_NAME_BASE}.gz"  
perl -pe 's/Pos[\x{00}-\x{ff}]{32}/Pos\x{06}\x{00}\x{00}\x{00}\x{03}\x{c0}\x{88}\x{c4}\x{00}\x{00}\x{00}\x{00}\x{00}\x{40}\x{51}\x{67}\x{ae}\x{14}\x{80}\x{00}\x{00}\x{c0}\x{b3}\x{e4}\x{80}\x{00}\x{00}\x{00}\x{00}\x{02}\x{00}\x{0a}/' < "${FILE_NAME_BASE}" >   "${FILE_NAME_BASE}.out"  
mv "${FILE_NAME_BASE}.out" "${FILE_NAME_BASE}"  
gzip "${FILE_NAME_BASE}"  
mv "${FILE_NAME_BASE}.gz" "${FILE_NAME_BASE}.dat"  

process_all.sh

#!/bin/bash  
find . -name "*.dat" -exec ./process_file.sh \{\} \;  
echo "Done."  

If you run process_all.sh in folder world/players, it changes the Pos field of all players to 06 00 00 00 03 c0 88 c4 00 00 00 00 00 40 51 67 ae 14 80 00 00 c0 b3 e4 80 00 00 00 00 02 00 0a (hexadecimal). Of course, you can change these values to move players to another point.

share|improve this answer
add comment

This method is a little unorthodox, but if you can pull it off it'll be awesome.

Step 1: Have all your players build an ark. Inform them that any person or object not on the ark when the world ends will be left behind. Allow them to bring their chests too. In case user inventory doesn't copy over correctly, instruct your followers--er, I mean players--to place their belongings in a chest.

Step 2: Create a new world, using a world seed with an ocean biome near spawn. If the 'ark' idea doesn't pan out, this will give the players a safe landing. If the ark is a success, it'll add to the effect.

Step 3: Use the map editor program MCEdit to copy the entire ark into the new world. You do this by selecting the area, exporting it as a schematic, then importing it into the new world. If you built the ark at sea level, it should copy quite seamlessly into any ocean area near your spawn.

share|improve this answer
4  
This is just epic... –  dlras2 Sep 23 '11 at 20:19
add comment

Copy the files manually, and then there is a command line tool that it looks like you might be able to set up to go through each file and change that players spawn point as well as move that player TO that spawn point.

I have not tested this tool myself, but its feature list fits the bill for your situation: http://www.electricmonk.nl/Programmings/MCPlayerEdit

Hope this helps.

share|improve this answer
add comment

In the world/player file you can copy and paste the .dat files into your new world player file. That way you will be able to keep the inventory but I'm not so sure that your players will spawn at the spawn because their last coordinates are recorded.

share|improve this answer
add comment

If you're running bukkit then you can use multiverse and stargates to link your maps/worlds together and allow (tell?) people to move their own stuff.

That's the solution I'm using, and I'll grab another plugin (I forget the name) to modify glass blocks and other fragile objects to drop their own item so people can move parts of their structures too.

edit

I see you said you're running a vanilla server, but maps are compatible between vanilla and bukkit so it might be worthwhile for you to use bukkit for a week to allow people to move their items.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.