Туториал 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
 

Вложения

т.е. проверяет прозрачность текстур? В случае обнаружения прозрачности просто не ставит? А как же Hd?
 
т.е. проверяет прозрачность текстур? В случае обнаружения прозрачности просто не ставит? А как же Hd?
в случае обнаружение прозрачных текстур, там где прозрачно, чорным цветом все покрывает.
 

Вложения

  • 2013-02-24_17.37.38.png
    2013-02-24_17.37.38.png
    322,6 КБ · Просмотры: 662
  • 2013-02-24_17.37.52.png
    2013-02-24_17.37.52.png
    304,4 КБ · Просмотры: 695
  • 2013-02-24_17.39.43.png
    2013-02-24_17.39.43.png
    653,6 КБ · Просмотры: 711
  • 2013-02-24_17.39.36.png
    2013-02-24_17.39.36.png
    237,5 КБ · Просмотры: 701
под 1.4.7 не работает.
upd: Заработало
 
@qwertyYy2, Почини пустые строки и подсветку синтаксиса хоть
 
Замеры FPS кто то делал? Сильно производительность падает?
Использовал ли кто то с Optifine?
 
у меня в клиенте, стоит, + моды: Optifine, ModLoader.
все отлично пашет, с хд паками x64, выше не тестировал.
 
Замеры FPS кто то делал? Сильно производительность падает?
Производительность вообще не должна падать.

какие?
1)package net.minecraft.src;
2)
3)
4)
5)import java.awt.image.BufferedImage;

эти?
Я про
5. import java.awt.Color;
6.
7. import java.awt.Graphics2D;
8.
9. import java.awt.image.BufferedImage;
 
qwertyYy2, можешь отключить возможность смены текстур-пака?
 
на моды не работает))просвечивает блоки из модов!!
 
Версия 13w02b

2013-03-09_23.05.08.png

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.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.regex.Pattern;
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 name)
	{
		openTexturePackFile();

		try
		{
			ZipEntry zipEntry = texturePackZipFile.getEntry(name.substring(1));

			if (zipEntry != null)
				return filterStream(name, texturePackZipFile.getInputStream(zipEntry));
		}
		catch (Exception var3)
		{
		}

		return super.getResourceAsStream(name);
	}

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

	public boolean func_94180_h()
	{
		openTexturePackFile();

		try
		{
			Enumeration var1 = texturePackZipFile.entries();
			ZipEntry zipEntry;

			do
			{
				if (!var1.hasMoreElements())
				{
					return false;
				}

				zipEntry = (ZipEntry) var1.nextElement();
			}
			while (!zipEntry.getName().startsWith("textures/"));

			return true;
		}
		catch (Exception var3)
		{
			return false;
		}
	}

	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);
			byte[] imageData = ((DataBufferByte)img.getRaster().getDataBuffer()).getData();

			for (int i = 0; i < imageData.length; i+=4)
				imageData[i] = (byte)0xFF;

			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.IOException;
import java.io.InputStream;
 
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 name)
    {
        try
        {
            File var2 = new File(texturePackFile, name.substring(1));
 
            if (var2.exists())
            {
                return TexturePackCustom.filterStream(name, new BufferedInputStream(new FileInputStream(var2)));
            }
        }
        catch (IOException var3)
        {
        }
 
        return super.getResourceAsStream(name);
    }
 
    public boolean func_94180_h()
    {
        File var1 = new File(texturePackFile, "textures/");
        return var1.exists();
    }
}
 
Назад
Верх Низ