类 MerchantRecipe

java.lang.Object
org.bukkit.inventory.MerchantRecipe
所有已实现的接口:
Recipe

public class MerchantRecipe extends Object implements Recipe
代表一个商人交易。

交易可以使用一种或两种材料,并提供一种结果。材料的 ItemStack 数量在交易中会被考虑。

交易有最大使用次数。Villager 可以通过将其商人配方的 使用次数 重置为 0 来定期补充交易,从而允许再次使用。

交易完成时可能会也可能不会奖励经验值。

在交易期间,MerchantRecipe 会根据以下标准动态调整其第一种材料的数量:

  • 需求:此值由拥有此商人配方的村民根据该配方自上次补货以来的使用频率 相对于其 最大使用次数 进行定期更新。需求对第一种材料数量的影响 由配方的 价格倍率 缩放,且永远不会低于零。
  • 特殊价格:每当玩家开始或停止与拥有此商人配方的村民交易时, 此值会动态更新。它基于玩家与村民的个人声誉,以及玩家当前激活的状态效果(参见 PotionEffectType.HERO_OF_THE_VILLAGE)。玩家声誉对特殊价格的影响 由配方的 价格倍率 缩放。
第一种材料的调整数量通过以下方式计算:将第一种材料的原始数量、 经配方 价格倍率 缩放并截断为大于或等于 0 的最小整数的需求值、 以及特殊价格相加,然后将结果值限制在 1 到物品堆的 最大堆叠大小 之间。
  • 构造器详细资料

    • MerchantRecipe

      public MerchantRecipe(@NotNull @NotNull ItemStack result, int maxUses)
    • MerchantRecipe

      public MerchantRecipe(@NotNull @NotNull ItemStack result, int uses, int maxUses, boolean experienceReward)
    • MerchantRecipe

      public MerchantRecipe(@NotNull @NotNull ItemStack result, int uses, int maxUses, boolean experienceReward, int villagerExperience, float priceMultiplier)
    • MerchantRecipe

      public MerchantRecipe(@NotNull @NotNull ItemStack result, int uses, int maxUses, boolean experienceReward, int villagerExperience, float priceMultiplier, int demand, int specialPrice)
  • 方法详细资料

    • getResult

      @NotNull public @NotNull ItemStack getResult()
      从接口复制的说明: Recipe
      得到这个配方的结果.

      原文: Get the result of this recipe.

      指定者:
      getResult 在接口中 Recipe
      返回:
      ItemStack
    • addIngredient

      public void addIngredient(@NotNull @NotNull ItemStack item)
    • removeIngredient

      public void removeIngredient(int index)
    • setIngredients

      public void setIngredients(@NotNull @NotNull List<ItemStack> ingredients)
    • getIngredients

      @NotNull public @NotNull List<ItemStack> getIngredients()
    • getAdjustedIngredient1

      @Nullable public @Nullable ItemStack getAdjustedIngredient1()
      获取 调整后的 第一种材料。

      原文:Gets the adjusted first ingredient.

      返回:
      调整后的第一种材料,如果此配方没有材料则返回 null
      另请参阅:
    • adjust

      public void adjust(@Nullable @Nullable ItemStack itemStack)
      以与 MerchantRecipe 在交易期间动态调整第一种材料数量相同的方式修改给定 ItemStack 的数量。
      计算方式为:将物品的原始数量、经配方 价格倍率 缩放并截断为大于或等于 0 的最小整数的需求值、 以及特殊价格相加,然后将结果值限制在 1 到 ItemStack 的 最大堆叠大小 之间。

      原文:Modifies the amount of the given ItemStack in the same way as MerchantRecipe dynamically adjusts the amount of the first ingredient during trading.
      This is calculated by adding up the original amount of the item, the demand scaled by the recipe's price multiplier and truncated to the next lowest integer value greater than or equal to 0, and the special price, and then constraining the resulting value between 1 and the ItemStack's maximum stack size.

      参数:
      itemStack - 要调整的物品
    • getDemand

      public int getDemand()
      获取此交易的需求量。

      原文:Get the demand for this trade.

      返回:
      需求量
    • setDemand

      public void setDemand(int demand)
      设置此交易的需求量。

      原文:Set the demand for this trade.

      参数:
      demand - 新的需求量
    • getSpecialPrice

      public int getSpecialPrice()
      获取此交易的特殊价格。

      原文:Get the special price for this trade.

      返回:
      特殊价格值
    • setSpecialPrice

      public void setSpecialPrice(int specialPrice)
      设置此交易的特殊价格。

      原文:Set the special price for this trade.

      参数:
      specialPrice - 特殊价格值
    • getUses

      public int getUses()
      获取此交易已被使用的次数。

      原文:Get the number of times this trade has been used.

      返回:
      使用次数
    • setUses

      public void setUses(int uses)
      设置此交易已被使用的次数。

      原文:Set the number of times this trade has been used.

      参数:
      uses - 使用次数
    • getMaxUses

      public int getMaxUses()
      获取此交易的最大使用次数。

      原文:Get the maximum number of uses this trade has.

      返回:
      最大使用次数
    • setMaxUses

      public void setMaxUses(int maxUses)
      设置此交易的最大使用次数。

      原文:Set the maximum number of uses this trade has.

      参数:
      maxUses - 此交易可被使用的最大次数
    • hasExperienceReward

      public boolean hasExperienceReward()
      是否为交易奖励玩家经验值。

      原文:Whether to reward experience to the player for the trade.

      返回:
      完成此交易时是否奖励玩家经验值
    • setExperienceReward

      public void setExperienceReward(boolean flag)
      设置是否为交易奖励玩家经验值。

      原文:Set whether to reward experience to the player for the trade.

      参数:
      flag - 完成此交易时是否奖励玩家经验值
    • getVillagerExperience

      public int getVillagerExperience()
      获取村民从此交易中获得的经验值。

      原文:Gets the amount of experience the villager earns from this trade.

      返回:
      村民经验值
    • setVillagerExperience

      public void setVillagerExperience(int villagerExperience)
      设置村民从此交易中获得的经验值。

      原文:Sets the amount of experience the villager earns from this trade.

      参数:
      villagerExperience - 新经验值数量
    • getPriceMultiplier

      public float getPriceMultiplier()
      获取此交易成本的价格倍率。

      原文:Gets the price multiplier for the cost of this trade.

      返回:
      价格倍率
    • setPriceMultiplier

      public void setPriceMultiplier(float priceMultiplier)
      设置此交易成本的价格倍率。

      原文:Sets the price multiplier for the cost of this trade.

      参数:
      priceMultiplier - 新价格倍率