1. Jason Scheirer
  2. mccity

Commits

Jason Scheirer  committed d048128

Functional parks

  • Participants
  • Parent commits 3ae8011
  • Branches default

Comments (0)

Files changed (1)

File buildings.py

View file
         self.bbox = pymclevel.mclevel.BoundingBox(bbox)
         self.griditem = griditem
         if orientation == -1:
-            orientation = 3 #random.choice([0, 1, 2, 3])
+            orientation = random.choice([0, 1, 2, 3])
         self.orientation = orientation
     # Actually lay down the building onto the map
     @abc.abstractmethod
     @staticmethod
     def can_use_here(width, height, depth):
         return 5 < height < 24
+    def __init__(self, bbox, griditem, orientation=-1):
+        self.datatype = random.randint(0, 2)
+        super(Park, self).__init__(bbox, griditem, orientation)
     def make_building(self, level):
         self.bbox.miny += 1
         self.bbox.maxy = self.bbox.miny + 1
-        level.fillBlocks(self.bbox, materials.Flower)
+        width = self.bbox.maxx - self.bbox.minx
+        depth = self.bbox.maxz - self.bbox.minz
+
+        for gogo in xrange(width * depth / 4):
+            newx = random.randint(self.bbox.minx + 2, self.bbox.maxx - 2)
+            newz = random.randint(self.bbox.minz + 2, self.bbox.maxz - 2)
+            if level.blockAt(newx, self.bbox.miny, newz) == materials.Air.ID:
+                    level.setBlockAt(newx,
+                                     self.bbox.miny,
+                                     newz,
+                                     random.choice([materials.Rose,
+                                                    materials.Flower]).ID)
+        for gogo in xrange(width * depth / 12):
+            newx = random.randint(self.bbox.minx + 2, self.bbox.maxx - 2)
+            newz = random.randint(self.bbox.minz + 2, self.bbox.maxz - 2)
+            if level.blockAt(newx, self.bbox.miny, newz) == materials.Air.ID:
+                mxo = random.randint(-1, 1)
+                mzo = random.randint(-1, 1)
+                level.setBlockAt(newx + mxo,
+                                 self.bbox.miny,
+                                 newz + mzo,
+                                 random.choice([materials.BrownMushroom,
+                                                materials.RedMushroom]).ID)
+                for x in xrange(0, 3):
+                    level.setBlockAt(newx,
+                                     self.bbox.miny + x,
+                                     newz,
+                                     materials.Wood.ID)
+                for x in xrange(random.randint(3, 6)):
+                    for xoff in range(-1, 2):
+                        for zoff in range(-1, 2):
+                            if level.blockAt(newx + xoff,
+                                             self.bbox.miny + x + 1,
+                                             newz + zoff) == materials.Air.ID:
+                                level.setBlockAt(newx + xoff,
+                                                 self.bbox.miny + x + 1,
+                                                 newz + zoff,
+                                                 materials.Leaves.ID)
+                                level.setBlockDataAt(newx + xoff,
+                                                     self.bbox.miny + x + 1,
+                                                     newz + zoff,
+                                                     self.datatype)
 
 @Building.register_building_type
 class Skyscraper(Building):