private boolean rotate(Shape shape, int rotation) {
        shape.rotate(rotation);
        int x, y, z;
        boolean[][][] shapeMatrix = shape.getMatrix();

        for (int i = 0; i < shapeMatrix.length; ++i) {
            for (int j = 0; j < shapeMatrix[i].length; ++j) {
                for (int k = 0; k < shapeMatrix[i][j].length; ++k) {
                    x = i + shape.getDesfX();
                    y = j + shape.getDesfY();
                    z = k + shape.getLevel();
                    if (x < matrix.length && y < matrix[0].length && z < matrix[0][0].length) {
                        if (matrix[x][y][z] && shapeMatrix[i][j][k]) {
                            for (int p = 0; p < 3; ++p) {
                                shape.rotate(rotation);
                            }
                            return false;
                        }
                    }

                }
            }
        }

        return true;
    }