-
Notifications
You must be signed in to change notification settings - Fork 0
/
blocks.txt
47 lines (38 loc) · 1.34 KB
/
blocks.txt
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
44
45
46
#!/usr/bin/env python2
#import pdb
#pdb.set_trace()
import mclevel
from materials import materials
from BroadBandData.wrangler import blockify_geojson
GRASS = 2
SEA = 9
BBSPEEDS = [materials.Brick.ID, materials.BlockofGold.ID ,materials.JackOLantern.ID]
BASE_MAP_HEIGHT = 10
level = mclevel.fromFile("WaterWorldFinal/level.dat")
data = blockify_geojson("BroadBandData/city_speeds.json")
#load the text map of the uk
tm = open('UK.txt', 'r')
uk = tm.readlines()
# iterate through the lines
for z, row in enumerate(uk):
# iterate through the characters in the line
row = row.strip().replace(',','')
for charpos, char in enumerate(row):
mcx = len(row) - charpos
speeddata = data.get(len(row) - charpos, {}).get(len(uk) - z, {})
if speeddata:
speed = int(round(speeddata[0]['bbspeed']/1000))
block_type = BBSPEEDS[0]
for height in range(1, speed):
if height > 4:
block_type = BBSPEEDS[1]
if height > 15:
block_type = BBSPEEDS[2]
level.setBlockAt(mcx + 175, BASE_MAP_HEIGHT + height, z - 281, block_type)
print 'data at' , charpos, z, 'for minecraft', mcx, z
else:
level.setBlockAt(mcx + 175, BASE_MAP_HEIGHT, z - 281, (char == '1') and GRASS or SEA)
print mcx, z
level.setPlayerSpawnPosition((mcx,30,z))
level.setPlayerPosition((mcx,30,z))
level.saveInPlace()