Java Code Examples for org.bukkit.Material#STATIONARY_WATER

The following examples show how to use org.bukkit.Material#STATIONARY_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: BlockBreakSpeedSurvival.java    From Hawk with GNU General Public License v3.0 6 votes vote down vote up
private boolean a(HawkPlayer pp) {
    Vector position = pp.getPosition();
    double d0 = position.getY() + 1.62;
    int i = floor(position.getX());
    int j = (int)d((float)floor(d0));
    int k = floor(position.getZ());
    Block block = ServerUtils.getBlockAsync(new Location(pp.getWorld(), i, j, k));
    if(block == null)
        return false;
    if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER) {
        float f = b(block.getData()) - 0.11111111F;
        float f1 = (float)(j + 1) - f;
        return d0 < (double)f1;
    } else {
        return false;
    }
}
 
Example 2
Source File: Strafe.java    From Hawk with GNU General Public License v3.0 5 votes vote down vote up
private boolean testLiquid(Set<Material> mats) {
    for(Material mat : mats) {
        if(mat == Material.WATER || mat == Material.STATIONARY_WATER || mat == Material.LAVA || mat == Material.STATIONARY_LAVA)
            return true;
    }
    return false;
}
 
Example 3
Source File: MoveEvent.java    From Hawk with GNU General Public License v3.0 5 votes vote down vote up
private Vector computeWaterFlowForce() {
    Vector finalForce = new Vector();
    for(Pair<Block, Vector> liquid : liquidsAndDirections) {
        Material mat = liquid.getKey().getType();
        if(mat == Material.STATIONARY_WATER || mat == Material.WATER) {
            finalForce.add(liquid.getValue());
        }
    }
    if(finalForce.lengthSquared() > 0 && !pp.isFlying()) {
        finalForce.normalize();
        finalForce.multiply(Physics.WATER_FLOW_FORCE_MULTIPLIER);
        return finalForce;
    }
    return finalForce;
}
 
Example 4
Source File: DefuseListener.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
private void participantDefuse(Player player, Entity entity) {
    if(!AntiGrief.Defuse.enabled()) return;

    // check tnt
    if(!(entity instanceof TNTPrimed)) return;

    TNTMatchModule tntmm = mm.getMatch(player.getWorld()).getMatchModule(TNTMatchModule.class);
    if(tntmm != null && !tntmm.getProperties().friendlyDefuse) return;

    MatchPlayer clicker = this.mm.getPlayer(player);
    if(clicker == null || !clicker.canInteract()) return;

    // check water
    Block block = entity.getLocation().getBlock();
    if(block != null && (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER)) {
        clicker.sendMessage(ChatColor.RED + PGMTranslations.t("defuse.water", clicker));
        return;
    }

    // check owner
    MatchPlayer owner = this.mm.getPlayer(entityResolver.getOwner(entity));
    if(owner == null || (owner != clicker && owner.getParty() == clicker.getParty())) { // cannot defuse own TNT
        // defuse TNT
        entity.remove();
        if(owner != null) {
            this.notifyDefuse(clicker, entity, ChatColor.RED + PGMTranslations.t("defuse.player", clicker, owner.getDisplayName(clicker) + ChatColor.RED));
            adminChannel.broadcast(clicker.getDisplayName() +
                                   ChatColor.WHITE + " defused " +
                                   owner.getDisplayName()
                                   + ChatColor.WHITE + "'s " +
                                   ChatColor.DARK_RED + "TNT");
        } else {
            this.notifyDefuse(clicker, entity, ChatColor.RED + PGMTranslations.t("defuse.world", clicker));
        }
    }
}
 
Example 5
Source File: LavaCheck.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
public boolean generatesCobble(Block block, Block toBlock){
    Material mirrorID1 = (block.getType().equals(Material.WATER)) || (block.getType().equals(Material.STATIONARY_WATER)) ? Material.LAVA : Material.WATER;
    Material mirrorID2 = (block.getType().equals(Material.WATER)) || (block.getType().equals(Material.STATIONARY_WATER)) ? Material.STATIONARY_LAVA : Material.STATIONARY_WATER;
    for (BlockFace face: FACES) {
        Block r = toBlock.getRelative(face);
        if ((r.getType().equals(mirrorID1)) || (r.getType().equals(mirrorID2))) {
            return true;
        }
    }
    return false;
}
 
Example 6
Source File: Materials.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
static boolean isWater(Material material) {
  return material == Material.WATER || material == Material.STATIONARY_WATER;
}
 
Example 7
Source File: CraftBlock.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public boolean isLiquid() {
    return (getType() == Material.WATER) || (getType() == Material.STATIONARY_WATER) || (getType() == Material.LAVA) || (getType() == Material.STATIONARY_LAVA);
}
 
Example 8
Source File: Materials.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
public static boolean isWater(Material material) {
    return material == Material.WATER || material == Material.STATIONARY_WATER;
}
 
Example 9
Source File: CraftBlock.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public boolean isLiquid() {
    return (getType() == Material.WATER) || (getType() == Material.STATIONARY_WATER) || (getType() == Material.LAVA) || (getType() == Material.STATIONARY_LAVA);
}
 
Example 10
Source File: LocationUtil.java    From UHC with MIT License 4 votes vote down vote up
/**
 * Checks for the highest safe to stand on block with 2 un-solid blocks above it (excluding above world height).
 *
 * <p>Does not teleport on to non-solid blocks or blocks that can damage the player.</p>
 * <p>Only teleports into water if it is not at head height (feet only)</p>
 * <p>
 *     If the world type is NETHER then searching will start at 128 instead of the world max height to avoid the
 *     bedrock roof.
 * </p>
 *
 * @param world world to check within
 * @param xcoord the x coord to check at
 * @param zcoord the z coord to check at
 * @return -1 if no valid location found, otherwise coordinate with non-air Y coord with 2 air blocks above it
 */
public static int findHighestTeleportableY(World world, int xcoord, int zcoord) {
    final Location startingLocation = new Location(
            world,
            xcoord,
            world.getEnvironment() == World.Environment.NETHER ? NETHER_MAX_HEIGHT : world.getMaxHeight(),
            zcoord
    );

    boolean above2WasSafe = false;
    boolean aboveWasSafe = false;
    boolean above2WasWater = false;
    boolean aboveWasWater = false;

    Block currentBlock = startingLocation.getBlock();

    Material type;
    boolean damagesPlayer;
    boolean canStandOn;
    boolean aboveAreSafe;
    while (currentBlock.getY() >= 0) {
        type = currentBlock.getType();

        // get info about the current block
        damagesPlayer = damagesPlayer(type);
        canStandOn = canStandOn(type);

        aboveAreSafe = aboveWasSafe && above2WasSafe && !above2WasWater;

        // valid block if it has 2 safe blocks above it, it doesn't damage the player,
        // is safe to stand on and there isn't any water in the head space
        if (aboveAreSafe && !damagesPlayer && canStandOn) {
            return currentBlock.getY();
        }

        // move safe blocks
        above2WasSafe = aboveWasSafe;
        aboveWasSafe = !canStandOn && !damagesPlayer;

        // move water blocks
        above2WasWater = aboveWasWater;
        aboveWasWater = type == Material.WATER || type == Material.STATIONARY_WATER;

        // move down a block and run again
        currentBlock = currentBlock.getRelative(BlockFace.DOWN);
    }

    return -1;
}