Beispiel #1
0
    def set_light(self, x, y, z, light_block=None, light_sky=None):

        x, rx = divmod(x, 16)
        y, ry = divmod(y, 16)
        z, rz = divmod(z, 16)

        if y > 0x0F:
            return

        if (x, z) in self.columns:
            column = self.columns[(x, z)]
        else:
            column = smpmap.ChunkColumn()
            self.columns[(x, z)] = column

        chunk = column.chunks[y]

        if chunk == None:
            chunk = smpmap.Chunk()
            column.chunks[y] = chunk

        if light_block != None:
            chunk.light_block.set(rx, ry, rz, light_block & 0xF)

        if light_sky != None:
            chunk.light_sky.set(rx, ry, rz, light_sky & 0xF)
    def set_light(self, x, y, z, light_block=None, light_sky=None):
        """ Sets the light level for the block at the given coordinates to the
        specified values.  If light_block or light_sky are not set in the
        function call then the respective light values will not be set.
        """

        x, rx = divmod(x, 16)
        y, ry = divmod(y, 16)
        z, rz = divmod(z, 16)

        # Check to see if y > 16, i.e. if the original height was greater than
        # 255 and therefore too high to be part of the world.
        if y > 0x0F:
            return

        if (x, z) in self.columns:
            column = self.columns[(x, z)]
        else:
            column = smpmap.ChunkColumn()
            self.columns[(x, z)] = column

        chunk = column.chunks[y]

        if chunk is None:
            chunk = smpmap.Chunk()
            column.chunks[y] = chunk

        if light_block is not None:
            chunk.light_block.set(rx, ry, rz, light_block & 0xF)

        if light_sky is not None:
            chunk.light_sky.set(rx, ry, rz, light_sky & 0xF)
Beispiel #3
0
    def set_biome(self, x, z, data):

        x, rx = divmod(x, 16)
        z, rz = divmod(z, 16)

        if (x, z) in self.columns:
            column = self.columns[(x, z)]
        else:
            column = smpmap.ChunkColumn()
            self.columns[(x, z)] = column

        return column.biome.set(rx, rz, data)
Beispiel #4
0
    def handle_unpack_chunk(self, data):

        chunk_x = data.chunk_x
        chunk_z = data.chunk_z
        mask = data.primary_bitmap
        continuous = data.continuous
        bbuff = BoundBuffer(data.data)

        if self.dimension == DIMENSION_OVERWORLD:
            skylight = True
        else:
            skylight = False

        key = (chunk_x, chunk_z)

        if key not in self.columns:
            self.columns[key] = smpmap.ChunkColumn()

        self.columns[key].unpack(bbuff, mask, skylight, continuous)
Beispiel #5
0
    def handle_unpack_bulk(self, data):

        #print "unpacking bulk"
        skylight = data.sky_light
        bbuff = BoundBuffer(data.data)

        #print "light: %s: buffer:"%skylight
        #print bbuff

        for meta in data.metadata:
            chunk_x = meta.chunk_x
            chunk_z = meta.chunk_z
            mask = meta.primary_bitmap

            #print "unpacking chunk meta x: %d, z: %d, mask: %d"%(chunk_x, chunk_z, mask)

            key = (chunk_x, chunk_z)

            if key not in self.columns:
                self.columns[key] = smpmap.ChunkColumn()

            self.columns[key].unpack(bbuff, mask, skylight)
Beispiel #6
0
    def handle_unpack_block(self, data):

        #becomes (chunk number, offset in chunk)
        x, rx = divmod(data.x, 16)
        y, ry = divmod(data.y, 16)
        z, rz = divmod(data.z, 16)

        if y > 0x0F:
            return

        if (x, z) in self.columns:
            column = self.columns[(x, z)]
        else:
            column = smpmap.ChunkColumn()
            self.columns[(x, z)] = column

        chunk = column.chunks[y]

        if chunk == None:
            chunk = smpmap.Chunk()
            column.chunks[y] = chunk

        chunk.block_data.set(rx, ry, rz, data.data)