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

The following examples show how to use org.spongepowered.api.block.BlockTypes#FLOWING_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 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 2
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 3
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);
                }
            }
        }
    }
}