001 package net.minecraft.src; 002 003 import cpw.mods.fml.common.Side; 004 import cpw.mods.fml.common.asm.SideOnly; 005 import java.io.File; 006 import java.io.IOException; 007 import java.io.InputStream; 008 import java.util.zip.ZipEntry; 009 import java.util.zip.ZipFile; 010 011 @SideOnly(Side.CLIENT) 012 public class TexturePackCustom extends TexturePackImplementation 013 { 014 /** ZipFile object used to access the texture pack file's contents. */ 015 private ZipFile texturePackZipFile; 016 017 public TexturePackCustom(String par1Str, File par2File) 018 { 019 super(par1Str, par2File, par2File.getName()); 020 } 021 022 /** 023 * Delete the OpenGL texture id of the pack's thumbnail image, and close the zip file in case of TexturePackCustom. 024 */ 025 public void deleteTexturePack(RenderEngine par1RenderEngine) 026 { 027 super.deleteTexturePack(par1RenderEngine); 028 029 try 030 { 031 if (this.texturePackZipFile != null) 032 { 033 this.texturePackZipFile.close(); 034 } 035 } 036 catch (IOException var3) 037 { 038 ; 039 } 040 041 this.texturePackZipFile = null; 042 } 043 044 /** 045 * Gives a texture resource as InputStream. 046 */ 047 public InputStream getResourceAsStream(String par1Str) 048 { 049 this.openTexturePackFile(); 050 051 try 052 { 053 ZipEntry var2 = this.texturePackZipFile.getEntry(par1Str.substring(1)); 054 055 if (var2 != null) 056 { 057 return this.texturePackZipFile.getInputStream(var2); 058 } 059 } 060 catch (Exception var3) 061 { 062 ; 063 } 064 065 return super.getResourceAsStream(par1Str); 066 } 067 068 /** 069 * Open the texture pack's file and initialize texturePackZipFile 070 */ 071 private void openTexturePackFile() 072 { 073 if (this.texturePackZipFile == null) 074 { 075 try 076 { 077 this.texturePackZipFile = new ZipFile(this.texturePackFile); 078 } 079 catch (IOException var2) 080 { 081 ; 082 } 083 } 084 } 085 }