def parse_terrain_png(self):
        '''
        Parses each block texture into a usable PNG file like terrain.png
        '''
        multiparts = MultipartTexture(self.block_image)
        log.debug("Parsing terrain.png")
        new_terrain = Image.new("RGBA", (512, 512), None)
        for tex in self.block_image.keys():
            if not self.__stop and tex in textureSlots.keys():
                try:
                    if tex not in multiparts.texture_dict:
                        image = self.block_image[tex]
                    else:
                        image = multiparts.texture_dict[tex].parse_texture()
                        if image is None:
                            continue
                    log.debug("    Image is %s"%tex)
                    log.debug("        Image mode: %s"%image.mode)
                    if image.mode != "RGBA":
                        try:
                            image = image.convert("RGBA")
                            log.debug("        Image converted to RGBA.")
                        except Exception as ee:
                            print "* * *", tex, ee
                    slot = textureSlots[tex]
                    try:
                        new_terrain.paste(image, slot, image)
                    except Exception as eee:
                        print "* * * new_terrain error:", eee
                    self.propogated_textures.append(slot)
                    log.debug("        Image pasted and propagated.")
                except Exception as e:
                    try:
                        # Print the resource pack 'raw' name.
                        print "An Exception occurred while trying to parse textures for {}".format(self._pack_name)
                        log.debug("An Exception occurred while trying to parse textures for {}".format(self._pack_name))
                    except:
                        # I for a reason it fails, print the 'representation' of it.
                        print "An Exception occurred while trying to parse textures for {}".format(repr(self._pack_name))
                        log.debug("An Exception occurred while trying to parse textures for {}".format(repr(self._pack_name)))
                    traceback.print_stack()
                    print "Exception Message: "+str(e)
                    log.debug("Exception Message: "+str(e))
                    print "Exception type: "+str(type(e))
                    log.debug("Exception type: "+str(type(e)))
                    print e
                    self.__stop = True
                    self._isEmpty = True
                    log.debug("Parsing stopped.")
                    log.debug("Resource pack considered as empty.")
                    pass
        for runAnyway in multiparts.runAnyways:
            parsed_texture = runAnyway.parse_texture()
            if parsed_texture is not None:
                new_terrain.paste(parsed_texture, runAnyway.position, parsed_texture)
                self.propogated_textures.append(runAnyway.position)
        copy = self.old_terrain.copy()

        log.debug("Correcting textures...")
        for t in self.all_texture_slots:
            if t not in self.propogated_textures:
                old_tex = copy.crop((t[0],t[1],t[0]+16,t[1]+16))
                new_terrain.paste(old_tex, t, old_tex)
        log.debug("    Done.")

        log.debug("Saving %s."%self._terrain_path)
        new_terrain.save(self._terrain_path)
        log.debug("    Done.")
        try:
            os.remove(self._pack_name.replace(" ", "_")+".png")
        except:
            pass
        if not self.propogated_textures:
            os.remove(self._terrain_path)
            self._isEmpty = True
            log.debug("No propagated textures.\nTexture pack considered as empty.")
            #print u"{} did not replace any textures".format(self._pack_name)

        del self.block_image
        if hasattr(self, 'fps'):
            log.debug("    Closing file descriptors.")
            for f in self.fps:
                f.close()
            log.debug("        Done")
        log.debug("Parsing terrain.png ended.")

        Parses each block texture into a usable PNG file like terrain.png
        
resource_packs.py