Class TradeOffer

java.lang.Object
net.minecraft.village.TradeOffer

public class TradeOffer
extends Object
  • Field Details

    • firstBuyItem

      private final ItemStack firstBuyItem
    • secondBuyItem

      private final ItemStack secondBuyItem
    • sellItem

      private final ItemStack 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

      public TradeOffer​(NbtCompound nbtCompound)
    • TradeOffer

      public TradeOffer​(ItemStack buyItem, ItemStack sellItem, int maxUses, int merchantExperience, float priceMultiplier)
    • TradeOffer

      public TradeOffer​(ItemStack firstBuyItem, ItemStack secondBuyItem, ItemStack sellItem, int maxUses, int merchantExperience, float priceMultiplier)
    • TradeOffer

      public TradeOffer​(ItemStack firstBuyItem, ItemStack secondBuyItem, ItemStack sellItem, int uses, int maxUses, int merchantExperience, float priceMultiplier)
    • TradeOffer

      public TradeOffer​(ItemStack itemStack, ItemStack itemStack2, ItemStack itemStack3, int int2, int int3, int int4, float float2, int int5)
  • Method Details

    • getOriginalFirstBuyItem

      public ItemStack getOriginalFirstBuyItem()
      Returns the first buy item of this trade offer.
    • getAdjustedFirstBuyItem

      public ItemStack 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

      public ItemStack getSecondBuyItem()
      Returns the second buy item of this trade offer.

      If there is no second buy item, this returns the empty item stack.

    • getSellItem

      public ItemStack 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

      public ItemStack 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 by increment.

      A negative increment value 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 to specialPrice.
    • 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

      public NbtCompound toNbt()
    • matchesBuyItems

      public boolean matchesBuyItems​(ItemStack first, ItemStack second)
    • acceptsBuy

      private boolean acceptsBuy​(ItemStack given, ItemStack sample)
    • depleteBuyItems

      public boolean depleteBuyItems​(ItemStack firstBuyStack, ItemStack secondBuyStack)