public virtual int[] GetTextureContents(string par1Str)
        {
            TexturePackBase texturepackbase = TexturePack.SelectedTexturePack;

            if (TextureContentsMap.ContainsKey(par1Str))
            {
                return(TextureContentsMap[par1Str]);
            }

            try
            {
                int[] ai1 = null;

                if (par1Str.StartsWith("##"))
                {
                    ai1 = GetImageContentsAndAllocate(UnwrapImageByColumns(ReadTextureImage(texturepackbase.GetResourceAsStream(par1Str.Substring(2)))));
                }
                else if (par1Str.StartsWith("%clamp%"))
                {
                    ClampTexture = true;
                    ai1          = GetImageContentsAndAllocate(ReadTextureImage(texturepackbase.GetResourceAsStream(par1Str.Substring(7))));
                    ClampTexture = false;
                }
                else if (par1Str.StartsWith("%blur%"))
                {
                    BlurTexture  = true;
                    ClampTexture = true;
                    ai1          = GetImageContentsAndAllocate(ReadTextureImage(texturepackbase.GetResourceAsStream(par1Str.Substring(6))));
                    ClampTexture = false;
                    BlurTexture  = false;
                }
                else
                {
                    Stream inputstream = texturepackbase.GetResourceAsStream(par1Str);

                    if (inputstream == null)
                    {
                        ai1 = GetImageContentsAndAllocate(MissingTextureImage);
                    }
                    else
                    {
                        ai1 = GetImageContentsAndAllocate(ReadTextureImage(inputstream));
                    }
                }

                TextureContentsMap.Add(par1Str, ai1);
                return(ai1);
            }
            catch (IOException ioexception)
            {
                Utilities.LogException(ioexception);
            }

            int[] ai2 = GetImageContentsAndAllocate(MissingTextureImage);
            TextureContentsMap.Add(par1Str, ai2);
            return(ai2);
        }
        /// <summary>
        /// Call setupTexture on all currently-loaded textures again to account for changes in rendering options
        /// </summary>
        public void RefreshTextures()
        {
            TexturePackBase texturepackbase = TexturePack.SelectedTexturePack;
            int             i;
            Bitmap          bufferedimage;

            for (IEnumerator <int> iterator = TextureNameToImageMap.GetKeySet().GetEnumerator(); iterator.MoveNext(); SetupTexture(bufferedimage, i))
            {
                i             = iterator.Current;
                bufferedimage = (Bitmap)TextureNameToImageMap.Lookup(i);
            }
            for (IEnumerator <ThreadedImageDownloader> iterator1 = UrlToImageDataMap.Values.GetEnumerator(); iterator1.MoveNext();)
            {
                ThreadedImageDownloader threaddownloadimagedata = iterator1.Current;
                threaddownloadimagedata.TextureSetupComplete = false;
            }
            for (IEnumerator <string> iterator2 = TextureMap.Keys.GetEnumerator(); iterator2.MoveNext();)
            {
                string s = (string)iterator2.Current;
                try
                {
                    Bitmap bufferedimage1;
                    if (s.StartsWith("##"))
                    {
                        bufferedimage1 = UnwrapImageByColumns(ReadTextureImage(texturepackbase.GetResourceAsStream(s.Substring(2))));
                    }
                    else if (s.StartsWith("%clamp%"))
                    {
                        ClampTexture   = true;
                        bufferedimage1 = ReadTextureImage(texturepackbase.GetResourceAsStream(s.Substring(7)));
                    }
                    else if (s.StartsWith("%blur%"))
                    {
                        BlurTexture    = true;
                        bufferedimage1 = ReadTextureImage(texturepackbase.GetResourceAsStream(s.Substring(6)));
                    }
                    else if (s.StartsWith("%blurclamp%"))
                    {
                        BlurTexture    = true;
                        ClampTexture   = true;
                        bufferedimage1 = ReadTextureImage(texturepackbase.GetResourceAsStream(s.Substring(11)));
                    }
                    else
                    {
                        bufferedimage1 = ReadTextureImage(texturepackbase.GetResourceAsStream(s));
                    }
                    int j = TextureMap[s];
                    SetupTexture(bufferedimage1, j);
                    BlurTexture  = false;
                    ClampTexture = false;
                }
                catch (IOException ioexception)
                {
                    Utilities.LogException(ioexception);
                }
            }
            for (IEnumerator <string> iterator3 = TextureContentsMap.Keys.GetEnumerator(); iterator3.MoveNext();)
            {
                string s1 = (string)iterator3.Current;
                try
                {
                    Bitmap bufferedimage2;
                    if (s1.StartsWith("##"))
                    {
                        bufferedimage2 = UnwrapImageByColumns(ReadTextureImage(texturepackbase.GetResourceAsStream(s1.Substring(2))));
                    }
                    else if (s1.StartsWith("%clamp%"))
                    {
                        ClampTexture   = true;
                        bufferedimage2 = ReadTextureImage(texturepackbase.GetResourceAsStream(s1.Substring(7)));
                    }
                    else if (s1.StartsWith("%blur%"))
                    {
                        BlurTexture    = true;
                        bufferedimage2 = ReadTextureImage(texturepackbase.GetResourceAsStream(s1.Substring(6)));
                    }
                    else
                    {
                        bufferedimage2 = ReadTextureImage(texturepackbase.GetResourceAsStream(s1));
                    }
                    GetImageContents(bufferedimage2, (int[])TextureContentsMap[s1]);
                    BlurTexture  = false;
                    ClampTexture = false;
                }
                catch (IOException ioexception1)
                {
                    Utilities.LogException(ioexception1);
                }
            }
        }
        public virtual int GetTexture(string par1Str)
        {
            TexturePackBase texturepackbase = TexturePack.SelectedTexturePack;

            if (TextureMap.ContainsKey(par1Str))
            {
                return(TextureMap[par1Str]);
            }

            try
            {
                SingleIntBuffer.Clear();
                GLAllocation.GenerateTextureNames(SingleIntBuffer);
                int i = SingleIntBuffer.Get(0);

                if (par1Str.StartsWith("##"))
                {
                    SetupTexture(UnwrapImageByColumns(ReadTextureImage(texturepackbase.GetResourceAsStream(par1Str.Substring(2)))), i);
                }
                else if (par1Str.StartsWith("%clamp%"))
                {
                    ClampTexture = true;
                    SetupTexture(ReadTextureImage(texturepackbase.GetResourceAsStream(par1Str.Substring(7))), i);
                    ClampTexture = false;
                }
                else if (par1Str.StartsWith("%blur%"))
                {
                    BlurTexture = true;
                    SetupTexture(ReadTextureImage(texturepackbase.GetResourceAsStream(par1Str.Substring(6))), i);
                    BlurTexture = false;
                }
                else if (par1Str.StartsWith("%blurclamp%"))
                {
                    BlurTexture  = true;
                    ClampTexture = true;
                    SetupTexture(ReadTextureImage(texturepackbase.GetResourceAsStream(par1Str.Substring(11))), i);
                    BlurTexture  = false;
                    ClampTexture = false;
                }
                else
                {
                    Stream inputstream = texturepackbase.GetResourceAsStream(par1Str);

                    if (inputstream == null)
                    {
                        SetupTexture(MissingTextureImage, i);
                    }
                    else
                    {
                        SetupTexture(ReadTextureImage(inputstream), i);
                    }
                }

                TextureMap.Add(par1Str, i);
                return(i);
            }
            catch (Exception exception)
            {
                Utilities.LogException(exception);
            }

            GLAllocation.GenerateTextureNames(SingleIntBuffer);
            int j = SingleIntBuffer.Get(0);

            SetupTexture(MissingTextureImage, j);
            TextureMap.Add(par1Str, j);
            return(j);
        }