Interface TradeOffer.Builder

    • Method Detail

      • firstBuyingItem

        TradeOffer.Builder firstBuyingItem​(ItemStack item)

        Sets the first selling item of the trade offer to be generated.

        Trade offers require at least one item to be generated.

        Parameters:
        item - The first item to buy
        Returns:
        This builder
      • secondBuyingItem

        TradeOffer.Builder secondBuyingItem​(ItemStack item)
        Sets the second selling item of the trade offer to be generated.
        Parameters:
        item - The second item to buy
        Returns:
        This builder
      • sellingItem

        TradeOffer.Builder sellingItem​(ItemStack item)
        Sets the selling item of the trade offer to be generated.
        Parameters:
        item - The item to sell
        Returns:
        This builder
      • uses

        TradeOffer.Builder uses​(int uses)
        Sets the existing uses of the trade offer to be generated. A trade offer will become unusable when the uses surpasses the max uses.
        Parameters:
        uses - The uses
        Returns:
        This builder
      • maxUses

        TradeOffer.Builder maxUses​(int maxUses)
        Sets the maximum uses the generated trade offer will have. A trade offer will become unusable when the uses surpasses the max uses.
        Parameters:
        maxUses - The maximum uses of the trade offer
        Returns:
        This builder
      • canGrantExperience

        TradeOffer.Builder canGrantExperience​(boolean experience)
        Sets the trade offer to be generated to grant experience to the customer upon use.
        Parameters:
        experience - Whether the offer will grant experience
        Returns:
        This builder
      • merchantExperienceGranted

        TradeOffer.Builder merchantExperienceGranted​(int experience)
        Sets how much experience the trade offer will grant to the merchant upon use.
        Parameters:
        experience - The amount of experience.
        Returns:
        This builder
      • priceGrowthMultiplier

        TradeOffer.Builder priceGrowthMultiplier​(double priceGrowthMultiplier)
        Sets the rate at which the generated 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, trade demand will have no effect on this offer's price.

        Parameters:
        priceGrowthMultiplier - The offer's rate of price growth
        Returns:
        This builder
        See Also:
        the Minecraft Wiki for more detail on how the price growth multiplier applies to trade offers
      • demandBonus

        TradeOffer.Builder demandBonus​(int bonus)
        Sets the demand bonus for this trade offer.
        Parameters:
        bonus - The offer's demand bonus
        Returns:
        This builder
      • build

        TradeOffer build()
                  throws java.lang.IllegalStateException
        Creates a new TradeOffer instance with the current state of the builder.
        Specified by:
        build in interface AbstractBuilder<TradeOffer>
        Specified by:
        build in interface Buildable.Builder<TradeOffer>
        Returns:
        A new trade offer instance
        Throws:
        java.lang.IllegalStateException - If the resulting trade offer would be invalid