You can not put a try/catch
at the class level, only inside a constructor, a method or an initializer block. That's what's causing the error reported. Try moving the code inside the constructor, assuming that defaultTexture
is an attribute:
public class EmptyTile extends TileEntity {
public EmptyTile(int x, int y, int height, int width, Texture texture) {
super(x, y, height, width, texture);
try {
defaultTexture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("stone.png"));
} catch (IOException e) {
e.printStackTrace();
}
}
}
But if defaultTexture
is an static attribute, then use a static initializer block:
public class EmptyTile extends TileEntity {
static {
try {
defaultTexture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream("stone.png"));
} catch (IOException e) {
e.printStackTrace();
}
}
public EmptyTile(int x, int y, int height, int width, Texture texture) {
super(x, y, height, width, texture);
}
}