private void breakBlock() {
    sourceblock.setType(sourcetype);
    if (revert) {
      EarthMethods.addTempAirBlock(sourceblock);
    } else {
      sourceblock.breakNaturally();
    }

    instances.remove(id);
  }
  private boolean moveEarth() {
    Block block = location.getBlock();
    location = location.add(direction);
    EarthMethods.moveEarth(player, block, direction, distance);
    loadAffectedBlocks();

    if (location.distance(origin) >= distance) {
      return false;
    }

    return true;
  }
 @SuppressWarnings("deprecation")
 public void throwEarth() {
   if (sourceblock != null) {
     if (sourceblock.getWorld().equals(player.getWorld())) {
       if (EarthMethods.movedearth.containsKey(sourceblock)) {
         if (!revert) {
           EarthMethods.removeRevertIndex(sourceblock);
         }
       }
       Entity target = GeneralMethods.getTargetedEntity(player, range, new ArrayList<Entity>());
       // Methods.verbose(target);
       if (target == null) {
         destination =
             player
                 .getTargetBlock(EarthMethods.getTransparentEarthbending(), (int) range)
                 .getLocation();
         firstdestination = sourceblock.getLocation().clone();
         firstdestination.setY(destination.getY());
       } else {
         destination = ((LivingEntity) target).getEyeLocation();
         firstdestination = sourceblock.getLocation().clone();
         firstdestination.setY(destination.getY());
         destination = GeneralMethods.getPointOnLine(firstdestination, destination, range);
       }
       if (destination.distance(location) <= 1) {
         progressing = false;
         destination = null;
       } else {
         progressing = true;
         EarthMethods.playEarthbendingSound(sourceblock.getLocation());
         // direction = getDirection().normalize();
         if (sourcetype != Material.SAND && sourcetype != Material.GRAVEL) {
           sourceblock.setType(sourcetype);
         }
       }
     }
   }
 }
  public EarthColumn(Player player, Location origin) {
    this.origin = origin;
    location = origin.clone();
    block = location.getBlock();
    this.player = player;
    distance =
        EarthMethods.getEarthbendableBlocksLength(
            player, block, direction.clone().multiply(-1), height);

    loadAffectedBlocks();

    if (distance != 0) {
      if (canInstantiate()) {
        id = ID;
        instances.put(id, this);
        if (ID >= Integer.MAX_VALUE) {
          ID = Integer.MIN_VALUE;
        }
        ID++;
        time = System.currentTimeMillis() - interval;
      }
    }
  }
  public EarthColumn(Player player) {
    BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());

    if (bPlayer.isOnCooldown("RaiseEarth")) return;

    try {
      if (AvatarState.isAvatarState(player)) {
        height = (int) (2. / 5. * (double) AvatarState.getValue(height));
      }
      block = BlockSource.getEarthSourceBlock(player, range, ClickType.LEFT_CLICK);
      if (block == null) return;
      origin = block.getLocation();
      location = origin.clone();
      distance =
          EarthMethods.getEarthbendableBlocksLength(
              player, block, direction.clone().multiply(-1), height);
    } catch (IllegalStateException e) {
      return;
    }

    this.player = player;

    loadAffectedBlocks();

    if (distance != 0) {
      if (canInstantiate()) {
        id = ID;
        instances.put(id, this);
        bPlayer.addCooldown("RaiseEarth", GeneralMethods.getGlobalCooldown());
        if (ID >= Integer.MAX_VALUE) {
          ID = Integer.MIN_VALUE;
        }
        ID++;
        time = System.currentTimeMillis() - interval;
      }
    }
  }
  private boolean progress() {
    if (player.isDead()
        || !player.isOnline()
        || !GeneralMethods.canBend(player.getName(), "EarthBlast")) {
      breakBlock();
      return false;
    }
    if (System.currentTimeMillis() - time >= interval) {
      time = System.currentTimeMillis();

      if (falling) {
        breakBlock();
        return false;
      }

      if (!EarthMethods.isEarthbendable(player, sourceblock)
          && sourceblock.getType() != Material.COBBLESTONE) {
        instances.remove(id);
        return false;
      }

      if (!progressing && !falling) {

        if (GeneralMethods.getBoundAbility(player) == null) {
          unfocusBlock();
          return false;
        }

        if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("EarthBlast")) {
          unfocusBlock();
          return false;
        }

        if (sourceblock == null) {
          instances.remove(id);
          return false;
        }
        if (!player.getWorld().equals(sourceblock.getWorld())) {
          unfocusBlock();
          return false;
        }
        if (sourceblock.getLocation().distance(player.getLocation()) > preparerange) {
          unfocusBlock();
          return false;
        }
      }

      if (falling) {
        breakBlock();

      } else {
        if (!progressing) {
          return false;
        }

        if (sourceblock.getY() == firstdestination.getBlockY()) {
          settingup = false;
        }

        Vector direction;
        if (settingup) {
          direction = GeneralMethods.getDirection(location, firstdestination).normalize();
        } else {
          direction = GeneralMethods.getDirection(location, destination).normalize();
        }

        location = location.clone().add(direction);

        WaterMethods.removeWaterSpouts(location, player);
        AirMethods.removeAirSpouts(location, player);

        Block block = location.getBlock();
        if (block.getLocation().equals(sourceblock.getLocation())) {
          location = location.clone().add(direction);
          block = location.getBlock();
        }

        if (EarthMethods.isTransparentToEarthbending(player, block) && !block.isLiquid()) {
          GeneralMethods.breakBlock(block);
        } else if (!settingup) {
          breakBlock();
          return false;
        } else {
          location = location.clone().subtract(direction);
          direction = GeneralMethods.getDirection(location, destination).normalize();
          location = location.clone().add(direction);

          WaterMethods.removeWaterSpouts(location, player);
          AirMethods.removeAirSpouts(location, player);
          double radius = FireBlast.AFFECTING_RADIUS;
          Player source = player;
          if (EarthBlast.annihilateBlasts(location, radius, source)
              || WaterManipulation.annihilateBlasts(location, radius, source)
              || FireBlast.annihilateBlasts(location, radius, source)) {
            breakBlock();
            return false;
          }

          Combustion.removeAroundPoint(location, radius);

          Block block2 = location.getBlock();
          if (block2.getLocation().equals(sourceblock.getLocation())) {
            location = location.clone().add(direction);
            block2 = location.getBlock();
          }

          if (EarthMethods.isTransparentToEarthbending(player, block) && !block.isLiquid()) {
            GeneralMethods.breakBlock(block);
          } else {
            breakBlock();
            return false;
          }
        }

        for (Entity entity :
            GeneralMethods.getEntitiesAroundPoint(location, FireBlast.AFFECTING_RADIUS)) {
          if (GeneralMethods.isRegionProtectedFromBuild(
              player, "EarthBlast", entity.getLocation())) {
            continue;
          }
          if (entity instanceof LivingEntity
              && (entity.getEntityId() != player.getEntityId() || hitself)) {

            AirMethods.breakBreathbendingHold(entity);

            Location location = player.getEyeLocation();
            Vector vector = location.getDirection();
            entity.setVelocity(vector.normalize().multiply(pushfactor));
            double damage = this.damage;
            if (EarthMethods.isMetal(sourceblock) && EarthMethods.canMetalbend(player)) {
              damage = EarthMethods.getMetalAugment(this.damage);
            }
            GeneralMethods.damageEntity(player, entity, damage);
            progressing = false;
          }
        }

        if (!progressing) {
          breakBlock();
          return false;
        }

        if (revert) {
          // Methods.addTempEarthBlock(sourceblock, block);
          if (sourceblock.getType() == Material.RED_SANDSTONE) {
            sourceblock.setType(sourcetype);
            if (sourcetype == Material.SAND) {
              sourceblock.setData((byte) 0x1);
            }
          } else {
            sourceblock.setType(sourcetype);
          }
          EarthMethods.moveEarthBlock(sourceblock, block);

          if (block.getType() == Material.SAND) {
            block.setType(Material.SANDSTONE);
          }
          if (block.getType() == Material.GRAVEL) {
            block.setType(Material.STONE);
          }
        } else {
          block.setType(sourceblock.getType());
          sourceblock.setType(Material.AIR);
        }

        sourceblock = block;

        if (location.distance(destination) < 1) {
          if (sourcetype == Material.SAND || sourcetype == Material.GRAVEL) {
            progressing = false;
            if (sourceblock.getType() == Material.RED_SANDSTONE) {
              sourcetype = Material.SAND;
              sourceblock.setType(sourcetype);
              sourceblock.setData((byte) 0x1);
            } else {
              sourceblock.setType(sourcetype);
            }
          }

          falling = true;
          progressing = false;
        }

        return true;
      }
    }

    return false;
  }