Make all tests one side only, so we can test vanilla clients in dev env.

This commit is contained in:
LexManos committed 2016-11-22 12:12:13 -08:00
1 parent 8f03658f1f
commit 8719fa0263
32 files changed
+263 -221

No files matched your search

@@ -19,64 +19,64 @@ import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.MinecraftForge;
@Mod(modid = TextureDump.MODID, name = "Forge Texture Atlas Dump", version = TextureDump.VERSION, clientSideOnly = true)
@Mod(modid = TextureDump.MODID, name = "Forge Texture Atlas Dump", version = TextureDump.VERSION, clientSideOnly = true, acceptableRemoteVersions = "*")
public class TextureDump
{
public static final String MODID = "forge_texture_dump";
public static final String VERSION = "1.0";
public static final String MODID = "forge_texture_dump";
public static final String VERSION = "1.0";
public static final boolean ENABLE = true;
public static final boolean ENABLE = true;
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
if (ENABLE)
{
MinecraftForge.EVENT_BUS.register(this);
}
}
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent event)
{
if (ENABLE)
{
MinecraftForge.EVENT_BUS.register(this);
}
}
@SubscribeEvent
public void postTextureStitch(TextureStitchEvent.Post e) throws Exception
{
TextureMap map = e.getMap();
String name = map.getBasePath().replace('/', '_');
int mip = map.getMipmapLevels();
saveGlTexture(name, map.getGlTextureId(), mip);
}
@SubscribeEvent
public void postTextureStitch(TextureStitchEvent.Post e) throws Exception
{
TextureMap map = e.getMap();
String name = map.getBasePath().replace('/', '_');
int mip = map.getMipmapLevels();
saveGlTexture(name, map.getGlTextureId(), mip);
}
public static void saveGlTexture(String name, int textureId, int mipmapLevels)
{
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
public static void saveGlTexture(String name, int textureId, int mipmapLevels)
{
GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1);
GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
GL11.glPixelStorei(GL11.GL_PACK_ALIGNMENT, 1);
GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
for (int level = 0; level <= mipmapLevels; level++)
{
int width = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_WIDTH);
int height = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_HEIGHT);
int size = width * height;
for (int level = 0; level <= mipmapLevels; level++)
{
int width = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_WIDTH);
int height = GL11.glGetTexLevelParameteri(GL11.GL_TEXTURE_2D, level, GL11.GL_TEXTURE_HEIGHT);
int size = width * height;
BufferedImage bufferedimage = new BufferedImage(width, height, 2);
File output = new File("texture_atlas_dump_" + name + "_mipmap_" + level + ".png");
BufferedImage bufferedimage = new BufferedImage(width, height, 2);
File output = new File("texture_atlas_dump_" + name + "_mipmap_" + level + ".png");
IntBuffer buffer = BufferUtils.createIntBuffer(size);
int[] data = new int[size];
IntBuffer buffer = BufferUtils.createIntBuffer(size);
int[] data = new int[size];
GL11.glGetTexImage(GL11.GL_TEXTURE_2D, level, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, buffer);
buffer.get(data);
bufferedimage.setRGB(0, 0, width, height, data, 0, width);
GL11.glGetTexImage(GL11.GL_TEXTURE_2D, level, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, buffer);
buffer.get(data);
bufferedimage.setRGB(0, 0, width, height, data, 0, width);
try
{
ImageIO.write(bufferedimage, "png", output);
FMLLog.info("[TextureDump] Exported png to: %s", output.getAbsolutePath());
}
catch (IOException ioexception)
{
FMLLog.info("[TextureDump] Unable to write: ", ioexception);
}
}
}
try
{
ImageIO.write(bufferedimage, "png", output);
FMLLog.info("[TextureDump] Exported png to: %s", output.getAbsolutePath());
}
catch (IOException ioexception)
{
FMLLog.info("[TextureDump] Unable to write: ", ioexception);
}
}
}
}