Skip to content

Commit

Permalink
Merge pull request #6 from Fenixin/empty-region-files
Browse files Browse the repository at this point in the history
Add special case for empty region files.
  • Loading branch information
MidnightLightning committed Sep 8, 2011
2 parents adeffef + f2732b1 commit 2e23e9b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions nbt/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,17 @@ def __init__(self, filename=None, fileobj=None):
self.extents = None
if self.file:
self.size = getsize(self.filename)
self.parse_header()
self.parse_chunk_headers()
if self.size == 0:
# Some region files seems to have 0 bytes of size, and
# Minecraft handle them without problems. Take them
# as empty region files.
for x in range(32):
for z in range(32):
self.header[x,z] = (0, 0, 0, self.STATUS_CHUNK_NOT_CREATED)
self.parse_chunk_headers()
else:
self.parse_header()
self.parse_chunk_headers()


def __del__(self):
Expand Down

0 comments on commit 2e23e9b

Please sign in to comment.