create a ChunkBase class with attrs common to FakeChunk, InfdevChunk, and PocketChunk

This commit is contained in:
David Vierra 2011-12-24 07:18:32 -10:00
parent de8dd71ee2
commit 26aacd8265
4 changed files with 12 additions and 9 deletions

View File

@ -585,11 +585,11 @@ def ZeroChunk(height=512):
if z is None:
z = _zeros[height] = _ZeroChunk(height)
return z
class _ZeroChunk(object):
from level import ChunkBase
class _ZeroChunk(ChunkBase):
" a placebo for neighboring-chunk routines "
def compress(self): pass
def load(self): pass
def __init__(self, height=512):
zeroChunk = zeros((16, 16, height), uint8)
whiteLight = zeroChunk + 15;
@ -598,7 +598,8 @@ class _ZeroChunk(object):
self.SkyLight = whiteLight
self.Data = zeroChunk
class InfdevChunk(EntityLevel):
class InfdevChunk(ChunkBase):
""" This is a 16x16xH chunk in an (infinite) world.
The properties Blocks, Data, SkyLight, BlockLight, and Heightmap
are ndarrays containing the respective blocks in the chunk file.

View File

@ -5,6 +5,7 @@ Created on Jul 22, 2011
'''
__all__ = ["MCJavaLevel"]
from mclevelbase import *
from level import MCLevel
import re

View File

@ -772,13 +772,14 @@ class EntityLevel(MCLevel):
return self._fakeEntities[cx, cz]
class FakeChunk(EntityLevel):
class ChunkBase(EntityLevel):
def load(self):pass
def compress(self):pass
def __init__(self):pass
def chunkChanged(self):pass
@property
def materials(self): return self.world.materials
class FakeChunk(ChunkBase):
@property
def HeightMap(self):
if hasattr(self, "_heightMap"):

View File

@ -297,7 +297,7 @@ class PocketChunksFile(object):
coords = ((i % 32, i // 32) for i in indexes)
return coords
from infiniteworld import InfdevChunk, ChunkedLevelMixin
from infiniteworld import ChunkBase, ChunkedLevelMixin
from level import MCLevel
class PocketWorld(ChunkedLevelMixin, MCLevel):
@ -350,7 +350,7 @@ class PocketWorld(ChunkedLevelMixin, MCLevel):
if cx>31 or cz>31 or cx < 0 or cz < 0: return False
return self.chunkFile.getOffset(cx,cz) != 0
class PocketChunk(InfdevChunk):
class PocketChunk(ChunkBase):
Blocks = Data = SkyLight = BlockLight = None
HeightMap = FakeChunk.HeightMap