Zenity-fy this project.

Working with python and the args for this project is rather
clumsy, so I'm adding a zenity wrapper that will aid people
to find the right folders easily and start the conversion
process. This should make it a lot easier to do the conversion
for people.
This commit is contained in:
Auke Kok 2016-03-26 21:53:47 -07:00
parent 6ab33ce34f
commit fccd3a4525
3 changed files with 60 additions and 0 deletions

22
entities.py Normal file
View File

@ -0,0 +1,22 @@
from itemstack import *
#If you wish to add more entities, then...
# To print out pre and post-conversion entity information uncomment line 237 (ish) in blocks.py (search for 'EntityInfo' to locate it)
def convert_frame(e):
from pprint import pprint
pprint(e)
# must read attribs and translate to entities we know from map_content.txt
content = e.get("Item")
x = e.get("TileX")
y = e.get("TileY")
z = e.get("TileZ")
item = e.get("Item")
if item:
content = item.get("id")
print(content)
return "xdecor:itemframe", None, (None, None)
else:
print("empty item frame")
return "xdecor:itemframe", None, (None, None)
e_convert = {"itemframe": convert_frame}

0
mcimport.py Executable file → Normal file
View File

38
mcimport.sh Executable file
View File

@ -0,0 +1,38 @@
#!/bin/bash
# shell wrapper around mcimport.py
# meant to assist users and provide an easy way to select input and output folders, and
# assure that the python script runs from the correct location.
cd `dirname $0`
if [ ! -f map_content.txt ]; then
zenity --info --text "Unable to locate \"map_content.txt\" file - this is a critical error, and this program is unable to continue."
exit 1
fi
while true; do
IN=`cd ~/.minecraft/saves; zenity --file-selection --directory --filename="New World"`
if [ "`basename "$IN"`" == "level.dat" ]; then
IN="`dirname "$IN"`"
fi
if [ ! -d "$IN" ]; then
zenity --info --text "The chosen entry \"$IN\" is not a folder. Try selecting a folder that has a \"level.dat\" file inside."
exit 1
fi
break
done
OUT=`zenity --entry --entry-text="$(basename "$IN")" --text="Type the output name of the converted world:"`
if [ -d "${HOME}/.minetest/worlds/$OUT" ]; then
if ! `zenity --question --title="Overwrite existing world?" --text="The world \"$OUT\" already exists, do you want to overwrite it?" --default-cancel`; then
exit 1
fi
rm -rf "${HOME}/.minetest/worlds/$OUT"
fi
zenity --info --width=800 --title="Conversion in progress" --text="The conversion is now running and make take a *very* long time to finish. Do not be alarmed by output lines that show \"Unknown Minecraft Block\" messages, this is normal and can usually be ignored without issues. You can safely close this window." &
python3 mcimport.py "$IN" "${HOME}/.minetest/worlds/$OUT"