-
Notifications
You must be signed in to change notification settings - Fork 11
/
buildmaps.py
executable file
·43 lines (33 loc) · 1.43 KB
/
buildmaps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python
import logging
logging.basicConfig(level=logging.WARNING)
import os
from utils import cleanmkdir
from pymclevel import mclevel
import argparse
def center(name):
"""Returns the center chunk values for a given region."""
worlddir = os.path.join('worlds', name, 'level.dat')
world = mclevel.fromFile(worlddir)
bounds = world.bounds
centerx = bounds.origin[0]+bounds.size[0]/2
centerz = bounds.origin[2]+bounds.size[2]/2
bounds = None
world = None
return centerx/16, centerz/16
def main():
"""The main routine."""
parser = argparse.ArgumentParser(description='Builds c10t maps for regions.')
parser.add_argument('--name', required=True, type=str, help='name of region to be mapped')
parser.add_argument('--gmaps', action='store_true', help='generate Google Maps')
args = parser.parse_args()
print "Building %smaps for %s..." % ('Google ' if args.gmaps else '', args.name)
(centerx, centerz) = center(args.name)
if args.gmaps:
cleanmkdir(os.path.join('maps', args.name))
command = 'C10T=../c10t/build/c10t ../c10t/scripts/google-api/google-api.sh -w worlds/%s -o maps/%s -O "-M 2048 -z --center %d,%d"' % (args.name, args.name, centerx, centerz)
else:
command = '../c10t/build/c10t -M 2048 -z -w worlds/%s -o maps/%s.png --center %d,%d' % (args.name, args.name, centerx, centerz)
os.system(command)
if __name__ == '__main__':
main()