Interface TradeOffer

  • All Superinterfaces:
    DataSerializable

    public interface TradeOffer
    extends DataSerializable

    Represents a trade offer that a Merchant may offer a Humanoid.

    TradeOffers usually have a limited amount of times they can be used.

    Also, trade offers are not guaranteed to have two buying items.

    • Method Detail

      • firstBuyingItem

        ItemStackSnapshot firstBuyingItem()
        Gets the first buying item.

        The first buying item is an item that the customer is selling to the merchant in exchange for sellingItem().

        Returns:
        The first buying item
      • hasSecondItem

        boolean hasSecondItem()
        Returns whether this trade offer has a second item the merchant is buying from the customer.
        Returns:
        True if there is a second buying item
      • secondBuyingItem

        java.util.Optional<ItemStackSnapshot> secondBuyingItem()

        Gets the second buying item.

        The second buying item is an item that the customer is selling to the merchant, along with the firstBuyingItem(), in exchange for sellingItem().

        Returns:
        The second buying item, if available
      • uses

        int uses()

        Gets the current uses of this offer.

        Usually, the uses of an offer are limited by the amount of maxUses(). Once the uses reaches the max uses, the offer may temporarily become disabled.

        Returns:
        The current uses of this trade offer
      • maxUses

        int maxUses()

        Gets the current maximum uses of this offer.

        Usually, the uses of an offer are limited by the amount of maximum uses. Once the uses reaches the max uses, the offer may temporarily become disabled.

        Returns:
        The maximum uses of this trade offer
      • hasExpired

        boolean hasExpired()
        Checks if this trade offer has indeed passed the time of which the uses surpassed the maximum uses.
        Returns:
        True if the uses have surpassed the maximum uses
      • doesGrantExperience

        boolean doesGrantExperience()
        Gets whether this trade offer will grant experience to the customer upon usage or not.
        Returns:
        True if using this trade offer will grant experience to the customer
      • experienceGrantedToMerchant

        int experienceGrantedToMerchant()
        Gets the amount of experience granted to the merchant when this trade offer is used.
        Returns:
        The experience to be granted to the merchant
      • priceGrowthMultiplier

        double priceGrowthMultiplier()
        Gets the rate at which this trade offer's price will grow when demand for an item increases. Every time a villager trades, this value is multiplied by the current price of the offer and the demand bonus.

        If this value is 0, demand will have no effect on this offer's price.

        Returns:
        the price growth multiplier
        See Also:
        the Minecraft Wiki for more detail on how the price growth multiplier applies to trade offers
      • demandBonus

        int demandBonus()
        Gets the demand bonus for this trade offer.
        Returns:
        the demand bonus