类 MerchantRecipe
- 所有已实现的接口:
Recipe
交易可以使用一种或两种材料,并提供一种结果。材料的 ItemStack 数量在交易中会被考虑。
交易有最大使用次数。Villager 可以通过将其商人配方的
使用次数 重置为 0 来定期补充交易,从而允许再次使用。
交易完成时可能会也可能不会奖励经验值。
在交易期间,MerchantRecipe 会根据以下标准动态调整其第一种材料的数量:
需求:此值由拥有此商人配方的村民根据该配方自上次补货以来的使用频率 相对于其最大使用次数进行定期更新。需求对第一种材料数量的影响 由配方的价格倍率缩放,且永远不会低于零。特殊价格:每当玩家开始或停止与拥有此商人配方的村民交易时, 此值会动态更新。它基于玩家与村民的个人声誉,以及玩家当前激活的状态效果(参见PotionEffectType.HERO_OF_THE_VILLAGE)。玩家声誉对特殊价格的影响 由配方的价格倍率缩放。
价格倍率 缩放并截断为大于或等于 0 的最小整数的需求值、
以及特殊价格相加,然后将结果值限制在 1 到物品堆的
最大堆叠大小 之间。-
构造器概要
构造器构造器说明MerchantRecipe(@NotNull ItemStack result, int maxUses) MerchantRecipe(@NotNull ItemStack result, int uses, int maxUses, boolean experienceReward) MerchantRecipe(@NotNull ItemStack result, int uses, int maxUses, boolean experienceReward, int villagerExperience, float priceMultiplier) MerchantRecipe(@NotNull ItemStack result, int uses, int maxUses, boolean experienceReward, int villagerExperience, float priceMultiplier, int demand, int specialPrice) -
方法概要
修饰符和类型方法说明voidaddIngredient(@NotNull ItemStack item) void以与 MerchantRecipe 在交易期间动态调整第一种材料数量相同的方式修改给定ItemStack的数量。获取调整后的第一种材料。int获取此交易的需求量。int获取此交易的最大使用次数。float获取此交易成本的价格倍率。得到这个配方的结果.int获取此交易的特殊价格。intgetUses()获取此交易已被使用的次数。int获取村民从此交易中获得的经验值。boolean是否为交易奖励玩家经验值。voidremoveIngredient(int index) voidsetDemand(int demand) 设置此交易的需求量。voidsetExperienceReward(boolean flag) 设置是否为交易奖励玩家经验值。voidsetIngredients(@NotNull List<ItemStack> ingredients) voidsetMaxUses(int maxUses) 设置此交易的最大使用次数。voidsetPriceMultiplier(float priceMultiplier) 设置此交易成本的价格倍率。voidsetSpecialPrice(int specialPrice) 设置此交易的特殊价格。voidsetUses(int uses) 设置此交易已被使用的次数。voidsetVillagerExperience(int villagerExperience) 设置村民从此交易中获得的经验值。
-
构造器详细资料
-
MerchantRecipe
-
MerchantRecipe
-
MerchantRecipe
-
MerchantRecipe
-
-
方法详细资料
-
getResult
从接口复制的说明:Recipe得到这个配方的结果.原文: Get the result of this recipe.
-
addIngredient
-
removeIngredient
public void removeIngredient(int index) -
setIngredients
-
getIngredients
-
getAdjustedIngredient1
- 返回:
- 调整后的第一种材料,如果此配方没有材料则返回
null - 另请参阅:
-
adjust
以与 MerchantRecipe 在交易期间动态调整第一种材料数量相同的方式修改给定ItemStack的数量。
计算方式为:将物品的原始数量、经配方价格倍率缩放并截断为大于或等于 0 的最小整数的需求值、 以及特殊价格相加,然后将结果值限制在1到ItemStack的最大堆叠大小之间。原文:Modifies the amount of the given
ItemStackin 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'sprice multiplierand truncated to the next lowest integer value greater than or equal to 0, and the special price, and then constraining the resulting value between1and theItemStack'smaximum 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- 新价格倍率
-