} catch (NumberFormatException nfe) {
super.throwChunkException("Cannot find Layer index, invalid chunk name :: chunkName=[" + super.getChunkName() + "]");
}
}
Layer layer = new Layer(map.getMapHeader(), mapLayer, map.getBlocks(), map.getAnimBlocks());
// make sure the layers array is large enough to accomodate the new layer
if ((layerIndex + 1) > map.getLayers().length) {
Layer[] layers = new Layer[layerIndex + 1];
System.arraycopy(map.getLayers(), 0, layers, 0, map.getLayers().length);