blocksForChunk, lightsForChunk, skyLightForChunk, dataForChunk, heightMapForChunk removed. use the corresponding chunk attributes instead
This commit is contained in:
parent
40fe19f663
commit
83c75757f6
67
mclevel.py
67
mclevel.py
@ -490,10 +490,10 @@ class MCLevel(object):
|
|||||||
f = FakeChunk()
|
f = FakeChunk()
|
||||||
f.world = self;
|
f.world = self;
|
||||||
|
|
||||||
f.Blocks = self.blocksForChunk(cx, cz)
|
f.Blocks = self.fakeBlocksForChunk(cx, cz)
|
||||||
|
|
||||||
|
|
||||||
f.Data = self.dataForChunk(cx, cz)
|
f.Data = self.fakeDataForChunk(cx, cz)
|
||||||
|
|
||||||
whiteLight = zeros_like(f.Blocks);
|
whiteLight = zeros_like(f.Blocks);
|
||||||
whiteLight[:] = 15;
|
whiteLight[:] = 15;
|
||||||
@ -518,12 +518,8 @@ class MCLevel(object):
|
|||||||
def chunkIsLoaded(self, cx, cz):
|
def chunkIsLoaded(self, cx, cz):
|
||||||
return self.containsChunk(cx,cz)
|
return self.containsChunk(cx,cz)
|
||||||
|
|
||||||
def lightsForChunk(self, cx, cz):
|
|
||||||
return None;
|
|
||||||
def skyLightForChunk(self, cx, cz):
|
|
||||||
return None;
|
|
||||||
|
|
||||||
def blocksForChunk(self, cx, cz):
|
def fakeBlocksForChunk(self, cx, cz):
|
||||||
#return a 16x16xH block array for rendering. Alpha levels can
|
#return a 16x16xH block array for rendering. Alpha levels can
|
||||||
#just return the chunk data. other levels need to reorder the
|
#just return the chunk data. other levels need to reorder the
|
||||||
#indices and return a slice of the blocks.
|
#indices and return a slice of the blocks.
|
||||||
@ -536,7 +532,8 @@ class MCLevel(object):
|
|||||||
# b = resize(b, (16,16,h) )
|
# b = resize(b, (16,16,h) )
|
||||||
return b;
|
return b;
|
||||||
|
|
||||||
def dataForChunk(self, cx, cz):
|
def fakeDataForChunk(self, cx, cz):
|
||||||
|
#Data is emulated for flexibility
|
||||||
cxOff = cx << 4
|
cxOff = cx << 4
|
||||||
czOff = cz << 4
|
czOff = cz << 4
|
||||||
|
|
||||||
@ -2215,22 +2212,6 @@ class MCInfdevOldLevel(MCLevel):
|
|||||||
return self.chunkFilename(cx,cz)
|
return self.chunkFilename(cx,cz)
|
||||||
#return os.path.join( self.worldDir, self.chunkFilename(cx, cz) )
|
#return os.path.join( self.worldDir, self.chunkFilename(cx, cz) )
|
||||||
|
|
||||||
def blocksForChunk(self, cx, cz):
|
|
||||||
return self.getChunk(cx, cz).Blocks;
|
|
||||||
|
|
||||||
def lightsForChunk(self, cx, cz):
|
|
||||||
return self.getChunk(cx, cz).BlockLight;
|
|
||||||
|
|
||||||
def heightMapForChunk(self, cx, cz):
|
|
||||||
return self.getChunk(cx, cz).HeightMap;
|
|
||||||
|
|
||||||
def skyLightForChunk(self, cx, cz):
|
|
||||||
return self.getChunk(cx, cz).SkyLight;
|
|
||||||
|
|
||||||
def blockDataForChunk(self, cx, cz):
|
|
||||||
return self.getChunk(cx, cz).Data;
|
|
||||||
|
|
||||||
|
|
||||||
def blockLightAt(self, x, y, z):
|
def blockLightAt(self, x, y, z):
|
||||||
if y < 0 or y >= self.Height: return 0
|
if y < 0 or y >= self.Height: return 0
|
||||||
zc=z >> 4
|
zc=z >> 4
|
||||||
@ -2238,7 +2219,9 @@ class MCInfdevOldLevel(MCLevel):
|
|||||||
|
|
||||||
xInChunk = x&0xf;
|
xInChunk = x&0xf;
|
||||||
zInChunk = z&0xf;
|
zInChunk = z&0xf;
|
||||||
return self.lightsForChunk(xc,zc)[xInChunk,zInChunk,y]
|
ch = self.getChunk(xc,zc)
|
||||||
|
|
||||||
|
return ch.BlockLight[xInChunk,zInChunk,y]
|
||||||
|
|
||||||
|
|
||||||
def setBlockLightAt(self, x, y, z, newLight):
|
def setBlockLightAt(self, x, y, z, newLight):
|
||||||
@ -2261,7 +2244,9 @@ class MCInfdevOldLevel(MCLevel):
|
|||||||
xInChunk = x&0xf;
|
xInChunk = x&0xf;
|
||||||
zInChunk = z&0xf;
|
zInChunk = z&0xf;
|
||||||
|
|
||||||
return self.blockDataForChunk(xc,zc)[xInChunk,zInChunk,y]
|
ch = self.getChunk(xc,zc)
|
||||||
|
|
||||||
|
return ch.Data[xInChunk,zInChunk,y]
|
||||||
|
|
||||||
|
|
||||||
def setBlockDataAt(self, x,y,z, newdata):
|
def setBlockDataAt(self, x,y,z, newdata):
|
||||||
@ -2286,7 +2271,8 @@ class MCInfdevOldLevel(MCLevel):
|
|||||||
xInChunk = x & 0xf;
|
xInChunk = x & 0xf;
|
||||||
zInChunk = z & 0xf;
|
zInChunk = z & 0xf;
|
||||||
|
|
||||||
return self.blocksForChunk(xc,zc)[xInChunk, zInChunk, y]
|
ch = self.getChunk(xc,zc)
|
||||||
|
return ch.Blocks[xInChunk, zInChunk, y]
|
||||||
|
|
||||||
def setBlockAt(self, x, y, z, blockID):
|
def setBlockAt(self, x, y, z, blockID):
|
||||||
"""returns 0 for blocks outside the loadable chunks. automatically loads chunks."""
|
"""returns 0 for blocks outside the loadable chunks. automatically loads chunks."""
|
||||||
@ -2311,7 +2297,9 @@ class MCInfdevOldLevel(MCLevel):
|
|||||||
xInChunk = x & 0xf;
|
xInChunk = x & 0xf;
|
||||||
zInChunk = z & 0xf
|
zInChunk = z & 0xf
|
||||||
|
|
||||||
return self.skyLightForChunk(xc,zc)[xInChunk, zInChunk, y]
|
ch = self.getChunk(xc,zc)
|
||||||
|
|
||||||
|
return ch.SkyLight[xInChunk, zInChunk, y]
|
||||||
|
|
||||||
|
|
||||||
def setSkylightAt(self, x, y, z, lightValue):
|
def setSkylightAt(self, x, y, z, lightValue):
|
||||||
@ -2336,8 +2324,11 @@ class MCInfdevOldLevel(MCLevel):
|
|||||||
zc=z>>4
|
zc=z>>4
|
||||||
xc=x>>4
|
xc=x>>4
|
||||||
|
|
||||||
heightMap = self.heightMapForChunk(xc,zc)
|
ch = self.getChunk(xc,zc)
|
||||||
return heightMap[z&0xf][x&0xf];
|
|
||||||
|
heightMap = ch.HeightMap
|
||||||
|
|
||||||
|
return heightMap[zc,xc];
|
||||||
#the heightmap is ordered differently because in minecraft it is a flat array
|
#the heightmap is ordered differently because in minecraft it is a flat array
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -2891,11 +2882,11 @@ class MCInfdevOldLevel(MCLevel):
|
|||||||
newMinZ = localMinZ + (cz << 4) - box.minz
|
newMinZ = localMinZ + (cz << 4) - box.minz
|
||||||
newMaxZ = localMaxZ + (cz << 4) - box.minz
|
newMaxZ = localMaxZ + (cz << 4) - box.minz
|
||||||
try:
|
try:
|
||||||
blocks = level.blocksForChunk(cx, cz)
|
ch = level.getChunk(cx, cz)
|
||||||
except ChunkNotPresent, e:
|
except ChunkNotPresent, e:
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
yield (level.getChunk(cx, cz),
|
yield (ch,
|
||||||
(slice(localMinX,localMaxX),slice(localMinZ,localMaxZ),slice(box.miny,box.maxy)),
|
(slice(localMinX,localMaxX),slice(localMinZ,localMaxZ),slice(box.miny,box.maxy)),
|
||||||
(newMinX, 0, newMinZ))
|
(newMinX, 0, newMinZ))
|
||||||
|
|
||||||
@ -3353,14 +3344,8 @@ class ZipSchematic (MCInfdevOldLevel):
|
|||||||
|
|
||||||
class MCIndevLevel(MCLevel):
|
class MCIndevLevel(MCLevel):
|
||||||
|
|
||||||
""" IMPORTANT: self.Blocks and self.Data are indexed with [y,z,x]
|
""" IMPORTANT: self.Blocks and self.Data are indexed with [x,z,y] via axis
|
||||||
because that's how the array appears"""
|
swapping to be consistent with infinite levels."""
|
||||||
#def neighborsAndBlock(self, x, y, z):
|
|
||||||
## def blocksForChunk(self, cx, cz):
|
|
||||||
## return self.Blocks[:,
|
|
||||||
## cz*self.chunkSize:cz*self.chunkSize+self.chunkSize,
|
|
||||||
## cx*self.chunkSize:cx*self.chunkSize+self.chunkSize]
|
|
||||||
##
|
|
||||||
|
|
||||||
def setPlayerSpawnPosition(self, pos):
|
def setPlayerSpawnPosition(self, pos):
|
||||||
assert len(pos) == 3
|
assert len(pos) == 3
|
||||||
@ -3724,7 +3709,6 @@ def testJavaLevels():
|
|||||||
indevlevel = MCLevel.fromFile("hell.mclevel")
|
indevlevel = MCLevel.fromFile("hell.mclevel")
|
||||||
|
|
||||||
creativelevel = MCLevel.fromFile("Dojo_64_64_128.dat");
|
creativelevel = MCLevel.fromFile("Dojo_64_64_128.dat");
|
||||||
creativelevel.blocksForChunk(0,0);
|
|
||||||
creativelevel.copyBlocksFrom(indevlevel, BoundingBox((0,0,0), (64,64,64,)), (0,0,0) )
|
creativelevel.copyBlocksFrom(indevlevel, BoundingBox((0,0,0), (64,64,64,)), (0,0,0) )
|
||||||
assert(all(indevlevel.Blocks[0:64,0:64,0:64] == creativelevel.Blocks[0:64,0:64,0:64]))
|
assert(all(indevlevel.Blocks[0:64,0:64,0:64] == creativelevel.Blocks[0:64,0:64,0:64]))
|
||||||
|
|
||||||
@ -3736,7 +3720,6 @@ def testIndevLevels():
|
|||||||
|
|
||||||
srclevel = MCLevel.fromFile("hell.mclevel")
|
srclevel = MCLevel.fromFile("hell.mclevel")
|
||||||
indevlevel = MCLevel.fromFile("hueg.mclevel")
|
indevlevel = MCLevel.fromFile("hueg.mclevel")
|
||||||
indevlevel.blocksForChunk(0,0);
|
|
||||||
indevlevel.copyBlocksFrom(srclevel, BoundingBox((0,0,0), (64,64,64,)), (0,0,0) )
|
indevlevel.copyBlocksFrom(srclevel, BoundingBox((0,0,0), (64,64,64,)), (0,0,0) )
|
||||||
assert(all(indevlevel.Blocks[0:64,0:64,0:64] == srclevel.Blocks[0:64,0:64,0:64]))
|
assert(all(indevlevel.Blocks[0:64,0:64,0:64] == srclevel.Blocks[0:64,0:64,0:64]))
|
||||||
indevlevel.fillBlocks(BoundingBox((0,0,0), (64,64,64,)), 12, 0, [1,2])
|
indevlevel.fillBlocks(BoundingBox((0,0,0), (64,64,64,)), 12, 0, [1,2])
|
||||||
|
Reference in New Issue
Block a user