类 MerchantRecipe
java.lang.Object
org.bukkit.inventory.MerchantRecipe
- 所有已实现的接口:
Recipe
Represents a merchant's trade.
Trades can take one or two ingredients, and provide one result. The
ingredients' ItemStack amounts are respected in the trade.
A trade has a limited number of uses, after which the trade can no longer be used, unless the player uses a different trade, which will cause its maximum uses to increase.
A trade may or may not reward experience for being completed.
During trades, the
A trade has a limited number of uses, after which the trade can no longer be used, unless the player uses a different trade, which will cause its maximum uses to increase.
A trade may or may not reward experience for being completed.
During trades, the
MerchantRecipe dynamically adjusts the amount of
its first ingredient based on the following criteria:
Demand: This value is periodically updated by the villager that owns this merchant recipe based on how often the recipe has been used since it has been last restocked in relation to itsmaximum uses. The amount by which the demand influences the amount of the first ingredient is scaled by the recipe'sprice multiplier, and can never be below zero.Special price: This value is dynamically updated whenever a player starts and stops trading with a villager that owns this merchant recipe. It is based on the player's individual reputation with the villager, and the player's currently active status effects (seePotionEffectType.HERO_OF_THE_VILLAGE). The influence of the player's reputation on the special price is scaled by the recipe'sprice multiplier.
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 item stack's
maximum stack size.-
构造器概要
构造器构造器说明MerchantRecipe(ItemStack result, int maxUses) MerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward) MerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int villagerExperience, float priceMultiplier) MerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int villagerExperience, float priceMultiplier, int demand, int specialPrice) -
方法概要
修饰符和类型方法说明voidaddIngredient(ItemStack item) voidModifies the amount of the givenItemStackin the same way as MerchantRecipe dynamically adjusts the amount of the first ingredient during trading.Gets theadjustedfirst ingredient.intGet the value of the demand for the item ingetResult().intGet the maximum number of uses this trade has.floatGets the additive price multiplier for the cost of this trade.得到这个配方的结果.intGet the special price for this trade.intgetUses()Get the number of times this trade has been used.intGets the amount of experience the villager earns from this trade.booleanWhether to reward experience to the player for the trade.voidremoveIngredient(int index) voidsetDemand(int demand) Set the value of the demand for the item ingetResult().voidsetExperienceReward(boolean flag) Set whether to reward experience to the player for the trade.voidsetIngredients(List<ItemStack> ingredients) voidsetMaxUses(int maxUses) Set the maximum number of uses this trade has.voidsetPriceMultiplier(float priceMultiplier) Sets the additive price multiplier for the cost of this trade.voidsetSpecialPrice(int specialPrice) Set the special value for this trade.voidsetUses(int uses) Set the number of times this trade has been used.voidsetVillagerExperience(int villagerExperience) Sets the amount of experience the villager earns from this trade.
-
构造器详细资料
-
MerchantRecipe
-
MerchantRecipe
-
MerchantRecipe
public MerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int villagerExperience, float priceMultiplier) -
MerchantRecipe
public MerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int villagerExperience, float priceMultiplier, int demand, int specialPrice)
-
-
方法详细资料
-
getResult
从接口复制的说明:Recipe得到这个配方的结果.原文: Get the result of this recipe.
-
addIngredient
-
removeIngredient
public void removeIngredient(int index) -
setIngredients
-
getIngredients
-
getAdjustedIngredient1
Gets theadjustedfirst ingredient.- 返回:
- the adjusted first ingredient, or
nullif this recipe has no ingredients - 另请参阅:
-
adjust
Modifies the amount of the givenItemStackin 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- the item to adjust
-
getDemand
public int getDemand()Get the value of the demand for the item ingetResult().- 返回:
- the demand for the item
-
setDemand
public void setDemand(int demand) Set the value of the demand for the item ingetResult().
Note: This value is updated when the item is purchase- 参数:
demand- demand value
-
getSpecialPrice
public int getSpecialPrice()Get the special price for this trade.
Note: This value can be updated byVillagerReplenishTradeEvent.getBonus()or byPotionEffectType.HERO_OF_THE_VILLAGE- 返回:
- special price value
-
setSpecialPrice
public void setSpecialPrice(int specialPrice) Set the special value for this trade.
Note: This value can be updated byVillagerReplenishTradeEvent.getBonus()or byPotionEffectType.HERO_OF_THE_VILLAGE- 参数:
specialPrice- special price value
-
getUses
public int getUses()Get the number of times this trade has been used.- 返回:
- the number of uses
-
setUses
public void setUses(int uses) Set the number of times this trade has been used.- 参数:
uses- the number of uses
-
getMaxUses
public int getMaxUses()Get the maximum number of uses this trade has.
The maximum uses of this trade may increase when a player trades with the owning merchant.- 返回:
- the maximum number of uses
-
setMaxUses
public void setMaxUses(int maxUses) Set the maximum number of uses this trade has.- 参数:
maxUses- the maximum number of time this trade can be used
-
hasExperienceReward
public boolean hasExperienceReward()Whether to reward experience to the player for the trade.- 返回:
- whether to reward experience to the player for completing this trade
-
setExperienceReward
public void setExperienceReward(boolean flag) Set whether to reward experience to the player for the trade.- 参数:
flag- whether to reward experience to the player for completing this trade
-
getVillagerExperience
public int getVillagerExperience()Gets the amount of experience the villager earns from this trade.- 返回:
- villager experience
-
setVillagerExperience
public void setVillagerExperience(int villagerExperience) Sets the amount of experience the villager earns from this trade.- 参数:
villagerExperience- new experience amount
-
getPriceMultiplier
public float getPriceMultiplier()Gets the additive price multiplier for the cost of this trade.- 返回:
- price multiplier
-
setPriceMultiplier
public void setPriceMultiplier(float priceMultiplier) Sets the additive price multiplier for the cost of this trade.- 参数:
priceMultiplier- new price multiplier
-