Sorry I forgot to mention it, move up and down with E and SHIFT.
Here's the relevant code
int[][][] cells = new int[size][size][size];
cells[10][10][10] = 1;
cells[10][10][11] = 1;
cells[10][10][12] = 1;
cells[11][11][10] = 1;
cells[10][11][11] = 1;
cells[10][11][12] = 1;
cells[11][4][10] = 3;
cells[11][4][11] = 3;
cells[11][4][12] = 3;
cells[12][4][10] = 3;
cells[12][4][11] = 3;
cells[12][4][12] = 3;
cells[10][4][10] = 3;
cells[10][4][11] = 3;
cells[10][4][12] = 3;
while (f.isVisible()) {
int[][][] tempcells = new int[size][size][size];
for (int x = 1; x < size - 1; x++) {
for (int y = 1; y < size - 1; y++) {
System.arraycopy(cells[x][y], 0, tempcells[x][y], 0, tempcells[x][y].length);
}
}
for (int x = 1; x < size - 1; x++) {
for (int y = 1; y < size - 1; y++) {
for (int z = 1; z < size - 1; z++) {
if (simtype == 0) {
tempcells[x][y][z] = rule3DGOL(x, y, z, sumCells(cells, x, y, z), cells);
} else if (simtype == 1) {
tempcells[x][y][z] = ruleFlow(x, y, z, sumCells(cells, x, y, z), cells);
}
}
}
}
cells = tempcells;
DisplayList dl = new DisplayList();
int cubes = 0;
for (int x = 1; x < size - 1; x++) {
for (int y = 1; y < size - 1; y++) {
for (int z = 1; z < size - 1; z++) {
if (cells[x][y][z] > 0) {
cubes++;
Cube c = new Cube(new Point3D(x, y, -z), new Point3D(.45, .45, .45), dl);
c.setMaterial(new Material(new Color(cells[x][y][z] * 50, 255 - cells[x][y][z] * 50, 0), Color.white, Color.black, 63, null), dl);
}
}
}
}
totalc = cubes;
displist = dl;
try {
Thread.sleep(10 * delay);
} catch (Exception e) {
}
}
static public int sumCells(int[][][] i, int x, int y, int z) {
return i[++x][y][z] + i[x][++y][z] + i[x][y][z + 1] + i[x][--y][z + 1] + i[x][--y][z + 1] + i[x][y][z] + i[x][y][z - 1] + i[x][++y][z - 1] + i[x][++y][z - 1] +
i[--x][y][z] + i[x][y][z + 1] + i[x][--y][z + 1] + i[x][--y][z + 1] + i[x][y][z] + i[x][y][z - 1] + i[x][++y][z - 1] + i[x][++y][z - 1] +
i[--x][y][z] + i[x][y][z] + i[x][y][z + 1] + i[x][--y][z + 1] + i[x][--y][z + 1] + i[x][y][z] + i[x][y][z - 1] + i[x][++y][z - 1] + i[x][++y][z - 1];
}
static public int rule3DGOL(int x, int y, int z, int sum, int[][][] i) {
if (sum == 2 || sum == 3 && i[x][y][z] == 1) {
return 1;
} else if (sum == 3 && i[x][y][z] == 0) {
return 1;
} else if (sum == 4 || sum == 5 && i[x][y][z] == 2) {
return 2;
} else if (sum == 5 && i[x][y][z] == 1) {
return 2;
} else if (sum == 6 || sum == 7 && i[x][y][z] == 3) {
return 3;
} else if (sum == 7 && i[x][y][z] == 2) {
return 3;
} else if (sum == 8 || sum == 9 && i[x][y][z] == 4) {
return 4;
} else if (sum == 9 && i[x][y][z] == 3) {
return 4;
} else if (sum < 2 || sum > 9 && i[x][y][z] == 1) {
return 0;
} else {
return 0;
}
}
static public int ruleFlow(int x, int y, int z, int sum, int[][][] i) {
if (i[x][y][z] == 0 && i[x][y + 1][z] == 1) {
return 1;
} else if ((i[x + 1][y][z] == 1 || i[x][y][z + 1] == 1 || i[x - 1][y][z] == 1 || i[x][y][z - 1] == 1) && i[x][y - 1][z] == 3 && i[x][y][z] == 0) {
return 1;
} else if (((i[x + 1][y][z] == 1 && i[x + 1][y - 1][z] == 3)
|| (i[x][y][z + 1] == 1 && i[x][y - 1][z + 1] == 3)
|| (i[x - 1][y][z] == 1 && i[x - 1][y - 1][z] == 3)
|| (i[x][y][z - 1] == 1 && i[x][y - 1][z - 1] == 3))
&& i[x][y - 1][z] == 0 && i[x][y][z] == 0) {
return 1;
} else if (((i[x + 1][y - 1][z] == 0)
|| (i[x][y - 1][z + 1] == 0)
|| (i[x - 1][y - 1][z] == 0)
|| (i[x][y - 1][z - 1] == 0))
&& i[x][y - 1][z] == 3 && i[x][y][z] == 1) {
return 0;
} else if (i[x][y][z] == 1 && i[x][y + 1][z] == 0) {
return 0;
} else {
return i[x][y][z];
}
}