Package net.minecraft.village
Class TradeOffer
java.lang.Object
net.minecraft.village.TradeOffer
public class TradeOffer extends Object
-
Field Summary
Fields Modifier and Type Field Description private intdemandBonusprivate ItemStackfirstBuyItemprivate intmaxUsesprivate intmerchantExperienceprivate floatpriceMultiplierprivate booleanrewardingPlayerExperienceprivate ItemStacksecondBuyItemprivate ItemStacksellItemprivate intspecialPriceprivate intuses -
Constructor Summary
Constructors Constructor Description TradeOffer(ItemStack buyItem, ItemStack sellItem, int maxUses, int merchantExperience, float priceMultiplier)TradeOffer(ItemStack firstBuyItem, ItemStack secondBuyItem, ItemStack sellItem, int maxUses, int merchantExperience, float priceMultiplier)TradeOffer(ItemStack firstBuyItem, ItemStack secondBuyItem, ItemStack sellItem, int uses, int maxUses, int merchantExperience, float priceMultiplier)TradeOffer(ItemStack itemStack, ItemStack itemStack2, ItemStack itemStack3, int int2, int int3, int int4, float float2, int int5)TradeOffer(NbtCompound nbtCompound) -
Method Summary
Modifier and Type Method Description private booleanacceptsBuy(ItemStack given, ItemStack sample)voidclearSpecialPrice()Resets the special price of this trade offer.ItemStackcopySellItem()Returns a copy of the sell item of this trade offer.booleandepleteBuyItems(ItemStack firstBuyStack, ItemStack secondBuyStack)voiddisable()Sets the number of times this trade offer has been used to its maximum uses, making it disabled.ItemStackgetAdjustedFirstBuyItem()Returns a copy of the first buy item of this trade offer, with its price adjusted depending on the demand bonus, the special price and the price multiplier.intgetDemandBonus()Returns the demand bonus of this trade offer.intgetMaxUses()Returns the maximum number of times this trade offer can be used.intgetMerchantExperience()Returns the amount of experience that will be given to a merchant after this trade offer has been used.ItemStackgetOriginalFirstBuyItem()Returns the first buy item of this trade offer.floatgetPriceMultiplier()Returns the price multiplier of this trade offer.ItemStackgetSecondBuyItem()Returns the second buy item of this trade offer.ItemStackgetSellItem()Returns the sell item of this trade offer.intgetSpecialPrice()Returns the special price of this trade offer.intgetUses()Returns the number of times this trade offer has been used.voidincreaseSpecialPrice(int increment)Increases the special price of this trade offer byincrement.booleanisDisabled()Returns whether this trade offer is disabled.booleanmatchesBuyItems(ItemStack first, ItemStack second)booleanmethod_21834()voidresetUses()Resets the number of times this trade offer has been used.voidsetSpecialPrice(int specialPrice)Sets the special price of this trade offer tospecialPrice.booleanshouldRewardPlayerExperience()Returns whether experience should be given to a player when they use this trade offer.NbtCompoundtoNbt()voidupdateDemandBonus()Updates the demand bonus of this trade offer depending on its previous demand bonus, the number of times it has been used and its remaining uses.voiduse()Increments the number of times this trade offer has been used.
-
Field Details
-
firstBuyItem
-
secondBuyItem
-
sellItem
-
uses
private int uses -
maxUses
private final int maxUses -
rewardingPlayerExperience
private boolean rewardingPlayerExperience -
specialPrice
private int specialPrice -
demandBonus
private int demandBonus -
priceMultiplier
private float priceMultiplier -
merchantExperience
private int merchantExperience
-
-
Constructor Details
-
TradeOffer
-
TradeOffer
-
TradeOffer
-
TradeOffer
-
TradeOffer
-
-
Method Details
-
getOriginalFirstBuyItem
Returns the first buy item of this trade offer. -
getAdjustedFirstBuyItem
Returns a copy of the first buy item of this trade offer, with its price adjusted depending on the demand bonus, the special price and the price multiplier. -
getSecondBuyItem
Returns the second buy item of this trade offer.If there is no second buy item, this returns the empty item stack.
-
getSellItem
Returns the sell item of this trade offer. -
updateDemandBonus
public void updateDemandBonus()Updates the demand bonus of this trade offer depending on its previous demand bonus, the number of times it has been used and its remaining uses. -
copySellItem
Returns a copy of the sell item of this trade offer. -
getUses
public int getUses()Returns the number of times this trade offer has been used. -
resetUses
public void resetUses()Resets the number of times this trade offer has been used. -
getMaxUses
public int getMaxUses()Returns the maximum number of times this trade offer can be used. -
use
public void use()Increments the number of times this trade offer has been used. -
getDemandBonus
public int getDemandBonus()Returns the demand bonus of this trade offer. It is used to adjust the price of its first buy item.The more the demand bonus is, the more the price will be high.
It is updated when a villager restocks.
- See Also:
updateDemandBonus()
-
increaseSpecialPrice
public void increaseSpecialPrice(int increment)Increases the special price of this trade offer byincrement.A negative
incrementvalue will decrease the special price. -
clearSpecialPrice
public void clearSpecialPrice()Resets the special price of this trade offer. -
getSpecialPrice
public int getSpecialPrice()Returns the special price of this trade offer. It is used to adjust the price of its first buy item.The less the special price is, the more the price will be low.
-
setSpecialPrice
public void setSpecialPrice(int specialPrice)Sets the special price of this trade offer tospecialPrice. -
getPriceMultiplier
public float getPriceMultiplier()Returns the price multiplier of this trade offer. It is used to adjust the price of its first buy item. -
getMerchantExperience
public int getMerchantExperience()Returns the amount of experience that will be given to a merchant after this trade offer has been used. -
isDisabled
public boolean isDisabled()Returns whether this trade offer is disabled.Checks if the number of times this trade offer has been used is greater or equal to its maximum uses.
-
disable
public void disable()Sets the number of times this trade offer has been used to its maximum uses, making it disabled. -
method_21834
public boolean method_21834() -
shouldRewardPlayerExperience
public boolean shouldRewardPlayerExperience()Returns whether experience should be given to a player when they use this trade offer. -
toNbt
-
matchesBuyItems
-
acceptsBuy
-
depleteBuyItems
-