Class TradeOfferHelper

java.lang.Object
net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper

public final class TradeOfferHelper extends Object
Utilities to help with registration of trade offers.
  • Method Details

    • registerVillagerOffers

      public static void registerVillagerOffers(VillagerProfession profession, int level, Consumer<List<TradeOffers.Factory>> factories)
      Registers trade offer factories for use by villagers.

      Below is an example, of registering a trade offer factory to be added a blacksmith with a profession level of 3:

       TradeOfferHelper.registerVillagerOffers(VillagerProfession.BLACKSMITH, 3, factories -> {
              factories.add(new CustomTradeFactory(...);
       });
       
      Parameters:
      profession - the villager profession to assign the trades to
      level - the profession level the villager must be to offer the trades
      factories - a consumer to provide the factories
    • registerWanderingTraderOffers

      public static void registerWanderingTraderOffers(int level, Consumer<List<TradeOffers.Factory>> factory)
      Registers trade offer factories for use by wandering trades.
      Parameters:
      level - the level the trades
      factory - a consumer to provide the factories
    • refreshOffers

      @Deprecated(forRemoval=true) public static void refreshOffers()
      Deprecated, for removal: This API element is subject to removal in a future version.
      This never did anything useful.