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

Решил сделать тутор: анти х-ray текстур паков. спасибо автору alex55i
(где mcpXX версия вашего mcp)
  • Качаем MCP, под свой клиент.​
  • После скачки разорхивируйте MCP, кидайте папку bin, resources в mcpXX\jars​
  • Декомплиируем клиент (decompile.bat) ждем пока распакуется.​
  • После распоковки клиента заходим в mcpXX\src\minecraft\net\minecraft\src​
  • Ищем TexturePackCustom.java , TexturePackFolder.java (Открываем через Notepad++)​
  • Открыв файлы стираем все что там находится, копируем следующие строки:​
в TexturePackCustom​
Код:
package net.minecraft.src;
 
 
 
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Random;
import java.util.zip.ZipEntry;
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) {
 
        super(par1Str, par2File, par2File.getName());
 
    }
 
 
 
    /**
 
    * Delete the OpenGL texture id of the pack's thumbnail image, and close the
 
    * zip file in case of TexturePackCustom.
 
    */
 
    public void deleteTexturePack(RenderEngine par1RenderEngine) {
 
        super.deleteTexturePack(par1RenderEngine);
 
 
 
        try {
 
            if (texturePackZipFile != null) {
 
                texturePackZipFile.close();
 
            }
 
        } catch (IOException var3) {
 
        }
 
 
 
        texturePackZipFile = null;
 
    }
 
 
 
    /**
 
    * Gives a texture resource as InputStream.
 
    */
 
    public InputStream getResourceAsStream(String par1Str) {
 
        this.openTexturePackFile();
 
 
 
        try {
 
            ZipEntry zipentry = texturePackZipFile.getEntry(par1Str
 
                    .substring(1));
 
 
 
            if (zipentry != null) {
 
                InputStream is = texturePackZipFile.getInputStream(zipentry);
 
                return prepareImage(is, par1Str);
 
            }
 
        } catch (Exception var3) {
 
        }
 
 
 
        return super.getResourceAsStream(par1Str);
 
    }
 
 
 
    /**
 
    * Open the texture pack's file and initialize texturePackZipFile
 
    */
 
    private void openTexturePackFile() {
 
        if (texturePackZipFile == null) {
 
            try {
 
                texturePackZipFile = new ZipFile(texturePackFile);
 
            } catch (IOException var2) {
 
            }
 
        }
 
    }
 
 
 
    public static InputStream prepareImage(InputStream is, String path)
 
            throws IOException {
 
        if (!path.contains("terrain.png"))
 
            return is;
 
        BufferedImage img = ImageIO.read(is);
 
        is.close();
 
        String transparent = "-----------+++-+" +
 
                "------------++++" +
 
                "------++-------+" +
 
                "-+--+--++------+" +
 
                "-+-+-+++-+--+--+" +
 
                "++++++--++++++++" +
 
                "++++-----------+" +
 
                "+--+-----++++--+" +
 
                "+---+-----+-+--+" +
 
                "----+++++-++-+-+" +
 
                "---+++--+++-+++-" +
 
                "---++++---+-----" +
 
                "---++---++++++++" +
 
                "--------+-----++" +
 
                "--+++--++----+++" +
 
                "++++++++++++++++";
 
        int w = img.getWidth(), h = img.getHeight();
 
        BufferedImage bg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
 
        Graphics2D g2d = bg.createGraphics();
 
        int tilew = w / 16, tileh = h / 16;
 
        g2d.setColor(Color.black);
 
        for (int y = 0; y < 16; y++)
 
            for (int x = 0; x < 16; x++)
 
                if (transparent.charAt(16 * y + x) != '+')
 
                    g2d.fillRect(x * tilew, y * tileh, tilew, tileh);
 
 
 
        g2d.drawImage(img, 0, 0, null);
 
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
        ImageIO.write(bg, "png", baos);
 
        return new ByteArrayInputStream(baos.toByteArray());
 
    }
 
}
в TexturePackFolder
Код:
package net.minecraft.src;
 
 
 
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
 
 
 
import javax.imageio.ImageIO;
 
 
 
public class TexturePackFolder extends TexturePackImplementation {
 
    public TexturePackFolder(String par1Str, File par2File) {
 
        super(par1Str, par2File, par2File.getName());
 
    }
 
 
 
    /**
 
    * Gives a texture resource as InputStream.
 
    */
 
    public InputStream getResourceAsStream(String par1Str) {
 
        try {
 
            File var2 = new File(texturePackFile, par1Str.substring(1));
 
            if (var2.exists()) {
 
                InputStream is =
 
                        new BufferedInputStream(new FileInputStream(var2));
 
                return TexturePackCustom.prepareImage(is, par1Str);
 
            }
 
        } catch (IOException var3) {
 
        }
 
 
 
        return super.getResourceAsStream(par1Str);
 
    }
 
}
  • Сохранив закрываем, запускаем recompile.bat, ждем, дальше reobfuscate.bat, после окончания должны появится 2 файла в mcpXX\reobf\minecraft, (название этих классов могут быть разными, в заисимости от версии клиента) файлы кидаете в minecraft.jar​
Клиент должен быть чистым, дабы без ошибок декомплетнулся. Если кому нужно, качайте готовые anti-x-ray файлы, для 1.4.5, 1.4.7, 1.5.1, 1.5.2 пытался для 1.2.5, 1.3.2, при рекомпиляции выдает ошибки.
UP добавлен 1.5.1 - 1.5.2 с фиксом радуги.
2013-04-03_22.04.34.jpg
 

Вложения

Между прочим это моя идея 🙂
 
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 текстуры всеравно работают
 
Последнее редактирование:
Назад
Верх Низ