Ejemplo n.º 1
0
 private static void finalRemoveLava(Block block) {
   if (AFFECTED_BLOCKS.containsKey(block)) {
     TempBlock.revertBlock(block, Material.AIR);
     AFFECTED_BLOCKS.remove(block);
   }
   if (WALL_BLOCKS.containsKey(block)) {
     TempBlock.revertBlock(block, Material.AIR);
     WALL_BLOCKS.remove(block);
   }
 }
Ejemplo n.º 2
0
 public static void cleanup() {
   for (Block block : AFFECTED_BLOCKS.keySet()) {
     TempBlock.revertBlock(block, Material.AIR);
     AFFECTED_BLOCKS.remove(block);
     WALL_BLOCKS.remove(block);
   }
   for (Block block : WALL_BLOCKS.keySet()) {
     TempBlock.revertBlock(block, Material.AIR);
     AFFECTED_BLOCKS.remove(block);
     WALL_BLOCKS.remove(block);
   }
 }
Ejemplo n.º 3
0
 private void addLava(Block block) {
   if (GeneralMethods.isRegionProtectedFromBuild(player, "LavaSurge", block.getLocation())) return;
   if (!TempBlock.isTempBlock(block)) {
     new TempBlock(block, Material.STATIONARY_LAVA, (byte) 8);
     AFFECTED_BLOCKS.put(block, block);
   }
 }
Ejemplo n.º 4
0
 private void removeLava(Block block) {
   if (block != null) {
     if (AFFECTED_BLOCKS.containsKey(block)) {
       if (!GeneralMethods.isAdjacentToThreeOrMoreSources(block)) {
         TempBlock.revertBlock(block, Material.AIR);
       }
       AFFECTED_BLOCKS.remove(block);
     }
   }
 }
Ejemplo n.º 5
0
 private void cancel() {
   if (progressing) {
     if (source != null) source.revertBlock();
     progressing = false;
   }
   BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
   if (bPlayer != null) {
     bPlayer.addCooldown("IceBlast", cooldown);
   }
   instances.remove(id);
 }
Ejemplo n.º 6
0
 private static boolean isFreezable(Player player, Block block) {
   if (GeneralMethods.isRegionProtectedFromBuild(player, "PhaseChange", block.getLocation())) {
     return false;
   }
   if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER) {
     if (WaterManipulation.canPhysicsChange(block) && !TempBlock.isTempBlock(block)) {
       return true;
     }
   }
   return false;
 }
Ejemplo n.º 7
0
 @SuppressWarnings("deprecation")
 static void freeze(Player player, Block block) {
   if (GeneralMethods.isRegionProtectedFromBuild(player, "PhaseChange", block.getLocation())) {
     return;
   }
   if (TempBlock.isTempBlock(block)) {
     return;
   }
   byte data = block.getData();
   block.setType(Material.ICE);
   if (frozenblocks.size() % 50 == 0) {
     WaterMethods.playIcebendingSound(block.getLocation());
   }
   frozenblocks.put(block, data);
 }
Ejemplo n.º 8
0
  public IceBlast(Player player) {
    if (!WaterMethods.canIcebend(player)) return;
    BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
    if (bPlayer.isOnCooldown("IceBlast")) {
      return;
    }

    block(player);
    range = WaterMethods.waterbendingNightAugment(defaultrange, player.getWorld());
    this.player = player;
    Block sourceblock =
        BlockSource.getWaterSourceBlock(player, range, ClickType.SHIFT_DOWN, false, true, false);

    if (sourceblock == null) {
      return;
    } else if (TempBlock.isTempBlock(sourceblock)) {
      return;
    } else {
      prepare(sourceblock);
    }
  }
Ejemplo n.º 9
0
  private void progress() {
    BendingPlayer bPlayer = GeneralMethods.getBendingPlayer(player.getName());
    if (player.isDead()
        || !player.isOnline()
        || !GeneralMethods.canBend(player.getName(), "IceBlast")
        || bPlayer.isOnCooldown("IceBlast")) {
      cancel();
      return;
    }

    if (!player.getWorld().equals(location.getWorld())) {
      cancel();
      return;
    }

    if (player.getEyeLocation().distance(location) >= range) {
      if (progressing) {
        breakParticles(20);
        cancel();
        returnWater();
      } else {
        breakParticles(20);
        cancel();
      }
      return;
    }

    if ((GeneralMethods.getBoundAbility(player) == null
            || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("IceBlast"))
        && prepared) {
      cancel();
      return;
    }

    if (System.currentTimeMillis() < time + interval) return;

    time = System.currentTimeMillis();

    if (progressing) {

      Vector direction;

      if (location.getBlockY() == firstdestination.getBlockY()) settingup = false;

      if (location.distance(destination) <= 2) {
        cancel();
        returnWater();
        return;
      }

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

      location.add(direction);

      Block block = location.getBlock();

      if (block.equals(sourceblock)) return;

      source.revertBlock();
      source = null;

      if (EarthMethods.isTransparentToEarthbending(player, block) && !block.isLiquid()) {
        GeneralMethods.breakBlock(block);
      } else if (!WaterMethods.isWater(block)) {
        breakParticles(20);
        cancel();
        returnWater();
        return;
      }

      if (GeneralMethods.isRegionProtectedFromBuild(player, "IceBlast", location)) {
        cancel();
        returnWater();
        return;
      }

      for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, affectingradius)) {
        if (entity.getEntityId() != player.getEntityId() && entity instanceof LivingEntity) {
          affect((LivingEntity) entity);
          progressing = false;
          returnWater();
        }
      }

      if (!progressing) {
        cancel();
        return;
      }

      sourceblock = block;
      source = new TempBlock(sourceblock, Material.PACKED_ICE, data);

      for (int x = 0; x < 10; x++) {
        ParticleEffect.ITEM_CRACK.display(
            new ParticleEffect.ItemData(Material.ICE, (byte) 0),
            new Vector(
                ((Math.random() - 0.5) * .5),
                ((Math.random() - 0.5) * .5),
                ((Math.random() - 0.5) * .5)),
            .5f,
            location,
            257.0D);
        ParticleEffect.SNOW_SHOVEL.display(
            location,
            (float) (Math.random() - 0.5),
            (float) (Math.random() - 0.5),
            (float) (Math.random() - 0.5),
            0,
            5);
      }
      if (GeneralMethods.rand.nextInt(4) == 0) {
        WaterMethods.playIcebendingSound(location);
      }
      location = location.add(direction.clone());

    } else if (prepared) {
      WaterMethods.playFocusWaterEffect(sourceblock);
    }
  }