resource_packs.py
def open_pack(self):
        '''
        Opens the zip file and puts texture data into a dictionary, where the key is the texture file name, and the value is a PIL.Image instance
        '''
        zfile = zipfile.ZipFile(self.zipfile)
        for name in zfile.infolist():
            if name.filename.endswith(".png") and not name.filename.split(os.path.sep)[-1].startswith("._"):
                filename = "assets/minecraft/textures/blocks"
                if name.filename.startswith(filename) and name.filename.replace(filename+"/", "").replace(".png","") in textureSlots:
                    block_name = os.path.normpath(name.filename).split(os.path.sep)[-1]
                    block_name = block_name.split(".")[0]
                    #zfile.extract(name.filename, self.texture_path)
                    fp = zfile.open(name)
                    #possible_texture = Image.open(os.path.join(self.texture_path, os.path.normpath(name.filename)))
                    possible_texture = Image.open(fp)
                    if possible_texture.size == (16, 16):
                        self.block_image[block_name] = possible_texture
                        if block_name.startswith("repeater_") or block_name.startswith("comparator_"):
                            self.block_image[block_name+"_west"] = possible_texture.rotate(-90)
                            self.block_image[block_name+"_north"] = possible_texture.rotate(180)
                            self.block_image[block_name+"_east"] = possible_texture.rotate(90)
                            self.block_image[block_name+"_south"] = possible_texture
                        if block_name == "piston_side":
                            self.block_image["piston_up"] = possible_texture
                            self.block_image["piston_left"] = possible_texture.rotate(90)
                            self.block_image["piston_down"] = possible_texture.rotate(180)
                            self.block_image["piston_right"] = possible_texture.rotate(-90)
                        if block_name == "hay_block_side":
                            self.block_image["hay_block_side_rotated"] = possible_texture.rotate(-90)
                        if block_name == "quartz_block_lines":
                            self.block_image["quartz_block_lines_rotated"] = possible_texture.rotate(-90)
                        if block_name.startswith("bed_"):
                            if block_name == "bed_head_side":
                                self.block_image["bed_head_side_flipped"] = possible_texture.transpose(Image.FLIP_LEFT_RIGHT)
                            if block_name == "bed_feet_side":
                                self.block_image["bed_feet_side_flipped"] = possible_texture.transpose(Image.FLIP_LEFT_RIGHT)
                            if block_name == "bed_head_top":
                                self.block_image["bed_head_top_flipped"] = possible_texture.transpose(Image.FLIP_LEFT_RIGHT)
                                self.block_image["bed_head_top_bottom"] = possible_texture.rotate(-90)
                                self.block_image["bed_head_top_top"] = possible_texture.rotate(90)
                            if block_name == "bed_feet_top":
                                self.block_image["bed_feet_top_flipped"] = possible_texture.transpose(Image.FLIP_LEFT_RIGHT)
                                self.block_image["bed_feet_top_bottom"] = possible_texture.rotate(-90)
                                self.block_image["bed_feet_top_top"] = possible_texture.rotate(90)
                    else:
                        if possible_texture.size == (32, 32):
                            self.block_image[block_name] = possible_texture.resize((16, 16))
                        elif possible_texture.size == (64, 64) or possible_texture.size == (128, 128) or possible_texture.size == (256, 256):
                            self.big_textures_counted += 1
                        else:
                            self.block_image[block_name] = possible_texture.crop((0,0,16,16))
        if self.big_textures_counted >= self.big_textures_max:
            self.handle_too_big_packs()
        else:
            self.parse_terrain_png()

        Opens the zip file and puts texture data into a dictionary, where the key is the texture file name, and the value is a PIL.Image instance
        
Opens the zip file and puts texture data into a dictionary, where the key is the texture file name, and the value is a PIL.Image instance
Opens the zip file and puts texture data into a dictionary where the key is the texture file name and the value is a PIL . Image instance
def open_pack(self):
        zfile = zipfile.ZipFile(self.zipfile)
        for name in zfile.infolist():
            if name.filename.endswith(".png") and not name.filename.split(os.path.sep)[-1].startswith("._"):
                filename = "assets/minecraft/textures/blocks"
                if name.filename.startswith(filename) and name.filename.replace(filename+"/", "").replace(".png","") in textureSlots:
                    block_name = os.path.normpath(name.filename).split(os.path.sep)[-1]
                    block_name = block_name.split(".")[0]
                    fp = zfile.open(name)
                    possible_texture = Image.open(fp)
                    if possible_texture.size == (16, 16):
                        self.block_image[block_name] = possible_texture
                        if block_name.startswith("repeater_") or block_name.startswith("comparator_"):
                            self.block_image[block_name+"_west"] = possible_texture.rotate(-90)
                            self.block_image[block_name+"_north"] = possible_texture.rotate(180)
                            self.block_image[block_name+"_east"] = possible_texture.rotate(90)
                            self.block_image[block_name+"_south"] = possible_texture
                        if block_name == "piston_side":
                            self.block_image["piston_up"] = possible_texture
                            self.block_image["piston_left"] = possible_texture.rotate(90)
                            self.block_image["piston_down"] = possible_texture.rotate(180)
                            self.block_image["piston_right"] = possible_texture.rotate(-90)
                        if block_name == "hay_block_side":
                            self.block_image["hay_block_side_rotated"] = possible_texture.rotate(-90)
                        if block_name == "quartz_block_lines":
                            self.block_image["quartz_block_lines_rotated"] = possible_texture.rotate(-90)
                        if block_name.startswith("bed_"):
                            if block_name == "bed_head_side":
                                self.block_image["bed_head_side_flipped"] = possible_texture.transpose(Image.FLIP_LEFT_RIGHT)
                            if block_name == "bed_feet_side":
                                self.block_image["bed_feet_side_flipped"] = possible_texture.transpose(Image.FLIP_LEFT_RIGHT)
                            if block_name == "bed_head_top":
                                self.block_image["bed_head_top_flipped"] = possible_texture.transpose(Image.FLIP_LEFT_RIGHT)
                                self.block_image["bed_head_top_bottom"] = possible_texture.rotate(-90)
                                self.block_image["bed_head_top_top"] = possible_texture.rotate(90)
                            if block_name == "bed_feet_top":
                                self.block_image["bed_feet_top_flipped"] = possible_texture.transpose(Image.FLIP_LEFT_RIGHT)
                                self.block_image["bed_feet_top_bottom"] = possible_texture.rotate(-90)
                                self.block_image["bed_feet_top_top"] = possible_texture.rotate(90)
                    else:
                        if possible_texture.size == (32, 32):
                            self.block_image[block_name] = possible_texture.resize((16, 16))
                        elif possible_texture.size == (64, 64) or possible_texture.size == (128, 128) or possible_texture.size == (256, 256):
                            self.big_textures_counted += 1
                        else:
                            self.block_image[block_name] = possible_texture.crop((0,0,16,16))
        if self.big_textures_counted >= self.big_textures_max:
            self.handle_too_big_packs()
        else:
            self.parse_terrain_png()
