case WEST_EAST:
final int wid = (int) Math.ceil(width / 2.0f);
for (int xs = 0; xs < wid; ++xs) {
for (int z = 0; z < length; ++z) {
for (int y = 0; y < height; ++y) {
final BaseBlock block1 = data[xs][y][z];
if (block1 != null) {
block1.flip(dir);
}
// Skip the center plane
if (xs == width - xs - 1) {
continue;
}
final BaseBlock block2 = data[width - xs - 1][y][z];
if (block2 != null) {
block2.flip(dir);
}
data[xs][y][z] = block2;
data[width - xs - 1][y][z] = block1;
}
}
}
if (aroundPlayer) {
offset = offset.setX(1 - offset.getX() - width);
}
break;
case NORTH_SOUTH:
final int len = (int) Math.ceil(length / 2.0f);
for (int zs = 0; zs < len; ++zs) {
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
final BaseBlock block1 = data[x][y][zs];
if (block1 != null) {
block1.flip(dir);
}
// Skip the center plane
if (zs == length - zs - 1) {
continue;
}
final BaseBlock block2 = data[x][y][length - zs - 1];
if (block2 != null) {
block2.flip(dir);
}
data[x][y][zs] = block2;
data[x][y][length - zs - 1] = block1;
}
}
}
if (aroundPlayer) {
offset = offset.setZ(1 - offset.getZ() - length);
}
break;
case UP_DOWN:
final int hei = (int) Math.ceil(height / 2.0f);
for (int ys = 0; ys < hei; ++ys) {
for (int x = 0; x < width; ++x) {
for (int z = 0; z < length; ++z) {
final BaseBlock block1 = data[x][ys][z];
if (block1 != null) {
block1.flip(dir);
}
// Skip the center plane
if (ys == height - ys - 1) {
continue;
}
final BaseBlock block2 = data[x][height - ys - 1][z];
if (block2 != null) {
block2.flip(dir);
}
data[x][ys][z] = block2;
data[x][height - ys - 1][z] = block1;
}