Commits

Jason Scheirer committed 5b86be2

Make stairs respect building orientation

  • Participants
  • Parent commits d8dcf5d

Comments (0)

Files changed (1)

                         level.setBlockDataAt(xoffset + 1, yoffset, zoffset, 1)
                 centerx = floorbox.minx + ((floorbox.maxx - floorbox.minx) / 2)
                 centerz = floorbox.minz + ((floorbox.maxz - floorbox.minz) / 2)
-                for zoffset in xrange(4):
-                    level.setBlockAt(centerx,
-                                     yoffset + 1,
-                                     centerz + zoffset - 2,
-                                     Air.ID)
-                    level.setBlockAt(centerx,
-                                     yoffset - (zoffset - 1),
-                                     centerz + zoffset - 2,
+
+                offseta, offsetb = [0, 0, 0, 0], range(-2, 2)
+
+                if self.orientation in (0, 2):
+                    offsetb = reversed(offsetb)
+                if self.orientation in (2, 3):
+                    xo, zo = offseta, offsetb
+                else:
+                    zo, xo = offseta, offsetb
+
+                for yo, (xoffset, zoffset) in enumerate(zip(xo, zo)):
+                    for eyo in xrange(yo):
+                        level.setBlockAt(centerx + xoffset,
+                                         yoffset + 1 - eyo,
+                                         centerz + zoffset,
+                                         Air.ID)
+                    level.setBlockAt(centerx + xoffset,
+                                     yoffset - (yo - 1),
+                                     centerz + zoffset,
                                      Stairs.ID)
-                    level.setBlockDataAt(centerx,
-                                         yoffset - (zoffset - 1),
-                                         centerz + zoffset - 2,
-                                         3)
+                    level.setBlockDataAt(centerx + xoffset,
+                                         yoffset - (yo - 1),
+                                         centerz + zoffset,
+                                         self.orientation)
         # Add a rooftop guard block
         newbbox.maxy += 1
         newbbox.miny += 1