Cool. Could you also tell me a bit where you copied the original code from? As Draco pointed out your "a" variable gets slightly out of hand. This is most likely because of your 3 loops:
for(int j = 0; j < 5; j++)
{
for(int k = 0; k < 5; k++)
{
...
for (int n = 0; n < 33; n++)
{
This can actually get you up to 5 x 5 x 33 = 825 pretty quickly. It's likely you want int j = 0; j < 4 , int k = 0; k < 4, int n = 0; n < 32 which should index the heightmap up to 512 = 4 x 4 x 32 .
Exception helps you out by pointing: java.lang.ArrayIndexOutOfBoundsException: 513
at harry.harrysmod.world.dimension.NormalTerrainGen.generateHeightmap(NormalTerrainGen.java:160)
So it's likely value 513 for the indexing variable "a" is the ofender while previous values (e.g. 512) were not, hence my idea of limiting it to 512.