示例#1
0
  /**
   * Handler for what blocks drop from the explosion.
   *
   * @param ores List of ore blocks destroyed by the explosion
   * @param debris List of non-ore blocks destroyed by the explosion
   * @param yield Percentage of blocks to drop
   * @param oreBonus Percentage bonus for ore drops
   * @param debrisReduction Percentage reduction for non-ore drops
   * @param extraDrops Number of times to drop each block
   * @return A list of blocks dropped from the explosion
   */
  private static List<Block> explosionYields(
      List<Block> ores,
      List<Block> debris,
      float yield,
      float oreBonus,
      float debrisReduction,
      int extraDrops) {
    Iterator<Block> oresIterator = ores.iterator();
    List<Block> blocksDropped = new ArrayList<Block>();

    while (oresIterator.hasNext()) {
      Block temp = oresIterator.next();

      if (random.nextFloat() < (yield + oreBonus)) {
        blocksDropped.add(temp);
        Mining.miningDrops(temp);

        if (!temp.hasMetadata("mcmmoPlacedBlock")) {
          for (int i = 1; i < extraDrops; i++) {
            blocksDropped.add(temp);
            Mining.miningDrops(temp);
          }
        }
      }
    }

    if (yield - debrisReduction > 0) {
      Iterator<Block> debrisIterator = debris.iterator();

      while (debrisIterator.hasNext()) {
        Block temp = debrisIterator.next();

        if (random.nextFloat() < (yield - debrisReduction)) Mining.miningDrops(temp);
      }
    }

    return blocksDropped;
  }
示例#2
0
  /**
   * Handler for explosion drops and XP gain.
   *
   * @param player Player triggering the explosion
   * @param event Event whose explosion is being processed
   */
  public static void dropProcessing(Player player, EntityExplodeEvent event) {
    final int RANK_1_LEVEL = 125;
    final int RANK_2_LEVEL = 250;
    final int RANK_3_LEVEL = 375;
    final int RANK_4_LEVEL = 500;
    final int RANK_5_LEVEL = 625;
    final int RANK_6_LEVEL = 750;
    final int RANK_7_LEVEL = 875;
    final int RANK_8_LEVEL = 1000;

    int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
    float yield = event.getYield();
    List<Block> blocks = event.blockList();
    Iterator<Block> iterator = blocks.iterator();

    List<Block> ores = new ArrayList<Block>();
    List<Block> debris = new ArrayList<Block>();
    List<Block> xp = new ArrayList<Block>();

    while (iterator.hasNext()) {
      Block temp = iterator.next();

      if (BlockChecks.isOre(temp.getType())) {
        ores.add(temp);
      } else {
        debris.add(temp);
      }
    }

    // Normal explosion
    if (skillLevel < RANK_1_LEVEL) {
      return;
    }

    event.setYield(0);

    // Triple Drops, No debris, +70% ores
    if (skillLevel >= RANK_8_LEVEL) {
      xp = explosionYields(ores, debris, yield, .70f, .30f, 3);
    }

    // Triple Drops, No debris, +65% ores
    else if (skillLevel >= RANK_7_LEVEL) {
      xp = explosionYields(ores, debris, yield, .65f, .30f, 3);
    }

    // Double Drops, No Debris, +60% ores
    else if (skillLevel >= RANK_6_LEVEL) {
      xp = explosionYields(ores, debris, yield, .60f, .30f, 2);
    }

    // Double Drops, No Debris, +55% ores
    else if (skillLevel >= RANK_5_LEVEL) {
      xp = explosionYields(ores, debris, yield, .55f, .30f, 2);
    }

    // No debris, +50% ores
    else if (skillLevel >= RANK_4_LEVEL) {
      xp = explosionYields(ores, debris, yield, .50f, .30f, 1);
    }

    // No debris, +45% ores
    else if (skillLevel >= RANK_3_LEVEL) {
      xp = explosionYields(ores, debris, yield, .45f, .30f, 1);
    }

    // +40% ores, -20% debris
    else if (skillLevel >= RANK_2_LEVEL) {
      xp = explosionYields(ores, debris, yield, .40f, .20f, 1);
    }

    // +35% ores, -10% debris
    else if (skillLevel >= RANK_1_LEVEL) {
      xp = explosionYields(ores, debris, yield, .35f, .10f, 1);
    }

    for (Block block : xp) {
      if (!block.hasMetadata("mcmmoPlacedBlock")) {
        Mining.miningXP(player, block);
      }
    }
  }