Is there a simple tool for migrating inventory to another world for all players on a vanilla server? [closed]

Solution 1:

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.

Solution 2:

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.

Solution 3:

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.