Java Code Examples for org.spongepowered.api.block.BlockTypes#SANDSTONE

The following examples show how to use org.spongepowered.api.block.BlockTypes#SANDSTONE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RestoreNatureProcessingTask.java    From GriefPrevention with MIT License 6 votes vote down vote up
private void coverSurfaceStone() {
    for (int x = 1; x < snapshots.length - 1; x++) {
        for (int z = 1; z < snapshots[0][0].length - 1; z++) {
            int y = this.highestY(x, z, true);
            BlockSnapshot block = snapshots[x][y][z];

            if (block.getState().getType() == BlockTypes.STONE || block.getState().getType() == BlockTypes.GRAVEL
                    || block.getState().getType() == BlockTypes.FARMLAND
                    || block.getState().getType() == BlockTypes.DIRT || block.getState().getType() == BlockTypes.SANDSTONE) {
                if (this.biome == BiomeTypes.DESERT || this.biome == BiomeTypes.DESERT_HILLS || this.biome == BiomeTypes.BEACH) {
                    this.snapshots[x][y][z] = this.snapshots[x][y][z].withState(BlockTypes.SAND.getDefaultState());
                } else {
                    this.snapshots[x][y][z] = this.snapshots[x][y][z].withState(BlockTypes.GRASS.getDefaultState());
                }
            }
        }
    }
}
 
Example 2
Source File: RestoreNatureProcessingTask.java    From GriefPrevention with MIT License 5 votes vote down vote up
private void removeSandstone() {
    for (int x = 1; x < snapshots.length - 1; x++) {
        for (int z = 1; z < snapshots[0][0].length - 1; z++) {
            for (int y = snapshots[0].length - 2; y > miny; y--) {
                if (snapshots[x][y][z].getState().getType() != BlockTypes.SANDSTONE) {
                    continue;
                }

                BlockSnapshot leftBlock = this.snapshots[x + 1][y][z];
                BlockSnapshot rightBlock = this.snapshots[x - 1][y][z];
                BlockSnapshot upBlock = this.snapshots[x][y][z + 1];
                BlockSnapshot downBlock = this.snapshots[x][y][z - 1];
                BlockSnapshot underBlock = this.snapshots[x][y - 1][z];
                BlockSnapshot aboveBlock = this.snapshots[x][y + 1][z];

                // skip blocks which may cause a cave-in
                if (aboveBlock.getState().getType() == BlockTypes.SAND && underBlock.getState().getType() == BlockTypes.AIR) {
                    continue;
                }

                // count adjacent non-air/non-leaf blocks
                if (leftBlock.getState().getType() == BlockTypes.SAND ||
                        rightBlock.getState().getType() == BlockTypes.SAND ||
                        upBlock.getState().getType() == BlockTypes.SAND ||
                        downBlock.getState().getType() == BlockTypes.SAND ||
                        aboveBlock.getState().getType() == BlockTypes.SAND ||
                        underBlock.getState().getType() == BlockTypes.SAND) {
                    snapshots[x][y][z] = snapshots[x][y][z].withState(BlockTypes.SAND.getDefaultState());
                } else {
                    snapshots[x][y][z] = snapshots[x][y][z].withState(BlockTypes.AIR.getDefaultState());
                }
            }
        }
    }
}
 
Example 3
Source File: RestoreNatureProcessingTask.java    From GriefPrevention with MIT License 4 votes vote down vote up
private void reduceStone() {
    if (this.seaLevel < 1) {
        return;
    }

    for (int x = 1; x < snapshots.length - 1; x++) {
        for (int z = 1; z < snapshots[0][0].length - 1; z++) {
            int thisy = this.highestY(x, z, true);

            while (thisy > this.seaLevel - 1 && (this.snapshots[x][thisy][z].getState().getType() == BlockTypes.STONE
                    || this.snapshots[x][thisy][z].getState().getType() == BlockTypes.SANDSTONE)) {
                BlockSnapshot leftBlock = this.snapshots[x + 1][thisy][z];
                BlockSnapshot rightBlock = this.snapshots[x - 1][thisy][z];
                BlockSnapshot upBlock = this.snapshots[x][thisy][z + 1];
                BlockSnapshot downBlock = this.snapshots[x][thisy][z - 1];

                // count adjacent non-air/non-leaf blocks
                byte adjacentBlockCount = 0;
                if (leftBlock.getState().getType() != BlockTypes.AIR && leftBlock.getState().getType() != BlockTypes.LEAVES
                        && leftBlock.getState().getType() != BlockTypes.VINE) {
                    adjacentBlockCount++;
                }
                if (rightBlock.getState().getType() != BlockTypes.AIR && rightBlock.getState().getType() != BlockTypes.LEAVES
                        && rightBlock.getState().getType() != BlockTypes.VINE) {
                    adjacentBlockCount++;
                }
                if (downBlock.getState().getType() != BlockTypes.AIR && downBlock.getState().getType() != BlockTypes.LEAVES
                        && downBlock.getState().getType() != BlockTypes.VINE) {
                    adjacentBlockCount++;
                }
                if (upBlock.getState().getType() != BlockTypes.AIR && upBlock.getState().getType() != BlockTypes.LEAVES
                        && upBlock.getState().getType() != BlockTypes.VINE) {
                    adjacentBlockCount++;
                }

                if (adjacentBlockCount < 3) {
                    this.snapshots[x][thisy][z] = this.snapshots[x][thisy][z].withState(BlockTypes.AIR.getDefaultState());
                }

                thisy--;
            }
        }
    }
}