def open_pack ( self ) : zfile = zipfile . ZipFile ( self . zipfile ) for name in zfile . infolist ( ) : if name . filename . endswith ( ".png" ) and not name . filename . split ( os . path . sep ) [ - 1 ] . startswith ( "._" ) : filename = "assets/minecraft/textures/blocks" if name . filename . startswith ( filename ) and name . filename . replace ( filename + "/" , "" ) . replace ( ".png" , "" ) in textureSlots : block_name = os . path . normpath ( name . filename ) . split ( os . path . sep ) [ - 1 ] block_name = block_name . split ( "." ) [ 0 ] fp = zfile . open ( name ) possible_texture = Image . open ( fp ) if possible_texture . size == ( 16 , 16 ) : self . block_image [ block_name ] = possible_texture if block_name . startswith ( "repeater_" ) or block_name . startswith ( "comparator_" ) : self . block_image [ block_name + "_west" ] = possible_texture . rotate ( - 90 ) self . block_image [ block_name + "_north" ] = possible_texture . rotate ( 180 ) self . block_image [ block_name + "_east" ] = possible_texture . rotate ( 90 ) self . block_image [ block_name + "_south" ] = possible_texture if block_name == "piston_side" : self . block_image [ "piston_up" ] = possible_texture self . block_image [ "piston_left" ] = possible_texture . rotate ( 90 ) self . block_image [ "piston_down" ] = possible_texture . rotate ( 180 ) self . block_image [ "piston_right" ] = possible_texture . rotate ( - 90 ) if block_name == "hay_block_side" : self . block_image [ "hay_block_side_rotated" ] = possible_texture . rotate ( - 90 ) if block_name == "quartz_block_lines" : self . block_image [ "quartz_block_lines_rotated" ] = possible_texture . rotate ( - 90 ) if block_name . startswith ( "bed_" ) : if block_name == "bed_head_side" : self . block_image [ "bed_head_side_flipped" ] = possible_texture . transpose ( Image . FLIP_LEFT_RIGHT ) if block_name == "bed_feet_side" : self . block_image [ "bed_feet_side_flipped" ] = possible_texture . transpose ( Image . FLIP_LEFT_RIGHT ) if block_name == "bed_head_top" : self . block_image [ "bed_head_top_flipped" ] = possible_texture . transpose ( Image . FLIP_LEFT_RIGHT ) self . block_image [ "bed_head_top_bottom" ] = possible_texture . rotate ( - 90 ) self . block_image [ "bed_head_top_top" ] = possible_texture . rotate ( 90 ) if block_name == "bed_feet_top" : self . block_image [ "bed_feet_top_flipped" ] = possible_texture . transpose ( Image . FLIP_LEFT_RIGHT ) self . block_image [ "bed_feet_top_bottom" ] = possible_texture . rotate ( - 90 ) self . block_image [ "bed_feet_top_top" ] = possible_texture . rotate ( 90 ) else : if possible_texture . size == ( 32 , 32 ) : self . block_image [ block_name ] = possible_texture . resize ( ( 16 , 16 ) ) elif possible_texture . size == ( 64 , 64 ) or possible_texture . size == ( 128 , 128 ) or possible_texture . size == ( 256 , 256 ) : self . big_textures_counted += 1 else : self . block_image [ block_name ] = possible_texture . crop ( ( 0 , 0 , 16 , 16 ) ) if self . big_textures_counted >= self . big_textures_max : self . handle_too_big_packs ( ) else : self . parse_terrain_png ( )
Opens the zip file and puts texture data into a dictionary, where the key is the texture file name, and the value is a PIL.Image instance
Opens the zip file and puts texture data into a dictionary where the key is the texture file name and the value is a PIL . Image instance
'''
        Opens the zip file and puts texture data into a dictionary, where the key is the texture file name, and the value is a PIL.Image instance
        ''' #zfile.extract(name.filename, self.texture_path) #possible_texture = Image.open(os.path.join(self.texture_path, os.path.normpath(name.filename)))
self