[Solved] A problem with my Voxel Engine

I made a simple voxel engine, and I was working on the chunk class, and I got an error. I have worked with allot of arrays in the past. I barely know why this isn’t working.

Chunk:


package passage.games.pdday.world;

import passage.games.pdday.block.Block;
import passage.games.pdday.block.BlockType;

public class Chunk {
	public static final int BLOCKS_SIZE_X = 16;
	public static final int BLOCKS_SIZE_Y = 16;
	public static final int BLOCKS_SIZE_Z = 16;

	public static final int BLOCK_SIZE = 16;

	public final Block[][][] blocks = new Block[BLOCKS_SIZE_X][BLOCKS_SIZE_Y][BLOCKS_SIZE_Z];

	public void init() {
		for (int x = 0; x < BLOCKS_SIZE_X; x++) {
			for (int y = 0; y < BLOCKS_SIZE_Y; y++) {
				for (int z = 0; z < BLOCKS_SIZE_Z; y++) {
	                   /*Error here--> */ blocks[x][y][z] = new Block(BlockType.AIR, x * BLOCK_SIZE, y * BLOCK_SIZE, z * BLOCK_SIZE);
				}
			}
		}
	}

	public void render() {
		for (int x = 0; x < BLOCKS_SIZE_X - 1; x++) {
			for (int y = 0; y < BLOCKS_SIZE_Y - 1; y++) {
				for (int z = 0; z < BLOCKS_SIZE_Z - 1; y++) {
					blocks[x][y][z].render();
				}
			}
		}
	}
}

Exception:


Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 16
	at passage.games.pdday.world.Chunk.init(Chunk.java:19)
	at passage.games.pdday.Main.init(Main.java:51)
	at passage.games.pdday.Main.<init>(Main.java:38)
	at passage.games.pdday.Main.main(Main.java:76)

EDIT:
The “Block” translates with glTranslate. That’s why there is a x * BLOCK_SIZE there, so they translate properly.

You’re incrementing the y variable in both z-loops.

Just read your code for like 3 minutes before you post it here. You put a y++ iterator on the z loop.

My bad, thanks guys.