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

The following examples show how to use org.spongepowered.api.block.BlockTypes#WATER . 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 removeHanging() {
    int miny = this.miny;
    if (miny < 1) {
        miny = 1;
    }

    for (int x = 1; x < snapshots.length - 1; x++) {
        for (int z = 1; z < snapshots[0][0].length - 1; z++) {
            for (int y = miny; y < snapshots[0].length - 1; y++) {
                BlockSnapshot block = snapshots[x][y][z];
                BlockSnapshot underBlock = snapshots[x][y - 1][z];

                if (underBlock.getState().getType() == BlockTypes.AIR || underBlock.getState().getType() == BlockTypes.WATER
                        || underBlock.getState().getType() == BlockTypes.LAVA || underBlock.getState().getType() == BlockTypes.LEAVES) {
                    if (this.notAllowedToHang.contains(block.getState().getType())) {
                        snapshots[x][y][z] = block.withState(BlockTypes.AIR.getDefaultState());
                    }
                }
            }
        }
    }
}
 
Example 2
Source File: RestoreNatureProcessingTask.java    From GriefPrevention with MIT License 6 votes vote down vote up
private void removeDumpedFluids() {
    if (this.seaLevel < 1) {
        return;
    }

    // remove any surface water or lava above sea level, presumed to be
    // placed by players
    // sometimes, this is naturally generated. but replacing it is very easy
    // with a bucket, so overall this is a good plan
    if (this.environment.equals(DimensionTypes.NETHER)) {
        return;
    }
    for (int x = 1; x < snapshots.length - 1; x++) {
        for (int z = 1; z < snapshots[0][0].length - 1; z++) {
            for (int y = this.seaLevel - 1; y < snapshots[0].length - 1; y++) {
                BlockSnapshot block = snapshots[x][y][z];
                if (block.getState().getType() == BlockTypes.WATER || block.getState().getType() == BlockTypes.LAVA ||
                        block.getState().getType() == BlockTypes.WATER || block.getState().getType() == BlockTypes.LAVA) {
                    snapshots[x][y][z] = block.withState(BlockTypes.AIR.getDefaultState());
                }
            }
        }
    }
}
 
Example 3
Source File: RestoreNatureProcessingTask.java    From GriefPrevention with MIT License 6 votes vote down vote up
private int highestY(int x, int z, boolean ignoreLeaves) {
    int y;
    for (y = snapshots[0].length - 1; y > 0; y--) {
        BlockSnapshot block = this.snapshots[x][y][z];
        if (block.getState().getType() != BlockTypes.AIR &&
                !(ignoreLeaves && block.getState().getType() == BlockTypes.SNOW) &&
                !(ignoreLeaves && block.getState().getType() == BlockTypes.LEAVES) &&
                !(block.getState().getType() == BlockTypes.WATER) &&
                !(block.getState().getType() == BlockTypes.FLOWING_WATER) &&
                !(block.getState().getType() == BlockTypes.LAVA) &&
                !(block.getState().getType() == BlockTypes.FLOWING_LAVA)) {
            return y;
        }
    }

    return y;
}
 
Example 4
Source File: GPClaim.java    From GriefPrevention with MIT License 5 votes vote down vote up
boolean hasSurfaceFluids() {
    Location<World> lesser = this.getLesserBoundaryCorner();
    Location<World> greater = this.getGreaterBoundaryCorner();

    // don't bother for very large claims, too expensive
    if (this.getClaimBlocks() > MAX_AREA) {
        return false;
    }

    int seaLevel = 0; // clean up all fluids in the end

    // respect sea level in normal worlds
    if (lesser.getExtent().getDimension().getType().equals(DimensionTypes.OVERWORLD)) {
        seaLevel = GriefPreventionPlugin.instance.getSeaLevel(lesser.getExtent());
    }

    for (int x = lesser.getBlockX(); x <= greater.getBlockX(); x++) {
        for (int z = lesser.getBlockZ(); z <= greater.getBlockZ(); z++) {
            for (int y = seaLevel - 1; y < lesser.getExtent().getDimension().getBuildHeight(); y++) {
                // dodge the exclusion claim
                BlockState block = lesser.getExtent().getBlock(x, y, z);

                if (block.getType() == BlockTypes.WATER || block.getType() == BlockTypes.FLOWING_WATER
                        || block.getType() == BlockTypes.LAVA || block.getType() == BlockTypes.FLOWING_LAVA) {
                    return true;
                }
            }
        }
    }

    return false;
}
 
Example 5
Source File: GPClaim.java    From GriefPrevention with MIT License 4 votes vote down vote up
public void removeSurfaceFluids(GPClaim exclusionClaim) {
    // don't do this for administrative claims
    if (this.isAdminClaim()) {
        return;
    }

    // don't do it for very large claims
    if (this.getClaimBlocks() > MAX_AREA) {
        return;
    }

    // only in creative mode worlds
    if (!GriefPreventionPlugin.instance.claimModeIsActive(this.lesserBoundaryCorner.getExtent().getProperties(), ClaimsMode.Creative)) {
        return;
    }

    Location<World> lesser = this.getLesserBoundaryCorner();
    Location<World> greater = this.getGreaterBoundaryCorner();

    if (lesser.getExtent().getDimension().getType().equals(DimensionTypes.NETHER)) {
        return; // don't clean up lava in the nether
    }

    int seaLevel = 0; // clean up all fluids in the end

    // respect sea level in normal worlds
    if (lesser.getExtent().getDimension().getType().equals(DimensionTypes.OVERWORLD)) {
        seaLevel = GriefPreventionPlugin.instance.getSeaLevel(lesser.getExtent());
    }

    for (int x = lesser.getBlockX(); x <= greater.getBlockX(); x++) {
        for (int z = lesser.getBlockZ(); z <= greater.getBlockZ(); z++) {
            for (int y = seaLevel - 1; y < lesser.getExtent().getDimension().getBuildHeight(); y++) {
                // dodge the exclusion claim
                BlockSnapshot block = lesser.getExtent().createSnapshot(x, y, z);
                if (exclusionClaim != null && exclusionClaim.contains(block.getLocation().get(), false)) {
                    continue;
                }

                if (block.getState().getType() == BlockTypes.LAVA || block.getState().getType() == BlockTypes.FLOWING_WATER
                        || block.getState().getType() == BlockTypes.WATER || block.getState().getType() == BlockTypes.FLOWING_LAVA) {
                    block.withState(BlockTypes.AIR.getDefaultState()).restore(true, BlockChangeFlags.PHYSICS);
                }
            }
        }
    }
}