sanitize both grass and snow layer. maybe more blocks in the future.
This commit is contained in:
parent
3087fa50d8
commit
0e6b3cfac9
18
mclevel.py
18
mclevel.py
@ -1806,6 +1806,7 @@ class InfdevChunk(MCLevel):
|
|||||||
return self.chunkFilename
|
return self.chunkFilename
|
||||||
def __init__(self, world, chunkPosition, create = False):
|
def __init__(self, world, chunkPosition, create = False):
|
||||||
self.world = world;
|
self.world = world;
|
||||||
|
#self.materials = self.world.materials
|
||||||
self.chunkPosition = chunkPosition;
|
self.chunkPosition = chunkPosition;
|
||||||
self.chunkFilename = world.chunkFilename(*chunkPosition)
|
self.chunkFilename = world.chunkFilename(*chunkPosition)
|
||||||
#self.filename = "UNUSED" + world.chunkFilename(*chunkPosition);
|
#self.filename = "UNUSED" + world.chunkFilename(*chunkPosition);
|
||||||
@ -1826,6 +1827,9 @@ class InfdevChunk(MCLevel):
|
|||||||
if not world.containsChunk(*chunkPosition):
|
if not world.containsChunk(*chunkPosition):
|
||||||
raise ChunkNotPresent("Chunk {0} not found", self.chunkPosition)
|
raise ChunkNotPresent("Chunk {0} not found", self.chunkPosition)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def materials(self):
|
||||||
|
return self.world.materials
|
||||||
|
|
||||||
def compressTagGzip(self, root_tag):
|
def compressTagGzip(self, root_tag):
|
||||||
buf = StringIO.StringIO()
|
buf = StringIO.StringIO()
|
||||||
@ -1872,12 +1876,22 @@ class InfdevChunk(MCLevel):
|
|||||||
return len(self.compressedTag)
|
return len(self.compressedTag)
|
||||||
|
|
||||||
|
|
||||||
def sanitizeGrass(self):
|
def sanitizeBlocks(self):
|
||||||
#change grass to dirt where needed so Minecraft doesn't flip out and die
|
#change grass to dirt where needed so Minecraft doesn't flip out and die
|
||||||
grass = self.Blocks == self.materials.Grass.ID
|
grass = self.Blocks == self.materials.Grass.ID
|
||||||
badgrass = grass[:,:,1:] & grass[:,:,:-1]
|
badgrass = grass[:,:,1:] & grass[:,:,:-1]
|
||||||
|
|
||||||
self.Blocks[:,:,:-1][badgrass] = self.materials.Dirt.ID
|
self.Blocks[:,:,:-1][badgrass] = self.materials.Dirt.ID
|
||||||
|
|
||||||
|
#remove any thin snow layers immediately above other thin snow layers.
|
||||||
|
#minecraft doesn't flip out, but it's almost never intended
|
||||||
|
if hasattr(self.materials, "SnowLayer"):
|
||||||
|
snowlayer = self.Blocks == self.materials.SnowLayer.ID
|
||||||
|
badsnow = snowlayer[:,:,1:] & snowlayer[:,:,:-1]
|
||||||
|
|
||||||
|
self.Blocks[:,:,1:][badsnow] = self.materials.Air.ID
|
||||||
|
|
||||||
|
|
||||||
def compress(self):
|
def compress(self):
|
||||||
|
|
||||||
|
|
||||||
@ -1886,7 +1900,7 @@ class InfdevChunk(MCLevel):
|
|||||||
#uncompressed tag structure away. rely on the OS disk cache.
|
#uncompressed tag structure away. rely on the OS disk cache.
|
||||||
self.root_tag = None
|
self.root_tag = None
|
||||||
else:
|
else:
|
||||||
self.sanitizeGrass() #xxx
|
self.sanitizeBlocks() #xxx
|
||||||
|
|
||||||
self.packChunkData()
|
self.packChunkData()
|
||||||
self._compressChunk()
|
self._compressChunk()
|
||||||
|
Reference in New Issue
Block a user