Merge in the mod texture changes from Lex

This commit is contained in:
Christian Weeks committed 2012-05-26 02:29:35 -04:00
commit da791ef721
3 files changed
+121 -117

No files matched your search

@@ -32,11 +32,12 @@ import static org.lwjgl.opengl.GL11.*;
public class ModTextureAnimation extends FMLTextureFX
{
private final int tickRate;
private final byte[][] images;
private byte[][] images;
private int index = 0;
private int ticks = 0;
private String targetTex = null;
private BufferedImage imgData = null;
public ModTextureAnimation(int icon, int target, BufferedImage image, int tickCount)
{
@@ -59,13 +60,18 @@ public class ModTextureAnimation extends FMLTextureFX
tickRate = tickCount;
ticks = tickCount;
imgData = image;
}
@Override
public void setup()
{
super.setup();
func_782_a(re);
int sWidth = image.getWidth();
int sHeight = image.getHeight();
int tWidth = GL11.glGetTexLevelParameteri(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH) >> 4;
int tHeight = GL11.glGetTexLevelParameteri(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT) >> 4;
int sWidth = imgData.getWidth();
int sHeight = imgData.getHeight();
int tWidth = tileSizeBase;
int tHeight = tileSizeBase;
int frames = (int)Math.floor((double)(sHeight / sWidth));
@@ -77,19 +83,13 @@ public class ModTextureAnimation extends FMLTextureFX
else
{
images = new byte[frames][];
if (tWidth != tileSizeBase || tHeight != tileSizeBase)
{
log.warning(String.format("Animation Override %s is not applied - there is a mismatch between the underlying texture (%s) size %d,%d and the current texture tile size %d", target, tWidth, tHeight, tileSizeBase));
errored = true;
return;
}
BufferedImage image = imgData;
if (sWidth != tWidth)
{
BufferedImage b = new BufferedImage(tWidth, tHeight * frames, 6);
Graphics2D g = b.createGraphics();
g.drawImage(image, 0, 0, tWidth, tHeight * frames, 0, 0, sWidth, sHeight, (ImageObserver)null);
g.drawImage(imgData, 0, 0, tWidth, tHeight * frames, 0, 0, sWidth, sHeight, (ImageObserver)null);
g.dispose();
image = b;
}
+27 -23
View File
@@ -31,6 +31,8 @@ public class ModTextureStatic extends FMLTextureFX
private int[] pixels = null;
private String targetTex = null;
private int storedSize;
private BufferedImage overrideData = null;
private int needApply = 2;
public ModTextureStatic(int icon, int target, BufferedImage image)
@@ -52,32 +54,27 @@ public class ModTextureStatic extends FMLTextureFX
storedSize = size;
field_1129_e = size;
field_1128_f = re.func_1070_a(target);
func_782_a(re);
overrideData = image;
}
@Override
public void setup()
{
super.setup();
int sWidth = overrideData.getWidth();
int sHeight = overrideData.getHeight();
int sWidth = image.getWidth();
int sHeight = image.getHeight();
int tWidth = GL11.glGetTexLevelParameteri(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH ) >> 4;
int tHeight = GL11.glGetTexLevelParameteri(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT) >> 4;
if (tWidth != tileSizeBase || tHeight != tileSizeBase)
{
log.warning(String.format("Override is not applied - there is a mismatch between the underlying texture (%s) size %d,%d and the current texture tile size %d", target, tWidth, tHeight, tileSizeBase));
errored=true;
return;
}
pixels = new int[tileSizeSquare];
if (tWidth == sWidth && tHeight == sHeight)
if (tileSizeBase == sWidth && tileSizeBase == sHeight)
{
image.getRGB(0, 0, sWidth, sHeight, pixels, 0, sWidth);
overrideData.getRGB(0, 0, sWidth, sHeight, pixels, 0, sWidth);
}
else
{
BufferedImage tmp = new BufferedImage(tWidth, tHeight, 6);
BufferedImage tmp = new BufferedImage(tileSizeBase, tileSizeBase, 6);
Graphics2D gfx = tmp.createGraphics();
gfx.drawImage(image, 0, 0, tWidth, tHeight, 0, 0, sWidth, sHeight, (ImageObserver)null);
tmp.getRGB(0, 0, tWidth, tHeight, pixels, 0, tWidth);
gfx.drawImage(overrideData, 0, 0, tileSizeBase, tileSizeBase, 0, 0, sWidth, sHeight, (ImageObserver)null);
tmp.getRGB(0, 0, tileSizeBase, tileSizeBase, pixels, 0, tileSizeBase);
gfx.dispose();
}
@@ -86,12 +83,17 @@ public class ModTextureStatic extends FMLTextureFX
public void func_783_a()
{
// Force the tile size to zero: generally we only need to stamp our static image once
field_1129_e = 0;
if (oldanaglyph != field_1131_c)
{
update();
field_1129_e = storedSize;
}
// This makes it so we only apply the texture to the target texture when we need to,
//due to the fact that update is called when the Effect is first registered, we actually
//need to wait for the next one.
field_1129_e = (needApply == 0 ? 0 : storedSize);
if (needApply > 0)
{
needApply--;
}
}
@@ -102,6 +104,7 @@ public class ModTextureStatic extends FMLTextureFX
public void update()
{
needApply = 2;
for (int idx = 0; idx < pixels.length; idx++)
{
int i = idx * 4;
@@ -169,7 +172,8 @@ public class ModTextureStatic extends FMLTextureFX
@Override
public String toString() {
public String toString()
{
return String.format("ModTextureStatic %s @ %d", targetTex, field_1126_b);
}
}
+79 -79
View File
@@ -1,79 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>FML-Client</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<linkedResources>
<link>
<name>client</name>
<type>2</type>
<locationURI>MCP_LOC/FML/client</locationURI>
</link>
<link>
<name>common</name>
<type>2</type>
<locationURI>MCP_LOC/FML/common</locationURI>
</link>
<link>
<name>jars</name>
<type>2</type>
<locationURI>MCP_LOC/jars</locationURI>
</link>
<link>
<name>src</name>
<type>2</type>
<locationURI>MCP_LOC/src-work/minecraft</locationURI>
</link>
<link>
<name>common/fmlversion.properties</name>
<type>1</type>
<location>/home/cpw/projects/mcworkspace/fmltestbed/FML/fmlversion.properties</location>
</link>
</linkedResources>
<filteredResources>
<filter>
<id>0</id>
<name>jars</name>
<type>13</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-bin</arguments>
</matcher>
</filter>
<filter>
<id>1307293504507</id>
<name>jars/bin</name>
<type>5</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-*.jar</arguments>
</matcher>
</filter>
<filter>
<id>1307293480435</id>
<name>jars/bin/natives</name>
<type>6</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-*</arguments>
</matcher>
</filter>
</filteredResources>
<variableList>
<variable>
<name>MCP_LOC</name>
<value>$%7BPARENT-2-WORKSPACE_LOC%7D</value>
</variable>
</variableList>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>FML-Client</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<linkedResources>
<link>
<name>client</name>
<type>2</type>
<locationURI>MCP_LOC/FML/client</locationURI>
</link>
<link>
<name>common</name>
<type>2</type>
<locationURI>MCP_LOC/FML/common</locationURI>
</link>
<link>
<name>jars</name>
<type>2</type>
<locationURI>MCP_LOC/jars</locationURI>
</link>
<link>
<name>src</name>
<type>2</type>
<locationURI>MCP_LOC/src-work/minecraft</locationURI>
</link>
<link>
<name>common/fmlversion.properties</name>
<type>1</type>
<locationURI>MCP_LOC/fml/common/fmlversion.properties</locationURI>
</link>
</linkedResources>
<filteredResources>
<filter>
<id>0</id>
<name>jars</name>
<type>13</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-bin</arguments>
</matcher>
</filter>
<filter>
<id>1307293504507</id>
<name>jars/bin</name>
<type>5</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-*.jar</arguments>
</matcher>
</filter>
<filter>
<id>1307293480435</id>
<name>jars/bin/natives</name>
<type>6</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-*</arguments>
</matcher>
</filter>
</filteredResources>
<variableList>
<variable>
<name>MCP_LOC</name>
<value>$%7BPARENT-2-WORKSPACE_LOC%7D</value>
</variable>
</variableList>
</projectDescription>