forked from mikemccllstr/mikemccllstr-python-minecraft
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gf_drawbuilding.py
executable file
·44 lines (40 loc) · 1.77 KB
/
gf_drawbuilding.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
#! /usr/bin/python
import mcpi.minecraft as minecraft
import mcpi.block as block
import server
import random
""" draw a building
@author: goldfish"""
def drawBuilding( locx, locy, locz, floors, width, depth, floorheight, wallmaterial, floormaterial ):
topx = locx+width
topy = locy+((floorheight+1)*floors)
topz = locz+depth
#draw building shell
mc.setBlocks( locx, locy, locz, topx, topy, topz, wallmaterial )
mc.setBlocks( locx+1, locy+1, locz+1, topx-1, topy-1, topz-1, block.AIR )
#draw floors
if( floors > 1 ):
for i in range( floors -1 ):
floorYloc = locy+( (floorheight+1)*(i+1) )
mc.setBlocks( locx+1, floorYloc, locz+1, topx-1, floorYloc, topz-1, floormaterial )
#draw door
doorloc = random.randint( 1, width-2 )
mc.setBlock( locx, locy+1, locz+doorloc, block.AIR )
mc.setBlock( locx, locy+2, locz+doorloc, block.AIR )
#draw front windows
if( floors > 1 ):
for i in range( floors-1 ):
windowYloc = locy+2+( (floorheight+1)*(i+1) )
for j in range( floorheight-1 ):
mc.setBlocks( locx, windowYloc+j , locz+1, locx, windowYloc+j, locz+(width-1), block.GLASS_PANE )
#draw back windows
if( floors > 1 ):
for i in range( floors-1 ):
windowYloc = locy+2+( (floorheight+1)*(i+1) )
for j in range( floorheight-1 ):
mc.setBlocks( locx+depth, windowYloc+j , locz+1, locx+depth, windowYloc+j, locz+(width-1), block.GLASS_PANE )
#connect levels with ladder
#mc.setBlocks( topx-1, locy+1, topz-1, topx-1, topy-1, topz-1, block.LADDER )
if __name__ == "__main__":
mc = minecraft.Minecraft.create( server.address )
drawBuilding( 0, 20, 0, 5, 25, 5, 3, block.STONE, block.WOOD_PLANKS )