예제 #1
0
  /**
   * Modifies an experience gain using skill modifiers, global rate and perks
   *
   * @param skillType Skill being used
   * @param xp Experience amount to process
   * @return Modified experience
   */
  private float modifyXpGain(SkillType skillType, float xp) {
    if (player.getGameMode() == GameMode.CREATIVE
        || (skillType.getMaxLevel() <= getSkillLevel(skillType))
        || (Config.getInstance().getPowerLevelCap() <= getPowerLevel())) {
      return 0;
    }

    xp =
        (float)
            (xp
                / skillType.getXpModifier()
                * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());

    if (Config.getInstance().getToolModsEnabled()) {
      CustomTool tool = mcMMO.getModManager().getTool(player.getItemInHand());

      if (tool != null) {
        xp *= tool.getXpMultiplier();
      }
    }

    return PerksUtils.handleXpPerks(player, xp, skillType);
  }
예제 #2
0
파일: Alchemy.java 프로젝트: EasyMFnE/mcMMO
public final class Alchemy {
  public enum Tier {
    EIGHT(8),
    SEVEN(7),
    SIX(6),
    FIVE(5),
    FOUR(4),
    THREE(3),
    TWO(2),
    ONE(1);

    int numerical;

    private Tier(int numerical) {
      this.numerical = numerical;
    }

    public int toNumerical() {
      return numerical;
    }

    public static Tier fromNumerical(int numerical) {
      for (Tier tier : Tier.values()) {
        if (tier.toNumerical() == numerical) {
          return tier;
        }
      }
      return null;
    }

    protected int getLevel() {
      return AdvancedConfig.getInstance().getConcoctionsTierLevel(this);
    }
  }

  public static int catalysisUnlockLevel = AdvancedConfig.getInstance().getCatalysisUnlockLevel();
  public static int catalysisMaxBonusLevel =
      AdvancedConfig.getInstance().getCatalysisMaxBonusLevel();
  public static double catalysisMinSpeed = AdvancedConfig.getInstance().getCatalysisMinSpeed();
  public static double catalysisMaxSpeed = AdvancedConfig.getInstance().getCatalysisMaxSpeed();

  public static double potionXp = ExperienceConfig.getInstance().getPotionXP();

  public static Map<Block, AlchemyBrewTask> brewingStandMap = new HashMap<Block, AlchemyBrewTask>();

  private Alchemy() {};

  /**
   * Calculate base brewing speed, given a skill level and ignoring all perks.
   *
   * @param skillLevel Skill level used for calculation.
   * @return Base brewing speed for the level.
   */
  public static double calculateBrewSpeed(int skillLevel) {
    if (skillLevel < catalysisUnlockLevel) {
      return catalysisMinSpeed;
    }

    return Math.min(
        catalysisMaxSpeed,
        catalysisMinSpeed
            + (catalysisMaxSpeed - catalysisMinSpeed)
                * (skillLevel - catalysisUnlockLevel)
                / (catalysisMaxBonusLevel - catalysisUnlockLevel));
  }

  /**
   * Finish all active brews. Used upon Disable to prevent vanilla potions from being brewed upon
   * next Enable.
   */
  public static void finishAllBrews() {
    mcMMO.p.getLogger().info("Completing " + brewingStandMap.size() + " unfinished Alchemy brews.");
    for (Entry<Block, AlchemyBrewTask> entry : brewingStandMap.entrySet()) {
      entry.getValue().finishImmediately();
    }
  }
}
예제 #3
0
  /** @param blockState The {@link BlockState} to check ability activation for */
  public void herbalismBlockCheck(BlockState blockState) {
    Player player = getPlayer();
    Material material = blockState.getType();
    boolean oneBlockPlant = !(material == Material.CACTUS || material == Material.SUGAR_CANE_BLOCK);

    if (oneBlockPlant && mcMMO.getPlaceStore().isTrue(blockState)) {
      return;
    }

    if (!canBlockCheck()) {
      return;
    }

    Collection<ItemStack> drops = null;
    int amount = 1;
    int xp;
    boolean greenTerra = mcMMOPlayer.getAbilityMode(skill.getAbility());

    if (mcMMO.getModManager().isCustomHerbalismBlock(blockState)) {
      CustomBlock customBlock = mcMMO.getModManager().getBlock(blockState);
      xp = customBlock.getXpGain();

      if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS)
          && customBlock.isDoubleDropEnabled()) {
        drops = blockState.getBlock().getDrops();
      }
    } else {
      if (Permissions.greenThumbPlant(player, material)) {
        processGreenThumbPlants(blockState, greenTerra);
      }

      xp = ExperienceConfig.getInstance().getXp(skill, material);

      if (Config.getInstance().getDoubleDropsEnabled(skill, material)
          && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS)) {
        drops = blockState.getBlock().getDrops();
      }

      if (!oneBlockPlant) {
        amount = Herbalism.calculateCatciAndSugarDrops(blockState);
        xp *= amount;
      }
    }

    applyXpGain(xp);

    if (drops == null) {
      return;
    }

    for (int i = greenTerra ? 2 : 1; i != 0; i--) {
      if (SkillUtils.activationSuccessful(
          SecondaryAbility.HERBALISM_DOUBLE_DROPS,
          getPlayer(),
          getSkillLevel(),
          activationChance)) {
        for (ItemStack item : drops) {
          Misc.dropItems(blockState.getLocation(), item, amount);
        }
      }
    }
  }
예제 #4
0
파일: SkillType.java 프로젝트: nwich/mcMMO
 public double getXpModifier() {
   return ExperienceConfig.getInstance().getFormulaSkillModifier(this);
 }