Exemplo n.º 1
0
  private int spoutableWaterHeight(Location location) {

    Location loc = location.clone();
    if (loc.getBlock().getType() != Material.AIR && !BlockTools.isWaterBased(loc.getBlock())) {
      return -1;
    }
    int height = HEIGHT;
    if (Tools.isNight(loc.getWorld())) {
      height = (int) (Settings.NIGHT_FACTOR * HEIGHT) + 1;
    }
    for (int i = 0; i <= (height + 1); i++) {
      Location locToTest = loc.add(0, -1, 0);
      if (ProtectionManager.isRegionProtectedFromBending(
          this.player, BendingAbilities.WaterSpout, locToTest)) {
        return -1;
      }
      Block block = locToTest.getBlock();
      if (block.getType().equals(Material.AIR)) {
        this.height = i + 1;
        continue;
      }
      if (BlockTools.isWaterBased(block)) {
        // Valid source !
        return i + 1;
      } else {
        return -1;
        // Cannot waterspout
      }
    }
    return -2;
    // Can waterspout but too high
  }
Exemplo n.º 2
0
 public static boolean canWaterSpout(Player player) {
   Location loc = player.getLocation();
   if (BlockTools.isWaterBased(loc.getBlock())) {
     return true;
   }
   int cpt = 0;
   while ((loc.getBlock().getType() == Material.AIR
           || loc.getBlock().getType() == Material.WATER
           || loc.getBlock().getType() == Material.STATIONARY_WATER)
       && (loc.getBlockY() > 0)
       && (cpt <= HEIGHT)) {
     loc = loc.add(0, -1, 0);
     if (BlockTools.isWaterBased(loc.getBlock())) {
       return true;
     }
     cpt++;
   }
   return false;
 }