fixed crash when spawn point does not have an associated region file (closes issue #399)
This commit is contained in:
32
world.py
32
world.py
@@ -208,23 +208,25 @@ class World(object):
|
|||||||
|
|
||||||
## The filename of this chunk
|
## The filename of this chunk
|
||||||
chunkFile = self.get_region_path(chunkX, chunkY)
|
chunkFile = self.get_region_path(chunkX, chunkY)
|
||||||
|
|
||||||
data=nbt.load_from_region(chunkFile, chunkX, chunkY)[1]
|
if chunkFile is not None:
|
||||||
level = data['Level']
|
data = nbt.load_from_region(chunkFile, chunkX, chunkY)[1]
|
||||||
blockArray = numpy.frombuffer(level['Blocks'], dtype=numpy.uint8).reshape((16,16,128))
|
if data is not None:
|
||||||
|
level = data['Level']
|
||||||
## The block for spawn *within* the chunk
|
blockArray = numpy.frombuffer(level['Blocks'], dtype=numpy.uint8).reshape((16,16,128))
|
||||||
inChunkX = spawnX - (chunkX*16)
|
|
||||||
inChunkZ = spawnZ - (chunkY*16)
|
## The block for spawn *within* the chunk
|
||||||
|
inChunkX = spawnX - (chunkX*16)
|
||||||
## find the first air block
|
inChunkZ = spawnZ - (chunkY*16)
|
||||||
while (blockArray[inChunkX, inChunkZ, spawnY] != 0):
|
|
||||||
spawnY += 1
|
## find the first air block
|
||||||
if spawnY == 128:
|
while (blockArray[inChunkX, inChunkZ, spawnY] != 0):
|
||||||
break
|
spawnY += 1
|
||||||
|
if spawnY == 128:
|
||||||
|
break
|
||||||
|
|
||||||
self.POI.append( dict(x=spawnX, y=spawnY, z=spawnZ,
|
self.POI.append( dict(x=spawnX, y=spawnY, z=spawnZ,
|
||||||
msg="Spawn", type="spawn", chunk=(inChunkX,inChunkZ)))
|
msg="Spawn", type="spawn", chunk=(chunkX, chunkY)))
|
||||||
self.spawn = (spawnX, spawnY, spawnZ)
|
self.spawn = (spawnX, spawnY, spawnZ)
|
||||||
|
|
||||||
def go(self, procs):
|
def go(self, procs):
|
||||||
|
|||||||
Reference in New Issue
Block a user