Туториал Anti x-ray texture

Между прочим это моя идея :)
 
up, чтоли, скажите хоть в какие файлы лесть? для 164
 
Это фича
Версия 1.5.2/1.5.1
Радуга исправлена

TexturePackCustom
Java:
package net.minecraft.src;

import java.awt.image.BufferedImage;
import java.awt.image.DataBufferByte;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;

import javax.imageio.ImageIO;

public class TexturePackCustom extends TexturePackImplementation
{
    /** ZipFile object used to access the texture pack file's contents. */
    private ZipFile texturePackZipFile;

    public TexturePackCustom(String par1Str, File par2File, ITexturePack par3ITexturePack)
    {
        super(par1Str, par2File, par2File.getName(), par3ITexturePack);
    }

    /**
    * Delete the OpenGL texture id of the pack's thumbnail image, and close the zip file in case of TexturePackCustom.
    */
    public void deleteTexturePack(RenderEngine renderEngine)
    {
        super.deleteTexturePack(renderEngine);

        try
        {
            if (texturePackZipFile != null)
            {
                texturePackZipFile.close();
            }
        }
        catch (IOException var3)
        {
        }

        texturePackZipFile = null;
    }

    protected InputStream func_98139_b(String name) throws IOException
    {
        openTexturePackFile();
        ZipEntry var2 = texturePackZipFile.getEntry(name.substring(1));

        if (var2 == null)
        {
            throw new FileNotFoundException(name);
        }
        else
        {
            return filterStream(name, texturePackZipFile.getInputStream(var2));
        }
    }

    public boolean func_98140_c(String par1Str)
    {
        try
        {
            openTexturePackFile();
            return texturePackZipFile.getEntry(par1Str.substring(1)) != null;
        }
        catch (Exception var3)
        {
            return false;
        }
    }

    /**
    * Open the texture pack's file and initialize texturePackZipFile
    */
    private void openTexturePackFile() throws IOException, ZipException
    {
        if (texturePackZipFile == null)
        {
            texturePackZipFile = new ZipFile(texturePackFile);
        }
    }

    public boolean isCompatible()
    {
        try
        {
            openTexturePackFile();
            Enumeration var1 = texturePackZipFile.entries();

            while (var1.hasMoreElements())
            {
                ZipEntry var2 = (ZipEntry)var1.nextElement();

                if (var2.getName().startsWith("textures/"))
                {
                    return true;
                }
            }
        }
        catch (Exception var3)
        {
        }

        boolean var4 = func_98140_c("terrain.png") || func_98140_c("gui/items.png");
        return !var4;
    }

    public static InputStream filterStream(String entryname, InputStream is) throws IOException
    {
        try
        {
            entryname = entryname.replace('\\', '/');
            if (!entryname.contains("textures/blocks/") || !entryname.endsWith(".png"))
                return is;

            String texturename = entryname.substring(entryname.lastIndexOf('/') +1, entryname.lastIndexOf(".png"));
            for (String pattern : patterns)
            {
                if (Pattern.compile("^" + pattern + "$").matcher(texturename).matches())
                    return is;
            }

            BufferedImage img = ImageIO.read(is);

            int w = img.getWidth();
            int h = img.getHeight();
            int[] r = img.getRGB(0, 0, w, h, null, 0, w);
            for (int i = 0; i < r.length; i++)
                r[i] |= 0xff000000;
            img.setRGB(0, 0, w, h, r, 0, w);

            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            ImageIO.write(img, "png", baos);
            return new ByteArrayInputStream(baos.toByteArray());
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
        return null;
    }

    static final String[] patterns = new String[] { "activatorRail(_powered)?", "anvil_(top(_damaged_[1-2])?|base)", "bed_(feet|head)_(end|side|top)", "brewingStand", "cactus_(bottom|side|top)", "cake_(bottom|inner|side|top)", "carrots_[0-3]", "cauldron_(bottom|inner|side|top)", "cocoa_[0-7]", "deadbush", "destroy_[0-9]", "detectorRail", "door(Iron|Wood)_(lower|upper)", "fenceIron", "fern", "fire_[0-1]", "flower(Pot)?", "glass", "goldenRail(_powered)?", "grass_side_overlay", "hopper_top", "ice", "ladder", "lava(_flow)?", "leaves(_(jungle|spruce))?", "lever", "mobSpawner", "mushroom_(brown|red)", "netherStalk_[0-2]", "portal", "potatoes_[0-3]", "rail(_turn)?", "redstoneDust_(cross|line)(_overlay)?", "redtorch(_lit)?", "reeds", "rose", "sapling(_(birch|jungle|spruce))?", "stem_(bent|straight)", "tallgrass", "thinglass_top", "torch", "trapdoor", "tripWire(Source)?", "vine", "water(_flow)?", "waterlily", "web" };
}

TexturePackFolder
Java:
package net.minecraft.src;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class TexturePackFolder extends TexturePackImplementation
{
    public TexturePackFolder(String par1, File par2, ITexturePack par3ITexturePack)
    {
        super(par1, par2, par2.getName(), par3ITexturePack);
    }

    protected InputStream func_98139_b(String name) throws IOException
    {
        File var2 = new File(texturePackFile, name.substring(1));

        if (!var2.exists())
        {
            throw new FileNotFoundException(name);
        }
        else
        {
            return TexturePackCustom.filterStream(name, new BufferedInputStream(new FileInputStream(var2)));
        }
    }

    public boolean func_98140_c(String par1Str)
    {
        File var2 = new File(texturePackFile, par1Str);
        return var2.exists() && var2.isFile();
    }

    public boolean isCompatible()
    {
        File var1 = new File(this.texturePackFile, "textures/");
        boolean var2 = var1.exists() && var1.isDirectory();
        boolean var3 = func_98140_c("terrain.png") || func_98140_c("gui/items.png");
        return var2 || !var3;
    }
}
Делаю так, но XRay текстуры всеравно работают
 
Последнее редактирование:
Назад
Верх