for(int i=1;i<8;i++) { ml = new MapLayer(ret, ret.getWidth(),ret.getHeight()); ml.setName("Layer "+i); ret.addLayer(ml); } readBKDTChunk(ret, c.getInputStream(), numBlocks);  c = findChunk("BGFX"); if(c != null) {
c = findChunk("BGFX"); if(c != null) {
    private Map readMPHDChunk(InputStream in) throws IOException {	Map ret = null;	TileSet set = new TileSet();	int major, minor;	major = in.read();	minor = in.read();	in.skip(2);	//skip lsb and reserved bytes - always msb	ret = new Map(readShort(in), readShort(in));	ret.addProperty("(s)fmap reader","Don't modify properties marked (s) unless you really know what you're doing.");	ret.addProperty("version",""+major+"."+minor);	in.skip(4);	//reserved	twidth = readShort(in);	theight = readShort(in);	set.setStandardWidth(twidth);	set.setStandardHeight(theight);	ret.setTileWidth(twidth);	ret.setTileHeight(theight);	set.setName("Static tiles");	ret.addTileset(set);	int depth = readShort(in);	if(depth<16) {		throw new IOException("Tile bitdepths less than 16 are not supported!");	}	ret.addProperty("(s)depth",""+depth);	in.skip(2);	int numBlocks = readShort(in);	int numBlocksGfx = readShort(in);	Chunk c = findChunk("BKDT");	if(c == null) {		throw new IOException("No BKDT block found!");	}	MapLayer ml = new MapLayer(ret, ret.getWidth(),ret.getHeight());	ml.setName("bg");	ret.addLayer(ml);	ml = new MapLayer(ret, ret.getWidth(),ret.getHeight());	ml.setName("fg 1");	ret.addLayer(ml);	ml = new MapLayer(ret, ret.getWidth(),ret.getHeight());	ml.setName("fg 2");	ret.addLayer(ml);	ml = new MapLayer(ret, ret.getWidth(),ret.getHeight());	ml.setName("fg 3");	ret.addLayer(ml);		for(int i=1;i<8;i++) {		ml = new MapLayer(ret, ret.getWidth(),ret.getHeight());		ml.setName("Layer "+i);		ret.addLayer(ml);	}	readBKDTChunk(ret, c.getInputStream(), numBlocks);	c = findChunk("BGFX");	if(c != null) {            readBGFXChunk(ret, c.getInputStream(), numBlocksGfx);        }else{            throw new IOException("No BGFX chunk found!");        }	System.out.println(ret.toString());	return ret;    }