forked from jfmario/mcpi_collection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_building.py
50 lines (32 loc) · 970 Bytes
/
load_building.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
44
45
46
47
48
49
50
'''
This file creates a saved building where you are.
python load_building.py <name>
'''
import argparse, json, os
from mcpi.minecraft import Minecraft
parser = argparse.ArgumentParser ()
parser.add_argument ( "name", metavar='N', type=str,
help="The name of the building you want to recreate." )
args = parser.parse_args ()
mc = Minecraft.create ()
def build_structure ( x, y, z, structure ):
x_start = x
z_start = z
for row in structure:
for column in row:
for block in column:
mc.setBlock ( x, y, z, block )
z += 1
x += 1
z = z_start
y += 1
x = x_start
full_filename = os.path.join ( os.path.dirname ( __file__ ), 'data',
'structures', args.name + '.json' )
with open ( full_filename, 'r' ) as f:
structure = json.loads ( f.read () )
pos = mc.player.getTilePos ()
x = pos.x
y = pos.y
z = pos.z
build_structure ( x, y, z, structure )