From e075a430e22e646e1b37469172dadfed531a986d Mon Sep 17 00:00:00 2001 From: LexManos Date: Thu, 24 May 2012 22:48:15 -0700 Subject: [PATCH 1/2] Fixed up ModTexture* classes to use the ITextureFX events to resize the image as needed. Also fixed ModTextureStatic's not being applied properly. --- .../minecraft/src/ModTextureAnimation.java | 30 +++++------ .../net/minecraft/src/ModTextureStatic.java | 50 ++++++++++--------- 2 files changed, 42 insertions(+), 38 deletions(-) diff --git a/client/net/minecraft/src/ModTextureAnimation.java b/client/net/minecraft/src/ModTextureAnimation.java index 780a08ff8f..8fd6bae237 100644 --- a/client/net/minecraft/src/ModTextureAnimation.java +++ b/client/net/minecraft/src/ModTextureAnimation.java @@ -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; } diff --git a/client/net/minecraft/src/ModTextureStatic.java b/client/net/minecraft/src/ModTextureStatic.java index 11e93209be..2839dffa61 100644 --- a/client/net/minecraft/src/ModTextureStatic.java +++ b/client/net/minecraft/src/ModTextureStatic.java @@ -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); } } From 49bca8998ac28e596d60d871e8faa31e7ab1c122 Mon Sep 17 00:00:00 2001 From: LexManos Date: Fri, 25 May 2012 23:25:05 -0700 Subject: [PATCH 2/2] Fixed location refs to fmlversion.properties --- eclipse/FML-Client/.project | 158 ++++++++++++++++++------------------ 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/eclipse/FML-Client/.project b/eclipse/FML-Client/.project index 04aedf6df0..9b5f768f2c 100644 --- a/eclipse/FML-Client/.project +++ b/eclipse/FML-Client/.project @@ -1,79 +1,79 @@ - - - FML-Client - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - - - client - 2 - MCP_LOC/FML/client - - - common - 2 - MCP_LOC/FML/common - - - jars - 2 - MCP_LOC/jars - - - src - 2 - MCP_LOC/src-work/minecraft - - - common/fmlversion.properties - 1 - /home/cpw/projects/mcworkspace/fmltestbed/FML/fmlversion.properties - - - - - 0 - jars - 13 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-bin - - - - 1307293504507 - jars/bin - 5 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-*.jar - - - - 1307293480435 - jars/bin/natives - 6 - - org.eclipse.ui.ide.multiFilter - 1.0-name-matches-false-false-* - - - - - - MCP_LOC - $%7BPARENT-2-WORKSPACE_LOC%7D - - - + + + FML-Client + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + + + client + 2 + MCP_LOC/FML/client + + + common + 2 + MCP_LOC/FML/common + + + jars + 2 + MCP_LOC/jars + + + src + 2 + MCP_LOC/src-work/minecraft + + + common/fmlversion.properties + 1 + MCP_LOC/fml/common/fmlversion.properties + + + + + 0 + jars + 13 + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-bin + + + + 1307293504507 + jars/bin + 5 + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-*.jar + + + + 1307293480435 + jars/bin/natives + 6 + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-* + + + + + + MCP_LOC + $%7BPARENT-2-WORKSPACE_LOC%7D + + +