Commits

Jason Scheirer  committed e03b393

Initial building doors

  • Participants
  • Parent commits 0a61a2d

Comments (0)

Files changed (1)

File buildings.py

     def make_building(self, level):
         Glass = materials.Glass
         Air = materials.Air
-        Lighting = materials.Glowstone
+        Lighting = materials.Stone
         Torch = materials.Torch
         Stairs = (materials.StoneStairs
                         if self.flooring is materials.Stone
                         else materials.WoodenStairs)
+        Door = materials.WoodenDoor
         bbox = pymclevel.mclevel.BoundingBox(self.bbox)
         level.fillBlocks(bbox, Air)
         bbox.miny += 1 # Meet sidewalk level
         # Make corners of building solid
         for edge in (northwall, southwall, eastwall, westwall):
             level.fillBlocks(edge, self.stone)
+        centerx = bbox.minx + ((bbox.maxx - bbox.minx) / 2)
+        centerz = bbox.minz + ((bbox.maxz - bbox.minz) / 2)
         # Add a floor for each story
         for story in xrange(stories + 1):
             newbbox = pymclevel.mclevel.BoundingBox(bbox)
                 lightbbox.maxy = lightbbox.miny + 1
                 yoffset = lightbbox.miny
                 for xoffset in xrange(lightbbox.minx + 2, lightbbox.maxx - 2, 3):
-                    for zoffset in xrange(lightbbox.minz + 2, lightbbox.maxz -2, 3):
+                    for zoffset in xrange(lightbbox.minz + 2, lightbbox.maxz - 2, 3):
                         level.setBlockAt(xoffset, yoffset, zoffset, Lighting.ID)
+                        level.setBlockLightAt(xoffset, yoffset, zoffset, 15)
                         level.setBlockAt(xoffset, yoffset, zoffset - 1, Torch.ID)
                         level.setBlockDataAt(xoffset, yoffset, zoffset - 1, 4)
                         level.setBlockAt(xoffset, yoffset, zoffset + 1, Torch.ID)
                         level.setBlockDataAt(xoffset - 1, yoffset, zoffset, 2)
                         level.setBlockAt(xoffset + 1, yoffset, zoffset, Torch.ID)
                         level.setBlockDataAt(xoffset + 1, yoffset, zoffset, 1)
-                centerx = floorbox.minx + ((floorbox.maxx - floorbox.minx) / 2)
-                centerz = floorbox.minz + ((floorbox.maxz - floorbox.minz) / 2)
 
                 offseta, offsetb = [0, 0, 0, 0], range(-2, 2)
 
         floorbox.maxy += 1
         level.fillBlocks(newbbox, self.stone)
         level.fillBlocks(floorbox, Air)
-
+        # And an opening for the door
+        if self.orientation in (2, 3):
+            px, pz = centerx, bbox.minz if self.orientation == 2 else bbox.maxz - 1
+        else:
+            px, pz = bbox.minx if self.orientation == 0 else bbox.maxx, centerz
+        for yoffset in (1, 2):
+            #print (px, bbox.miny + yoffset, pz, Lighting.ID)
+            level.setBlockAt(px, bbox.miny + yoffset, pz, Door.ID)
+            level.setBlockDataAt(px,
+                                 bbox.miny + yoffset,
+                                 pz,
+                                 (8 if yoffset == 2 else 0))
 
 class Buildings(object):
     def __init__(self, grid, origin, node_length, level):