Skip to content

Instantly share code, notes, and snippets.

@idiosync
Created March 29, 2012 03:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save idiosync/2232990 to your computer and use it in GitHub Desktop.
Save idiosync/2232990 to your computer and use it in GitHub Desktop.
Script to generate terrain and render maps from Minecraft seeds.
#!/bin/bash
#set -e
USAGE="Usage: ${0} [options]
Uses mcexplore.py to explore a seed, and c10t to make a number of maps of that seed.
Requires:
mcexplore.py (https://gist.github.com/854679)
c10t (https://github.com/udoprog/c10t)
advdef (http://advancemame.sourceforge.net/comp-readme.html)
imagemagick (http://www.imagemagick.org/script/index.php)
Notes:
All of the required tools are assumed to be in your path
Advdef and imagemagick are generally packaged for your distro.
Advdef is only there to squeeze some large PNG files down, and
you can just comment out the one line that uses it if you want
to avoid the requirement.
Options:
-h Display this usage information
-r SERVER_ROOT Specify the folder that contains your Minecraft server (default: ~/minecraft/)
-p SERVER_PORT Set the port your server will run on while exploring (default: 25501)
-f SEED_FILE Specify a file containing one seed per line to explore sequentially
-s SEED Specify a seed (mutually exclusive with -f) (default: randomized)
-l LENGTH Set the length in regions of a side of the square map that's explored (default: 4)
-o OUTPUT_PATH Specify the path to store map images (creates subfolder per seed) (default: ~/mcmaps)
"
SERVER=~/minecraft
PORT="25501"
SEED=""
SEEDFILE=""
LENGTH=4
OUTPUTPATH=~/minecraft/mcmaps/1.2.4
while getopts “hr:p:f:s:l:o:” OPTION
do
case $OPTION in
h) echo "$USAGE" ; exit 1 ;;
r) SERVER=$OPTARG ;;
p) PORT=$OPTARG ;;
f) SEEDFILE=$OPTARG ;;
s) SEED=$OPTARG ;;
l) LENGTH=$OPTARG ;;
o) OUTPUTPATH=$OPTARG ;;
esac
done
randomseed() {
dd if=/dev/urandom 2>&1 bs=32 count=1 | md5sum | cut -d " " -f 1
}
[ "${SEED}" != "" ] && [ "${SEEDFILE}" != "" ] && echo "Please only specify either the seed, or the seed file." && exit 1
[ "${SEEDFILE}" != "" ] && [ ! -f "${SEEDFILE}" ] && echo "${SEEDFILE} not found." && exit 1
[ "${SEEDFILE}" == "-" ] && SEEDFILE="/dev/stdin"
[ "${SEED}" == "" ] && [ "${SEEDFILE}" == "" ] && SEED=$(randomseed)
PROPERTIES="level-name=world
allow-nether=false
view-distance=10
spawn-monsters=false
online-mode=false
difficulty=1
gamemode=0
spawn-animals=false
max-players=20
server-ip=
pvp=true
level-seed=SEED
server-port=PORT
allow-flight=false
white-list=false
motd=A Minecraft Server"
genmap() {
SEED=${1}
OUTPUT="${OUTPUTPATH}/${SEED}"
pushd "${SERVER}"
[ -d world ] && rm -rf world
echo "${PROPERTIES}" | sed "s|SEED|${SEED}|;s|PORT|${PORT}|" > server.properties
echo "Initializing server [${SEED}]"
echo 'stop' | java -jar minecraft_server.jar nogui
echo "Exploring world [${SEED}]"
~/minecraft/mcexplore.py -r "${LENGTH}" "${LENGTH}"
popd
mkdir -p ${OUTPUT}
cp ${SERVER}/world/level.dat ${OUTPUT}
echo "Rendering maps [${SEED}]"
echo "mcmap "${SERVER}"/world "${OUTPUT}"/iso.png"
mcmap ${SERVER}/world
cp ${SERVER}/output.png ${OUTPUT}/iso.png
advdef -z -4 ${SERVER}/output.png
mv ${SERVER}/output.png ${OUTPUTPATH}/${SEED}.png
}
if [ "${SEEDFILE}" != "" ] ; then
for SEED in $(cat "${SEEDFILE}") ; do
genmap "${SEED}"
done
else
genmap "${SEED}"
fi
@micuit-cuit
Copy link

super mais sa serre a quoi
?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment