Lots of error handling.
This commit is contained in:
parent
dd94427f22
commit
88f3c4f9bd
4 changed files with 63 additions and 36 deletions
|
@ -81,8 +81,8 @@ public class SpriteHelper
|
|||
initMCSpriteMaps();
|
||||
}
|
||||
if (spriteInfo.containsKey(file)) {
|
||||
FMLCommonHandler.instance().getFMLLogger().severe(String.format("Duplicate attempt to register a sprite file %s for overriding",file));
|
||||
FMLCommonHandler.instance().raiseException(new LoaderException(),"Sprite override alert", true);
|
||||
FMLCommonHandler.instance().getFMLLogger().finer(String.format("Duplicate attempt to register a sprite file %s for overriding -- ignoring",file));
|
||||
return;
|
||||
}
|
||||
spriteInfo.put(file, toBitSet(spriteMap));
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.awt.image.ImageObserver;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
/**
|
||||
|
@ -53,8 +54,8 @@ public class ModTextureAnimation extends TextureFX
|
|||
|
||||
targetTex = target;
|
||||
field_1129_e = size;
|
||||
field_1128_f = re.func_1070_a(target);
|
||||
|
||||
field_1128_f = re.func_1070_a(target);
|
||||
|
||||
tickRate = tickCount;
|
||||
ticks = tickCount;
|
||||
|
||||
|
@ -62,8 +63,9 @@ public class ModTextureAnimation extends TextureFX
|
|||
|
||||
int sWidth = image.getWidth();
|
||||
int sHeight = image.getHeight();
|
||||
int tWidth = GL11.glGetTexLevelParameteri(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH) / 16;
|
||||
int tHeight = GL11.glGetTexLevelParameteri(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT) / 16;
|
||||
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 frames = (int)Math.floor((double)(sHeight / sWidth));
|
||||
|
||||
|
@ -75,6 +77,13 @@ public class ModTextureAnimation extends TextureFX
|
|||
{
|
||||
images = new byte[frames][];
|
||||
|
||||
if (tWidth != TextureFX.iconTileSize || tHeight != TextureFX.iconTileSize)
|
||||
{
|
||||
FMLCommonHandler.instance().getFMLLogger().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, TextureFX.iconTileSize));
|
||||
errored = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (sWidth != tWidth)
|
||||
{
|
||||
BufferedImage b = new BufferedImage(tWidth, tHeight * frames, 6);
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.awt.image.ImageObserver;
|
|||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import static org.lwjgl.opengl.GL11.*;
|
||||
|
||||
public class ModTextureStatic extends TextureFX
|
||||
|
@ -28,6 +29,7 @@ public class ModTextureStatic extends TextureFX
|
|||
private boolean oldanaglyph = false;
|
||||
private int[] pixels = null;
|
||||
private String targetTex = null;
|
||||
private int storedSize;
|
||||
|
||||
|
||||
public ModTextureStatic(int icon, int target, BufferedImage image)
|
||||
|
@ -46,6 +48,7 @@ public class ModTextureStatic extends TextureFX
|
|||
RenderEngine re = FMLClientHandler.instance().getClient().field_6315_n;
|
||||
|
||||
targetTex = target;
|
||||
storedSize = size;
|
||||
field_1129_e = size;
|
||||
field_1128_f = re.func_1070_a(target);
|
||||
|
||||
|
@ -53,13 +56,17 @@ public class ModTextureStatic extends TextureFX
|
|||
|
||||
int sWidth = image.getWidth();
|
||||
int sHeight = image.getHeight();
|
||||
int tWidth = GL11.glGetTexLevelParameteri(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH ) / 16;
|
||||
int tHeight = GL11.glGetTexLevelParameteri(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT) / 16;
|
||||
|
||||
pixels = new int[tWidth * tHeight];
|
||||
field_1127_a = new byte[tWidth * tHeight * 4];
|
||||
|
||||
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 != TextureFX.iconTileSize || tHeight != TextureFX.iconTileSize)
|
||||
{
|
||||
FMLCommonHandler.instance().getFMLLogger().warning(String.format("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, TextureFX.iconTileSize));
|
||||
errored=true;
|
||||
return;
|
||||
}
|
||||
pixels = new int[TextureFX.iconTileSize];
|
||||
|
||||
if (tWidth == sWidth && tHeight == sHeight)
|
||||
{
|
||||
image.getRGB(0, 0, sWidth, sHeight, pixels, 0, sWidth);
|
||||
|
@ -78,9 +85,12 @@ public class ModTextureStatic extends TextureFX
|
|||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,17 +165,10 @@ public class ModTextureStatic extends TextureFX
|
|||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.src.TextureFX#unregister(net.minecraft.src.RenderEngine)
|
||||
*/
|
||||
@Override
|
||||
public boolean unregister(RenderEngine engine)
|
||||
{
|
||||
if (this.getClass()==ModTextureStatic.class) {
|
||||
return super.unregister(engine);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
public String toString() {
|
||||
return String.format("ModTextureStatic %s @ %d", targetTex, field_1126_b);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,11 +9,12 @@
|
|||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -13,9 +16,15 @@
|
||||
@@ -13,9 +16,16 @@
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
+import java.util.logging.Level;
|
||||
+import java.util.logging.Logger;
|
||||
+
|
||||
import javax.imageio.ImageIO;
|
||||
+
|
||||
|
@ -25,7 +26,7 @@
|
|||
public class RenderEngine
|
||||
{
|
||||
public static boolean field_1609_a = false;
|
||||
@@ -24,7 +33,7 @@
|
||||
@@ -24,7 +34,7 @@
|
||||
private IntHashMap field_1607_c = new IntHashMap();
|
||||
private IntBuffer field_1606_d = GLAllocation.func_1125_c(1);
|
||||
private ByteBuffer field_1605_e = GLAllocation.func_1127_b(16777216);
|
||||
|
@ -34,15 +35,26 @@
|
|||
private Map field_1603_g = new HashMap();
|
||||
private GameSettings field_1602_h;
|
||||
public boolean field_4281_i = false;
|
||||
@@ -97,6 +106,7 @@
|
||||
@@ -32,6 +42,7 @@
|
||||
private TexturePackList field_6527_k;
|
||||
private BufferedImage field_25189_l = new BufferedImage(64, 64, 2);
|
||||
private int field_48512_n = 16;
|
||||
+ public static Logger log = FMLCommonHandler.instance().getFMLLogger();
|
||||
|
||||
public RenderEngine(TexturePackList p_i754_1_, GameSettings p_i754_2_)
|
||||
{
|
||||
@@ -95,8 +106,9 @@
|
||||
this.field_28151_c.put(p_28149_1_, var3);
|
||||
return var3;
|
||||
}
|
||||
catch (IOException var5)
|
||||
- catch (IOException var5)
|
||||
+ catch (Exception var5)
|
||||
{
|
||||
+ FMLCommonHandler.instance().getFMLLogger().log(Level.INFO,String.format("An error occured reading texture file %s (getTexture)", p_28149_1_),var5);
|
||||
+ log.log(Level.INFO,String.format("An error occured reading texture file %s (getTexture)", p_28149_1_),var5);
|
||||
var5.printStackTrace();
|
||||
int[] var4 = this.func_28148_b(this.field_25189_l);
|
||||
this.field_28151_c.put(p_28149_1_, var4);
|
||||
@@ -459,8 +469,17 @@
|
||||
@@ -459,8 +471,17 @@
|
||||
for (int var2 = 0; var2 < this.field_1604_f.size(); ++var2)
|
||||
{
|
||||
TextureFX var3 = (TextureFX)this.field_1604_f.get(var2);
|
||||
|
@ -53,7 +65,7 @@
|
|||
+ try {
|
||||
+ var3.func_783_a();
|
||||
+ } catch (Exception e) {
|
||||
+ FMLCommonHandler.instance().getFMLLogger().warning(String.format("Texture FX %s has failed to animate. Likely caused by a texture pack change that they did not respond correctly to",var3.getClass().getSimpleName()));
|
||||
+ log.warning(String.format("Texture FX %s has failed to animate. Likely caused by a texture pack change that they did not respond correctly to",var3.getClass().getSimpleName()));
|
||||
+ var3.errored=true;
|
||||
+ continue;
|
||||
+ }
|
||||
|
@ -61,12 +73,12 @@
|
|||
this.field_1605_e.clear();
|
||||
this.field_1605_e.put(var3.field_1127_a);
|
||||
this.field_1605_e.position(0).limit(var3.field_1127_a.length);
|
||||
@@ -470,12 +489,17 @@
|
||||
@@ -470,12 +491,17 @@
|
||||
var3.func_782_a(this);
|
||||
var1 = var3.field_1126_b;
|
||||
}
|
||||
+ if (var3.field_1127_a.length!=TextureFX.tileSizeSquare<<2) {
|
||||
+ FMLCommonHandler.instance().getFMLLogger().warning(String.format("Detected a texture FX discrepancy in %s (%d, %d)",var3.getClass().getSimpleName(), var3.field_1127_a.length, var3.tileSizeSquare<<2));
|
||||
+ log.warning(String.format("Detected a texture FX sizing discrepancy in %s (%d, %d)",var3.getClass().getSimpleName(), var3.field_1127_a.length, var3.tileSizeSquare<<2));
|
||||
+ var3.errored=true;
|
||||
+ continue;
|
||||
+ }
|
||||
|
@ -80,22 +92,25 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
@@ -577,8 +601,9 @@
|
||||
@@ -577,8 +603,9 @@
|
||||
this.field_4280_j = false;
|
||||
this.field_4281_i = false;
|
||||
}
|
||||
- catch (IOException var7)
|
||||
+ catch (Exception var7)
|
||||
{
|
||||
+ FMLCommonHandler.instance().getFMLLogger().log(Level.INFO,String.format("An error occured reading texture file %s (refreshTexture)", var9),var7);
|
||||
+ log.log(Level.INFO,String.format("An error occured reading texture file %s (refreshTexture)", var9),var7);
|
||||
var7.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -616,9 +641,28 @@
|
||||
@@ -614,11 +641,30 @@
|
||||
this.field_4280_j = false;
|
||||
this.field_4281_i = false;
|
||||
}
|
||||
catch (IOException var6)
|
||||
- catch (IOException var6)
|
||||
+ catch (Exception var6)
|
||||
{
|
||||
+ FMLCommonHandler.instance().getFMLLogger().log(Level.INFO,String.format("An error occured reading texture file data %s (refreshTexture)", var9),var6);
|
||||
+ log.log(Level.INFO,String.format("An error occured reading texture file data %s (refreshTexture)", var9),var6);
|
||||
var6.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue